Jump to content

DGARM Nagios Core - PNP4Nagios Fix Session Summary

From TetraWiki

Source video: DGARM-Nagios-Core-Fixed-PNP4Nagios-2026-07-17_11-33-20.mkv (94 min)

Summary[edit]

Two distinct parts on this recording:

Part 1 — Timeline/scope discussion (~0–15 min)[edit]

A tense check-in between the vendor engineer and client stakeholders (Pimlish/Murli side) about schedule slippage: it's day 5 and the install is still "on the same phase" after an original 1-week estimate. The engineer explains the delay is driven by integrating three additional components beyond bare Nagios Core, and why each matters:

  1. PNP4Nagios — Core has no graphing at all by default; without it the client would only get alerts, no historical performance data/graphs.
  2. Thruk — a significantly better web interface/dashboard than Core's built-in (primitive) GUI.
  3. NagiosQL — GUI-based host/device onboarding and templating, so onboarding doesn't require directly hand-editing config files (which is fragile/error-prone at scale).

Agreement reached: finish these three integrations first (today + one more day), then begin bulk device onboarding, rather than onboarding now and risking that integration work becomes much harder once real config is in place.

Part 2 — Live remote troubleshooting (~15–94 min)[edit]

Remote-access session (Zoom screen share/remote control, after WebEx was ruled out for Linux-desktop control) into dcprdlmonitor02, working through a PNP4Nagios graph rendering error:

  • Error observed: PNP4Nagios (v0.6.26) web UI threw:

<syntaxhighlight lang="text">

 sizeof(): Parameter must be an array or an object that implements Countable
 file: application/models/data.php [979]

</syntaxhighlight>

 This is a classic PHP 8.x compatibility break — older PNP4Nagios code calls sizeof() on a value that may not be an array/Countable, which PHP 7.2+ warns on and PHP 8+ errors on.
  • Fix applied (on dcprdlmonitor02):

<syntaxhighlight lang="bash">

 sudo cp /usr/local/pnp4nagios/share/application/models/data.php \
         /usr/local/pnp4nagios/share/application/models/data.php.bak
 sudo vi /usr/local/pnp4nagios/share/application/models/data.php
 # around line ~965-985, guarded the sizeof() call:
 if (is_array($pages) && sizeof($pages) > 0) {
     natsort($pages);
 } else {
     return FALSE;
 }
 return $pages;

</syntaxhighlight>

 i.e. added an is_array() guard before calling sizeof(), matching the getFirstPage() pattern already used elsewhere in the same file.
  • Referenced Nagios's official KB (support.nagios.com — "Nagios Core Performance Graphs Using PNP4Nagios") for the required Nagios object templates that wire hosts/ services to PNP4Nagios graphs:

<syntaxhighlight lang="text">

 define host {
     name        host-pnp
     action_url  /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_
     register    0
 }
 define service {
     name        service-pnp
     action_url  /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
     register    0
 }

</syntaxhighlight>

 added to /usr/local/nagios/etc/objects/templates.cfg.
  • Outcome: after the fix, RRD/performance data started flowing into PNP4Nagios graphs ("data started coming"). Session ends with the team agreeing to move on to NagiosQL next (matches the following NagiosQL fix video).

Root cause & fix (for the runbook)[edit]

Symptom Root cause Fix
PNP4Nagios graph page errors: sizeof(): Parameter must be an array or an object that implements Countable in application/models/data.php:979 PHP 8.x strict-typing break in old PNP4Nagios 0.6.26 code — sizeof() called without first checking the value is an array Back up data.php, add is_array($pages) && guard before the sizeof($pages) call
No graphs/performance data in Nagios Core at all Stock Nagios Core ships without any graphing; hosts/services aren't wired to PNP4Nagios by default Add host-pnp / service-pnp templates to templates.cfg with the correct action_url, per Nagios's official PNP4Nagios integration KB

Source recording[edit]