From 29c70aaefa10007ed10ded2b35cdf20398fb29c1 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Tue, 15 May 2012 16:50:36 +0000 Subject: [PATCH] fix some rrdtool_graph calls to use arrays. add NRG printer support. git-svn-id: http://www.observium.org/svn/observer/trunk@3187 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/images/os/nrg.png | Bin 0 -> 1026 bytes includes/definitions.inc.php | 8 ++++++ includes/discovery/os/nrg.inc.php | 8 ++++++ includes/polling/cisco-mac-accounting.inc.php | 6 +++-- includes/polling/os/nrg.inc.php | 17 +++++++++++++ includes/polling/ucd-mib.inc.php | 24 ++++++++---------- includes/polling/wifi.inc.php | 4 +-- 7 files changed, 49 insertions(+), 18 deletions(-) create mode 100644 html/images/os/nrg.png create mode 100644 includes/discovery/os/nrg.inc.php create mode 100644 includes/polling/os/nrg.inc.php diff --git a/html/images/os/nrg.png b/html/images/os/nrg.png new file mode 100644 index 0000000000000000000000000000000000000000..1172f2b507ecad7ed58de94a58c301cf83f3a722 GIT binary patch literal 1026 zcmV+d1pWJoP)8O5{|;zQcBMw*7EqS2yYER-q{rKnX=>Vrtd z8x~QbRza|cB2pCbMWR(Ac`32+GL6@UDot~NBvwhZNvAWJlgy0goW1w*p~;B&!+QDn zS>Iah_qhcTFZ)SHg^aDN@Y&tFO6`nAOF#TMY`HKG8{;w7Ug}?3%tZ|*x2~7iN*fywY1D0BVwxK z`Zo>dHLkPS&vd5gQ?u@|EDE~2k4O^Iz_Ka;TmrxVh{?%kY%bctMHyPh0e}QIB&3Fv z01z76vCB91Je3+6JR5D^TrX#4ZUdlEscd@aiNmc}TI^-U004A4y}Eqtt%Ldf`;fh> zFNbnD#>2o?iNtvc5Uvcs07IN}7KXweAMa&GYXBO6z<(oo7$W)Ocdv)7trz+HeAgNm zu$}3Mv(Tz?!n9+({Px5?zu5Rl5Wa*}!Hs{P3C%2AJso3^cBg^(TUk_CuJ+zgL=C0zY wlx1Zy88bHaXOPZ>vLVI7`wmVf9)B$V4`Elm8;z?Fm;e9(07*qoM6N<$f?OQny8r+H literal 0 HcmV?d00001 diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php index 5919cfbdb..1122612d7 100644 --- a/includes/definitions.inc.php +++ b/includes/definitions.inc.php @@ -758,6 +758,14 @@ $config['os'][$os]['icon'] = "ricoh"; $config['os'][$os]['over'][0]['graph'] = "device_toner"; $config['os'][$os]['over'][0]['text'] = "Toner"; +$os = "nrg"; +$config['os'][$os]['group'] = "printer"; +$config['os'][$os]['text'] = "NRG Printer"; +$config['os'][$os]['type'] = "printer"; +$config['os'][$os]['icon'] = "nrg"; +$config['os'][$os]['over'][0]['graph'] = "device_toner"; +$config['os'][$os]['over'][0]['text'] = "Toner"; + $os = "epson"; $config['os'][$os]['group'] = "printer"; $config['os'][$os]['text'] = "Epson Printer"; diff --git a/includes/discovery/os/nrg.inc.php b/includes/discovery/os/nrg.inc.php new file mode 100644 index 000000000..11bebecc1 --- /dev/null +++ b/includes/discovery/os/nrg.inc.php @@ -0,0 +1,8 @@ + diff --git a/includes/polling/cisco-mac-accounting.inc.php b/includes/polling/cisco-mac-accounting.inc.php index 64640aaf9..05bf065f8 100755 --- a/includes/polling/cisco-mac-accounting.inc.php +++ b/includes/polling/cisco-mac-accounting.inc.php @@ -74,8 +74,10 @@ if ($device['os_group'] == "cisco") DS:PIN:COUNTER:600:0:12500000000 \ DS:POUT:COUNTER:600:0:12500000000 " . $config['rrd_rra']); } - $woo = "N:".($b_in+0).":".($b_out+0).":".($p_in+0).":".($p_out+0); - $ret = rrdtool_update("$rrdfile", $woo); + + // FIXME - use memcached to make sure these values don't go backwards? + $rrdupdate = array($b_in, $b_out, $p_in, $p_out); + $ret = rrdtool_update("$rrdfile", $rrdupdate); if ($acc['update']) { /// Do Updates diff --git a/includes/polling/os/nrg.inc.php b/includes/polling/os/nrg.inc.php new file mode 100644 index 000000000..740e03e83 --- /dev/null +++ b/includes/polling/os/nrg.inc.php @@ -0,0 +1,17 @@ + diff --git a/includes/polling/ucd-mib.inc.php b/includes/polling/ucd-mib.inc.php index c1eb827f5..2a81cd9e0 100755 --- a/includes/polling/ucd-mib.inc.php +++ b/includes/polling/ucd-mib.inc.php @@ -52,7 +52,7 @@ if (is_numeric($ss['ssCpuRawUser']) && is_numeric($ss['ssCpuRawNice']) && is_num { rrdtool_create($cpu_rrd, $cpu_rrd_create); } - rrdtool_update($cpu_rrd, "N:".$ss['ssCpuRawUser'].":".$ss['ssCpuRawSystem'].":".$ss['ssCpuRawNice'].":".$ss['ssCpuRawIdle']); + rrdtool_update($cpu_rrd, array($ss['ssCpuRawUser'],$ss['ssCpuRawSystem'],$ss['ssCpuRawNice'],$ss['ssCpuRawIdle'])); $graphs['ucd_cpu'] = TRUE; } @@ -115,6 +115,8 @@ if (is_array($snmpdata[0])) foreach (array_keys($snmpdata[0]) as $key) { $$key = $snmpdata[0][$key]; } } +$snmpdata = $snmpdata[0]; + ## Check to see that the OIDs are actually populated before we make the rrd if (is_numeric($memTotalReal) && is_numeric($memAvailReal) && is_numeric($memTotalFree)) { @@ -123,7 +125,7 @@ if (is_numeric($memTotalReal) && is_numeric($memAvailReal) && is_numeric($memTot ## Create the rrd file if it doesn't exist rrdtool_create($mem_rrd, $mem_rrd_create); } - rrdtool_update($mem_rrd, "N:$memTotalSwap:$memAvailSwap:$memTotalReal:$memAvailReal:$memTotalFree:".($memShared+0).":".($memBuffer+0).":".($memCached+0)); + rrdtool_update($mem_rrd, array($memTotalSwap, $memAvailSwap, $memTotalReal, $memAvailReal, $memTotalFree, $memShared, $memBuffer, $memCached)); $graphs['ucd_memory'] = TRUE; } @@ -134,26 +136,20 @@ if (is_numeric($memTotalReal) && is_numeric($memAvailReal) && is_numeric($memTot #UCD-SNMP-MIB::laLoadInt.2 = INTEGER: 429 #UCD-SNMP-MIB::laLoadInt.3 = INTEGER: 479 -$la_load_create = " --step 300 DS:1min:GAUGE:600:0:5000 DS:5min:GAUGE:600:0:5000 DS:15min:GAUGE:600:0:5000 ".$config['rrd_rra']; +$load_raw = snmp_get_multi($device, "laLoadInt.1 laLoadInt.2 laLoadInt.3", "-OQUs", "UCD-SNMP-MIB"); -$load_get = "laLoadInt.1 laLoadInt.2 laLoadInt.3"; -$load_raw = snmp_get_multi($device, $load_get, "-OQUs", "UCD-SNMP-MIB"); -$load1 = $load_raw[1]['laLoadInt']; -$load5 = $load_raw[2]['laLoadInt']; -$load10 = $load_raw[3]['laLoadInt']; - -## Check to see that the OIDs are actually populated before we make the rrd -if (is_numeric($load1) && is_numeric($load5) && is_numeric($load10)) +## Check to see that the 5-min OID is actually populated before we make the rrd +if (is_numeric($load_raw[2]['laLoadInt'])) { if (!is_file($load_rrd)) { - rrdtool_create($load_rrd, $la_load_create); + rrdtool_create($load_rrd, " --step 300 DS:1min:GAUGE:600:0:5000 DS:5min:GAUGE:600:0:5000 DS:15min:GAUGE:600:0:5000 ".$config['rrd_rra']); } - rrdtool_update($load_rrd, "N:$load1:$load5:$load10"); + rrdtool_update($load_rrd, array($load_raw[1]['laLoadInt'], $load_raw[2]['laLoadInt'], $load_raw[3]['laLoadInt'])); $graphs['ucd_load'] = "TRUE"; } -unset($ss, $load1, $load5, $load10, $load_rrd, $la_load_create, $load_raw, $load_get, $snmpdata); +unset($ss, $load_rrd, $load_raw, $snmpdata); unset($memTotalSwap, $memAvailSwap, $memTotalReal, $memAvailReal, $memTotalFree, $memShared, $memBuffer, $memCached); unset($key, $mem_rrd, $mem_rrd_create, $collect_oids, $value, $filename, $cpu_rrd, $cpu_rrd_create, $oid); diff --git a/includes/polling/wifi.inc.php b/includes/polling/wifi.inc.php index 66ee71b9f..0eef95920 100644 --- a/includes/polling/wifi.inc.php +++ b/includes/polling/wifi.inc.php @@ -66,7 +66,7 @@ if ($device['type'] == 'network' || $device['type'] == 'firewall') DS:wificlients:GAUGE:600:-273:1000 ".$config['rrd_rra']); } - rrdtool_update($wificlientsrrd,"N:".$wificlients1); + rrdtool_update($wificlientsrrd,array($wificlients1)); $graphs['wifi_clients'] = TRUE; } @@ -81,7 +81,7 @@ if ($device['type'] == 'network' || $device['type'] == 'firewall') DS:wificlients:GAUGE:600:-273:1000 ".$config['rrd_rra']); } - rrdtool_update($wificlientsrrd,"N:".$wificlients2); + rrdtool_update($wificlientsrrd,array($wificlients2)); $graphs['wifi_clients'] = TRUE; }