From 7dfc4db15a69c185313f946fe19d95e846d09767 Mon Sep 17 00:00:00 2001 From: crcro Date: Tue, 2 Aug 2016 18:42:31 +0300 Subject: [PATCH] app-os-updates initial release --- doc/Extensions/Applications.md | 15 ++++++++ .../graphs/application/os-updates.inc.php | 36 +++++++++++++++++++ html/pages/device/apps/os-updates.inc.php | 28 +++++++++++++++ .../polling/applications/os-updates.inc.php | 18 ++++++++++ 4 files changed, 97 insertions(+) create mode 100644 html/includes/graphs/application/os-updates.inc.php create mode 100644 html/pages/device/apps/os-updates.inc.php create mode 100644 includes/polling/applications/os-updates.inc.php diff --git a/doc/Extensions/Applications.md b/doc/Extensions/Applications.md index 01a80c8499..58c9e052ec 100644 --- a/doc/Extensions/Applications.md +++ b/doc/Extensions/Applications.md @@ -10,6 +10,8 @@ Different applications support a variety of ways collect data: by direct connect 4. [PowerDNS](#powerdns) - Agent 5. [PowerDNS Recursor](#powerdns-recursor) - Agent 6. [TinyDNS/djbdns](#tinydns-aka-djbdns) - Agent +7. [OS Updates](#os-updates) - extend SNMP + * [Agent Setup](#agent-setup) @@ -121,6 +123,19 @@ chown dnslog:nofiles /service/dns/log/main/tinystats 3. Restart TinyDNS and Daemontools: `/etc/init.d/svscan restart` _Note_: Some say `svc -t /service/dns` is enough, on my install (Gentoo) it doesn't rehook the logging and I'm forced to restart it entirely. +### OS Updates +A small shell script that checks your system package manager for any available updates (supports yum/apt/zypper package managers). + +##### Extend SNMP +1. Copy the shell script to the desired host (the host must be added to LibreNMS devices) +2. Make the script executable (chmod +x /opt/os-updates.sh) +3. Edit your snmpd.conf file (usually /etc/snmp/snmpd.conf) and add: +``` +extend osupdate /opt/os-updates.sh +``` +4. Restart snmpd on your host +5. On the device page in Librenms, edit your host and check the `OS Updates` under the Applications tab. + Agent Setup ----------- diff --git a/html/includes/graphs/application/os-updates.inc.php b/html/includes/graphs/application/os-updates.inc.php new file mode 100644 index 0000000000..b86ed4a9ea --- /dev/null +++ b/html/includes/graphs/application/os-updates.inc.php @@ -0,0 +1,36 @@ + array('descr' => 'packages','colour' => '2B9220',), +); + +$i = 0; +if (is_file($rrd_filename)) { + foreach ($array as $ds => $vars) { + $rrd_list[$i]['filename'] = $rrd_filename; + $rrd_list[$i]['descr'] = $vars['descr']; + $rrd_list[$i]['ds'] = $ds; + $rrd_list[$i]['colour'] = $vars['colour']; + $i++; + } +} +else { + echo "file missing: $rrd_filename"; +} + +require 'includes/graphs/generic_v3_multiline.inc.php'; diff --git a/html/pages/device/apps/os-updates.inc.php b/html/pages/device/apps/os-updates.inc.php new file mode 100644 index 0000000000..31ba45b92a --- /dev/null +++ b/html/pages/device/apps/os-updates.inc.php @@ -0,0 +1,28 @@ + 'OS updates', +); + +foreach ($graphs as $key => $text) { + $graph_type = $key; + $graph_array['height'] = '100'; + $graph_array['width'] = '215'; + $graph_array['to'] = $config['time']['now']; + $graph_array['id'] = $app['app_id']; + $graph_array['type'] = 'application_'.$key; + + echo '
+
+

'.$text.'

+
+
+
'; + include 'includes/print-graphrow.inc.php'; + echo '
'; + echo '
'; + echo '
'; +} + diff --git a/includes/polling/applications/os-updates.inc.php b/includes/polling/applications/os-updates.inc.php new file mode 100644 index 0000000000..7bc14647f2 --- /dev/null +++ b/includes/polling/applications/os-updates.inc.php @@ -0,0 +1,18 @@ + $osupdates,); + +$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +data_update($device, 'app', $tags, $fields);