From 29f5afa47221d9408ffbb118e03c609486c21aa2 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Wed, 28 Jul 2010 12:59:59 +0000 Subject: [PATCH] split netstats pollers into protocols. update $graphs array for each one successfully polled git-svn-id: http://www.observium.org/svn/observer/trunk@1501 61d68cd4-352d-0410-923a-c4978735b2b8 --- includes/polling/hr-mib.inc.php | 39 +++++++++--- includes/polling/hr-mib_storage.inc.php | 45 -------------- includes/polling/ipSystemStats.inc.php | 5 ++ includes/polling/mempools.inc.php | 1 - includes/polling/netstats-icmp.inc.php | 52 ++++++++++++++++ includes/polling/netstats-ip.inc.php | 52 ++++++++++++++++ includes/polling/netstats-snmp.inc.php | 47 ++++++++++++++ includes/polling/netstats-tcp.inc.php | 54 ++++++++++++++++ includes/polling/netstats-udp.inc.php | 45 ++++++++++++++ includes/polling/netstats.inc.php | 83 +++---------------------- includes/polling/storage.inc.php | 4 ++ includes/polling/wireless.inc.php | 8 +++ 12 files changed, 304 insertions(+), 131 deletions(-) delete mode 100755 includes/polling/hr-mib_storage.inc.php create mode 100755 includes/polling/netstats-icmp.inc.php create mode 100755 includes/polling/netstats-ip.inc.php create mode 100755 includes/polling/netstats-snmp.inc.php create mode 100755 includes/polling/netstats-tcp.inc.php create mode 100755 includes/polling/netstats-udp.inc.php diff --git a/includes/polling/hr-mib.inc.php b/includes/polling/hr-mib.inc.php index 330947884..c4d6e6e9a 100755 --- a/includes/polling/hr-mib.inc.php +++ b/includes/polling/hr-mib.inc.php @@ -4,17 +4,17 @@ // Generic System Statistics $hrSystem_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/hrSystem.rrd"; -$hrSystem_cmd = $config['snmpget'] . " -M ".$config['mibdir']." -m HOST-RESOURCES-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; -$hrSystem_cmd .= " hrSystemProcesses.0 hrSystemNumUsers.0 hrMemorySize.0"; -$hrSystem = `$hrSystem_cmd`; -list ($hrSystemProcesses, $hrSystemNumUsers, $hrMemorySize) = explode("\n", $hrSystem); -if (!is_file($hrSystem_rrd)) { - shell_exec($config['rrdtool'] . " create $hrSystem_rrd \ +$oid_list = "hrSystemProcesses.0 hrSystemNumUsers.0"; +$hrSystem = snmp_get_multi ($device, $oid_list, "-OUQs", "HOST-RESOURCES-MIB"); + +if(isset($hrSystem[0]['hrSystemProcesses'])) +{ + $rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/hr-processes.rrd"; + if (!is_file($rrd_file)) { + shell_exec($config['rrdtool'] . " create $rrd_file \ --step 300 \ - DS:users:GAUGE:600:0:U \ DS:procs:GAUGE:600:0:U \ - DS:uptime:GAUGE:600:0:U \ RRA:AVERAGE:0.5:1:800 \ RRA:AVERAGE:0.5:6:800 \ RRA:AVERAGE:0.5:24:800 \ @@ -23,9 +23,30 @@ if (!is_file($hrSystem_rrd)) { RRA:MAX:0.5:6:800 \ RRA:MAX:0.5:24:800 \ RRA:MAX:0.5:288:800"); + } + rrdtool_update($rrd_file, "N:$hrSystemProcesses"); + $graphs['hrprocesses'] = TRUE; } -rrdtool_update($hrSystem_rrd, "N:$hrSystemNumUsers:$hrSystemProcesses:$uptime"); +if(isset($hrSystem[0]['hrSystemNumUsers'])) +{ + $rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/hr-users.rrd"; + if (!is_file($rrd_file)) { + shell_exec($config['rrdtool'] . " create $rrd_file \ + --step 300 \ + DS:users:GAUGE:600:0:U \ + RRA:AVERAGE:0.5:1:800 \ + RRA:AVERAGE:0.5:6:800 \ + RRA:AVERAGE:0.5:24:800 \ + RRA:AVERAGE:0.5:288:800 \ + RRA:MAX:0.5:1:800 \ + RRA:MAX:0.5:6:800 \ + RRA:MAX:0.5:24:800 \ + RRA:MAX:0.5:288:800"); + } + rrdtool_update($rrd_file, "N:$hrSystemNumUsers"); + $graphs['hrusers'] = TRUE; +} ?> diff --git a/includes/polling/hr-mib_storage.inc.php b/includes/polling/hr-mib_storage.inc.php deleted file mode 100755 index 6b672a58e..000000000 --- a/includes/polling/hr-mib_storage.inc.php +++ /dev/null @@ -1,45 +0,0 @@ -= $dr['storage_perc_warn']) - { - $msg = "Disk Alarm: " . $device['hostname'] . " " . $dr['storage_descr'] . " is " . $perc . "% at " . date($config['timestamp_format']); - notify($device, "Disk Alarm: " . $device['hostname'] . " " . $dr['storage_descr'], $msg); - echo("Alerting for " . $device['hostname'] . " " . $dr['storage_descr'] . "\n"); - } -} diff --git a/includes/polling/ipSystemStats.inc.php b/includes/polling/ipSystemStats.inc.php index 3d8feefa2..47f912a9c 100755 --- a/includes/polling/ipSystemStats.inc.php +++ b/includes/polling/ipSystemStats.inc.php @@ -88,6 +88,11 @@ if(!file_exists($rrdfile)) { shell_exec($rrd_create); } rrdtool_update($rrdfile, $rrdupdate); unset($rrdupdate, $rrd_create); + + ## FIXME per-AF? + + $graphs['ipSystemStats'] = TRUE; + } } diff --git a/includes/polling/mempools.inc.php b/includes/polling/mempools.inc.php index 0868b0ab2..c0aad509b 100755 --- a/includes/polling/mempools.inc.php +++ b/includes/polling/mempools.inc.php @@ -51,7 +51,6 @@ while($mempool = mysql_fetch_array($mempool_data)) { mysql_query($update_query); if($debug) { echo($update_query); } - } unset($mempool_cache); diff --git a/includes/polling/netstats-icmp.inc.php b/includes/polling/netstats-icmp.inc.php new file mode 100755 index 000000000..1502ec09e --- /dev/null +++ b/includes/polling/netstats-icmp.inc.php @@ -0,0 +1,52 @@ + diff --git a/includes/polling/netstats-ip.inc.php b/includes/polling/netstats-ip.inc.php new file mode 100755 index 000000000..7922ae703 --- /dev/null +++ b/includes/polling/netstats-ip.inc.php @@ -0,0 +1,52 @@ + diff --git a/includes/polling/netstats-snmp.inc.php b/includes/polling/netstats-snmp.inc.php new file mode 100755 index 000000000..346a40bfe --- /dev/null +++ b/includes/polling/netstats-snmp.inc.php @@ -0,0 +1,47 @@ + diff --git a/includes/polling/netstats-tcp.inc.php b/includes/polling/netstats-tcp.inc.php new file mode 100755 index 000000000..9238727bb --- /dev/null +++ b/includes/polling/netstats-tcp.inc.php @@ -0,0 +1,54 @@ + diff --git a/includes/polling/netstats-udp.inc.php b/includes/polling/netstats-udp.inc.php new file mode 100755 index 000000000..d7fabe202 --- /dev/null +++ b/includes/polling/netstats-udp.inc.php @@ -0,0 +1,45 @@ + diff --git a/includes/polling/netstats.inc.php b/includes/polling/netstats.inc.php index 60aa70af8..16ac14c37 100755 --- a/includes/polling/netstats.inc.php +++ b/includes/polling/netstats.inc.php @@ -1,82 +1,13 @@ diff --git a/includes/polling/storage.inc.php b/includes/polling/storage.inc.php index 1e4381321..f0b056ee9 100755 --- a/includes/polling/storage.inc.php +++ b/includes/polling/storage.inc.php @@ -2,6 +2,8 @@ $storage_cache = array(); +echo("Storage: "); + $query = "SELECT * FROM storage WHERE device_id = '" . $device['device_id'] . "'"; $storage_data = mysql_query($query); while($storage = mysql_fetch_array($storage_data)) { @@ -54,4 +56,6 @@ while($storage = mysql_fetch_array($storage_data)) { unset($storage); +echo("\n"); + ?> diff --git a/includes/polling/wireless.inc.php b/includes/polling/wireless.inc.php index 58a4df4e0..07340cc77 100644 --- a/includes/polling/wireless.inc.php +++ b/includes/polling/wireless.inc.php @@ -42,6 +42,9 @@ if ($device['type'] == 'network') } rrdtool_update($wificlientsrrd,"N:".$wificlients1); + + $graphs['airport_wireless'] = TRUE; + } if (isset($wificlients2) && $wificlients2 != "") @@ -59,8 +62,13 @@ if ($device['type'] == 'network') } rrdtool_update($wificlientsrrd,"N:".$wificlients2); + + $graphs['airport_wireless'] = TRUE; + } + unset($wificlients2, $wificlients1); + } echo "\n";