mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
app-os-updates initial release
This commit is contained in:
@@ -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
|
||||
-----------
|
||||
|
36
html/includes/graphs/application/os-updates.inc.php
Normal file
36
html/includes/graphs/application/os-updates.inc.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
require 'includes/graphs/common.inc.php';
|
||||
$name = 'os-updates';
|
||||
$app_id = $app['app_id'];
|
||||
$scale_min = 0;
|
||||
$colours = 'mixed';
|
||||
$unit_text = 'Available updates';
|
||||
$unitlen = 18;
|
||||
$bigdescrlen = 18;
|
||||
$smalldescrlen = 18;
|
||||
$dostack = 0;
|
||||
$printtotal = 0;
|
||||
$addarea = 1;
|
||||
$transparency = 33;
|
||||
|
||||
$rrd_filename = rrd_name($device['hostname'], array('app', $name, $app_id));
|
||||
|
||||
$array = array(
|
||||
'packages' => 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';
|
28
html/pages/device/apps/os-updates.inc.php
Normal file
28
html/pages/device/apps/os-updates.inc.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
global $config;
|
||||
|
||||
$graphs = array(
|
||||
'os-updates' => '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 '<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">'.$text.'</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="row">';
|
||||
include 'includes/print-graphrow.inc.php';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
18
includes/polling/applications/os-updates.inc.php
Normal file
18
includes/polling/applications/os-updates.inc.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
$name = 'os-updates';
|
||||
$app_id = $app['app_id'];
|
||||
$options = '-O qv';
|
||||
$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';
|
||||
|
||||
$rrd_name = array('app', $name, $app_id);
|
||||
$rrd_def = array(
|
||||
'DS:packages:GAUGE:600:0:U',
|
||||
);
|
||||
|
||||
$osupdates = snmp_get($device, $oid, $options, $mib);
|
||||
|
||||
$fields = array('packages' => $osupdates,);
|
||||
|
||||
$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name);
|
||||
data_update($device, 'app', $tags, $fields);
|
Reference in New Issue
Block a user