diff --git a/doc/Extensions/Applications.md b/doc/Extensions/Applications.md index 18ccf3057b..6f104db16c 100644 --- a/doc/Extensions/Applications.md +++ b/doc/Extensions/Applications.md @@ -1529,6 +1529,11 @@ The application should be auto-discovered as described at the top of the page. If it is not, please follow the steps set out under `SNMP Extend` heading top of page. +### Agent + +[Install the agent](Agent-Setup.md) on this device if it isn't already +and copy the `osupdate` script to `/usr/lib/check_mk_agent/local/` + ## PHP-FPM ### SNMP Extend diff --git a/includes/polling/applications/os-updates.inc.php b/includes/polling/applications/os-updates.inc.php index a40dfd0118..fa8159ae6e 100644 --- a/includes/polling/applications/os-updates.inc.php +++ b/includes/polling/applications/os-updates.inc.php @@ -3,15 +3,21 @@ use LibreNMS\RRD\RrdDefinition; $name = 'os-updates'; -$options = '-Oqv'; -$mib = 'NET-SNMP-EXTEND-MIB'; -$oid = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.8.111.115.117.112.100.97.116.101.1'; + +if (! empty($agent_data['app'][$name])) { + $osupdates = $agent_data['app'][$name]; +} else { + $options = '-Oqv'; + $mib = 'NET-SNMP-EXTEND-MIB'; + $oid = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.8.111.115.117.112.100.97.116.101.1'; + $osupdates = snmp_get($device, $oid, $options, $mib); + $osupdates = preg_replace('/^.+\n/', '', $osupdates); + $osupdates = str_replace("<<>>\n", '', $osupdates); +} $rrd_name = ['app', $name, $app->app_id]; $rrd_def = RrdDefinition::make()->addDataset('packages', 'GAUGE', 0); -$osupdates = snmp_get($device, $oid, $options, $mib); - $fields = ['packages' => $osupdates]; $tags = ['name' => $name, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; diff --git a/includes/polling/unix-agent.inc.php b/includes/polling/unix-agent.inc.php index 2c0919bd4b..d7cd8d1a1f 100644 --- a/includes/polling/unix-agent.inc.php +++ b/includes/polling/unix-agent.inc.php @@ -62,6 +62,7 @@ if ($device['os_group'] == 'unix' || $device['os'] == 'windows') { 'ceph', 'mysql', 'nginx', + 'os-updates', 'php-fpm', 'powerdns', 'powerdns-recursor',