clean up polling source files, remove dead code

git-svn-id: http://www.observium.org/svn/observer/trunk@1865 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-03-16 01:11:27 +00:00
parent 0b55624ba0
commit ecbcd1db43
41 changed files with 1135 additions and 1246 deletions
+4 -4
View File
@@ -1,7 +1,7 @@
<?php
if($device['os'] == "asa" || $device['os'] == "pix") {
if ($device['os'] == "asa" || $device['os'] == "pix")
{
echo("ALTIGA-MIB SSL VPN Statistics \n");
$oids = array('alSslStatsTotalSessions','alSslStatsActiveSessions','alSslStatsMaxSessions','alSslStatsPreDecryptOctets',
@@ -28,7 +28,8 @@ if($device['os'] == "asa" || $device['os'] == "pix") {
foreach ($oids as $oid)
{
if(is_numeric($data_array[0][$oid])) {
if (is_numeric($data_array[0][$oid]))
{
$value = $data_array[0][$oid];
} else {
$value = "0";
@@ -42,7 +43,6 @@ if($device['os'] == "asa" || $device['os'] == "pix") {
}
unset($rrdfile, $rrdupdate, $data_array);
}
?>
+2 -2
View File
@@ -7,7 +7,8 @@ $app_data = mysql_query($sql);
if (mysql_affected_rows())
{
echo('Applications: ');
while($app = mysql_fetch_array($app_data)) {
while ($app = mysql_fetch_array($app_data))
{
$app_include = $config['install_dir'].'/includes/polling/applications/'.$app['app_type'].'.inc.php';
if (is_file($app_include))
{
@@ -21,5 +22,4 @@ if(mysql_affected_rows())
echo("\n");
}
?>
+2 -2
View File
@@ -10,7 +10,8 @@ echo(" apache");
list ($total_access, $total_kbyte, $cpuload, $uptime, $reqpersec, $bytespersec, $bytesperreq, $busyworkers, $idleworkers,
$score_wait, $score_start, $score_reading, $score_writing, $score_keepalive, $score_dns, $score_closing, $score_logging, $score_graceful, $score_idle, $score_open) = explode("\n", $apache);
if (!is_file($apache_rrd)) {
if (!is_file($apache_rrd))
{
rrdtool_create($apache_rrd, "--step 300 \
DS:access:DERIVE:600:0:125000000000 \
DS:kbyte:DERIVE:600:0:125000000000 \
@@ -48,5 +49,4 @@ if (!is_file($apache_rrd)) {
rrdtool_update($apache_rrd, "N:$total_access:$total_kbyte:$cpuload:$uptime:$reqpersec:$bytespersec:$bytesperreq:$busyworkers:$idleworkers:$score_wait:$score_start:$score_reading:$score_writing:$score_keepalive:$score_dns:$score_closing:$score_logging:$score_graceful:$score_idle:$score_open");
?>
+17 -10
View File
@@ -2,12 +2,15 @@
echo("Polling BGP peers\n");
if(!$config['enable_bgp']) { echo("BGP Support Disabled\n"); } else {
$query = "SELECT * FROM bgpPeers WHERE device_id = '" . $device['device_id'] . "'";
$peers = mysql_query($query);
while($peer = mysql_fetch_array($peers)) {
if (!$config['enable_bgp'])
{
echo("BGP Support Disabled\n");
}
else
{
$peers = mysql_query("SELECT * FROM bgpPeers WHERE device_id = '" . $device['device_id'] . "'");
while ($peer = mysql_fetch_array($peers))
{
### Poll BGP Peer
echo("Checking ".$peer['bgpPeerIdentifier']." ");
@@ -42,6 +45,7 @@ if ($device['os'] == "junos")
$junos_v6[implode('.',array_slice($peer_id,35))] = implode('.',array_slice($peer_id,18));
}
}
## FIXME - move to function (and clean up, wtf?)
$peer_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . "/junos -m BGP4-V2-MIB-JUNIPER -OUvq -" . $device['snmpver'] . " -c" . $device['community'] . " " . $device['hostname'].":".$device['port'];
$peer_cmd .= " jnxBgpM2PeerState.0.ipv6." . $junos_v6[$peer_ip];
@@ -69,7 +73,9 @@ if ($device['os'] == "junos")
{
$bgpLocalAddr = strtolower($bgpLocalAddr);
for ($i = 0;$i < 32;$i+=4)
{
$bgpLocalAddr6[] = substr($bgpLocalAddr,$i,4);
}
$bgpLocalAddr = Net_IPv6::compress(implode(':',$bgpLocalAddr6)); unset($bgpLocalAddr6);
}
}
@@ -97,7 +103,8 @@ if ($device['os'] == "junos")
}
$peerrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("bgp-" . $peer['bgpPeerIdentifier'] . ".rrd");
if(!is_file($peerrrd)) {
if (!is_file($peerrrd))
{
$create_rrd = "DS:bgpPeerOutUpdates:COUNTER:600:U:100000000000 \
DS:bgpPeerInUpdates:COUNTER:600:U:100000000000 \
DS:bgpPeerOutTotal:COUNTER:600:U:100000000000 \
@@ -113,13 +120,13 @@ if ($device['os'] == "junos")
RRA:MAX:0.5:288:797";
rrdtool_create($peerrrd, $create_rrd);
}
rrdtool_update("$peerrrd", "N:$bgpPeerOutUpdates:$bgpPeerInUpdates:$bgpPeerOutTotalMessages:$bgpPeerInTotalMesages:$bgpPeerFsmEstablishedTime");
$update = "UPDATE bgpPeers SET bgpPeerState = '$bgpPeerState', bgpPeerAdminStatus = '$bgpPeerAdminStatus', ";
$update .= "bgpPeerFsmEstablishedTime = '$bgpPeerFsmEstablishedTime', bgpPeerInUpdates = '$bgpPeerInUpdates' , bgpLocalAddr = '$bgpLocalAddr' , bgpPeerOutUpdates = '$bgpPeerOutUpdates'";
$update .= " WHERE `device_id` = '".$device['device_id']."' AND bgpPeerIdentifier = '" . $peer['bgpPeerIdentifier'] . "'";
mysql_query($update);
if ($device['os_group'] == "ios" || $device['os'] == "junos")
@@ -231,6 +238,6 @@ if ($device['os'] == "junos")
echo("\n");
} ## End While loop on peers
} ## End check for BGP support
?>
@@ -1,60 +0,0 @@
<?php
echo("CISCO-ENHANCED-MEMPOOL: ");
$query = "SELECT * FROM cempMemPool WHERE device_id = '" . $device['device_id'] . "'";
$pool_data = mysql_query($query);
while($mempool = mysql_fetch_array($pool_data)) {
$entPhysicalName = @mysql_result(mysql_query("SELECT `entPhysicalName` from entPhysical WHERE device_id = '".$device['device_id']."'
AND `entPhysicalIndex` = '".$mempool['entPhysicalIndex']."'"),0);
echo($entPhysicalName . " - " . $mempool['cempMemPoolName'] . " ");
$oid = $mempool['entPhysicalIndex'] . "." . $mempool['Index'];
$pool_cmd = $config['snmpget']. " -M ".$config['mibdir'] . " -m CISCO-ENHANCED-MEMPOOL-MIB -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$pool_cmd .= " cempMemPoolUsed.$oid cempMemPoolFree.$oid cempMemPoolLargestFree.$oid cempMemPoolLowestFree.$oid";
$pool_cmd .= " | cut -f 1 -d ' '";
$pool = shell_exec($pool_cmd);
list($cempMemPoolUsed, $cempMemPoolFree, $cempMemPoolLargestFree, $cempMemPoolLowestFree) = explode("\n", $pool);
echo(round(($cempMemPoolUsed/($cempMemPoolFree+$cempMemPoolUsed))*100) . "% ");
$poolrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("cempMemPool-" . $oid . ".rrd");
if (!is_file($poolrrd)) {
`rrdtool create $poolrrd \
--step 300 \
DS:used:GAUGE:600:0:U \
DS:free:GAUGE:600:-1:U \
DS:largestfree:GAUGE:600:0:U \
DS:lowestfree:GAUGE:600:-1:U \
RRA:AVERAGE:0.5:1:2000 \
RRA:AVERAGE:0.5:6:2000 \
RRA:AVERAGE:0.5:24:2000 \
RRA:AVERAGE:0.5:288:2000 \
RRA:MAX:0.5:1:2000 \
RRA:MAX:0.5:6:2000 \
RRA:MAX:0.5:24:2000 \
RRA:MAX:0.5:288:2000`;
}
$pool = trim(str_replace("\"", "", $pool));
list($pool) = split(" ", $pool);
$updatecmd = $config['rrdtool'] ." update $poolrrd N:$cempMemPoolUsed:$cempMemPoolFree:$cempMemPoolLargestFree:$cempMemPoolLowestFree";
shell_exec($updatecmd);
$update_query = "UPDATE `cempMemPool` SET cempMemPoolUsed='$cempMemPoolUsed', cempMemPoolFree='$cempMemPoolFree', cempMemPoolLargestFree='$cempMemPoolLargestFree', cempMemPoolLowestFree='$cempMemPoolLowestFree' WHERE `cempMemPool_id` = '".$mempool['cempMemPool_id']."'";
mysql_query($update_query);
}
echo("\n");
?>
@@ -2,8 +2,8 @@
$query = "SELECT * FROM entPhysical WHERE device_id = '" . $device['device_id'] . "' AND entPhysicalClass = 'sensor'";
$sensors = mysql_query($query);
while($sensor = mysql_fetch_array($sensors)) {
while ($sensor = mysql_fetch_array($sensors))
{
echo("Checking Entity Sensor " . $sensor['entPhysicalName'] . " - " . $sensor['cempsensorName']);
$oid = $sensor['entPhysicalIndex'];
@@ -19,9 +19,9 @@ while($sensor = mysql_fetch_array($sensors)) {
$rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("ces-" . $oid . ".rrd");
if (!is_file($rrd)) {
`rrdtool create $rrd \
--step 300 \
if (!is_file($rrd))
{
rrdtool_create($rrd,"--step 300 \
DS:value:GAUGE:600:-1000:U \
RRA:AVERAGE:0.5:1:2304 \
RRA:AVERAGE:0.5:6:1536 \
@@ -34,7 +34,7 @@ while($sensor = mysql_fetch_array($sensors)) {
RRA:MIN:0.5:1:2304 \
RRA:MIN:0.5:6:1536 \
RRA:MIN:0.5:24:2268 \
RRA:MIN:0.5:288:1890`;
RRA:MIN:0.5:288:1890");
}
$entSensorValue = entPhysical_scale($entSensorValue, $sensor['entSensorScale']);
@@ -46,7 +46,6 @@ while($sensor = mysql_fetch_array($sensors)) {
mysql_query($update_query);
echo($entSensorValue . " - " . $entSensorStatus . "\n");
}
?>
@@ -32,8 +32,8 @@
#CISCO-IPSEC-FLOW-MONITOR-MIB::cipSecGlobalNoSaFails.0 = Counter32: 5 Failures
#CISCO-IPSEC-FLOW-MONITOR-MIB::cipSecGlobalSysCapFails.0 = Counter32: 0 Failures
if($device['os_group'] == "ios") {
if ($device['os_group'] == "ios")
{
$data = snmpwalk_cache_oid($device, "cipSecGlobalStats", NULL, "CISCO-IPSEC-FLOW-MONITOR-MIB");
$data = $data[0];
@@ -43,7 +43,6 @@ if($device['os_group'] == "ios") {
if (is_numeric($data['cipSecGlobalHcInDecompOctets'])) { $data['cipSecGlobalInDecompOctets'] = $data['cipSecGlobalHcInDecompOctets']; }
if (is_numeric($data['cipSecGlobalHcOutUncompOctets'])) { $data['cipSecGlobalOutUncompOctets'] = $data['cipSecGlobalHcOutUncompOctets']; }
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("cipsec_flow.rrd");
$rrd_create = " DS:Tunnels:GAUGE:600:0:U";
$rrd_create .= " DS:InOctets:COUNTER:600:0:100000000000";
@@ -118,8 +117,8 @@ if($device['os_group'] == "ios") {
$graphs['cipsec_flow_stats'] = TRUE;
echo(" cipsec_flow");
}
unset($data, $$rrd_filename, $rrd_create, $rrd_update);
}
+11 -7
View File
@@ -15,16 +15,17 @@ $polled = time();
$mac_entries = 0;
$mac_accounting_query = mysql_query("SELECT *, A.poll_time AS poll_time FROM `mac_accounting` as A, `ports` AS I where A.interface_id = I.interface_id AND I.device_id = '".$device['device_id']."'");
while ($acc = mysql_fetch_assoc($mac_accounting_query)) {
while ($acc = mysql_fetch_assoc($mac_accounting_query))
{
$device_id = $acc['device_id'];
$ifIndex = $acc['ifIndex'];
$mac = $acc['mac'];
$polled_period = $polled - $acc['poll_time'];
if($cip_array[$ifIndex][$mac]) {
if ($cip_array[$ifIndex][$mac])
{
$update .= "`poll_time` = '".$polled."'";
$update .= ", `poll_prev` = '".$acc['poll_time']."'";
$update .= ", `poll_period` = '".$polled_period."'";
@@ -39,13 +40,16 @@ while ($acc = mysql_fetch_assoc($mac_accounting_query)) {
$this_ma = &$cip_array[$ifIndex][$mac];
/// Update metrics
foreach ($cip_oids as $oid) {
foreach(array('input','output') as $dir) {
foreach ($cip_oids as $oid)
{
foreach (array('input','output') as $dir)
{
$oid_dir = $oid . "_" . $dir;
$update .= ", `".$oid_dir."` = '".$this_ma[$oid][$dir]."'";
$update .= ", `".$oid_dir."_prev` = '".$acc[$oid_dir]."'";
$oid_prev = $oid_dir . "_prev";
if($this_ma[$oid][$dir]) {
if ($this_ma[$oid][$dir])
{
$oid_diff = $this_ma[$oid][$dir] - $acc[$oid_dir];
$oid_rate = $oid_diff / $polled_period;
$update .= ", `".$oid_dir."_rate` = '".$oid_rate."'";
@@ -82,8 +86,8 @@ while ($acc = mysql_fetch_assoc($mac_accounting_query)) {
@mysql_query($update_query);
if ($debug) { echo("\nMYSQL : [ $update_query ]"); }
} /// End Updates
unset($update_query); unset($update);
unset($update_query); unset($update);
}
}
-54
View File
@@ -1,54 +0,0 @@
<?php
echo("CISCO-MEMORY-POOL: ");
$query = "SELECT * FROM cmpMemPool WHERE device_id = '" . $device['device_id'] . "'";
$pool_data = mysql_query($query);
while($mempool = mysql_fetch_array($pool_data)) {
echo($mempool['cmpName'] . " ");
$oid = $mempool['Index'];
$pool_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m CISCO-MEMORY-POOL-MIB -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$pool_cmd .= " ciscoMemoryPoolUsed.$oid ciscoMemoryPoolFree.$oid ciscoMemoryPoolLargestFree.$oid";
$pool_cmd .= " | cut -f 1 -d ' '";
$pool = shell_exec($pool_cmd);
list($cmpUsed, $cmpFree, $cmpLargestFree) = explode("\n", $pool);
echo(round(($cmpUsed/($cmpFree+$cmpUsed))*100) . "% ");
$poolrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("cmp-" . $mempool['Index'] . ".rrd");
if (!is_file($poolrrd)) {
shell_exec ($config['rrdtool'] . " create $poolrrd \
--step 300 \
DS:used:GAUGE:600:0:U \
DS:free:GAUGE:600:-1:U \
DS:largestfree:GAUGE:600:0:U \
RRA:AVERAGE:0.5:1:2000 \
RRA:AVERAGE:0.5:6:2000 \
RRA:AVERAGE:0.5:24:2000 \
RRA:AVERAGE:0.5:288:2000 \
RRA:MAX:0.5:1:2000 \
RRA:MAX:0.5:6:2000 \
RRA:MAX:0.5:24:2000 \
RRA:MAX:0.5:288:2000");
}
$pool = trim(str_replace("\"", "", $pool));
list($pool) = split(" ", $pool);
$updatecmd = $config['rrdtool'] ." update $poolrrd N:$cmpUsed:$cmpFree:$cmpLargestFree";
shell_exec($updatecmd);
$update_query = "UPDATE `cmpMemPool` SET cmpUsed='$cmpUsed', cmpFree='$cmpFree', cmpLargestFree='$cmpLargestFree' WHERE `cmp_id` = '".$mempool['cmp_id']."'";
mysql_query($update_query);
}
echo("\n");
?>
-36
View File
@@ -1,36 +0,0 @@
<?php
$query = "SELECT * FROM cpmCPU WHERE device_id = '" . $device['device_id'] . "'";
$proc_data = mysql_query($query);
while($processor = mysql_fetch_array($proc_data)) {
$proc_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m CISCO-PROCESS-MIB -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " cpmCPUTotal5minRev." . $processor['cpmCPU_oid'];
$proc = shell_exec($proc_cmd);
echo("Checking CPU " . $processor['entPhysicalDescr'] . "... ");
$procrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("cpmCPU-" . $processor['cpmCPU_oid'] . ".rrd");
if (!is_file($procrrd)) {
`rrdtool create $procrrd \
--step 300 \
DS:usage:GAUGE:600:-273:1000 \
RRA:AVERAGE:0.5:1:1200 \
RRA:MIN:0.5:12:2400 \
RRA:MAX:0.5:12:2400 \
RRA:AVERAGE:0.5:12:2400`;
}
$proc = trim(str_replace("\"", "", $proc));
list($proc) = split(" ", $proc);
echo($proc . "%\n");
$updatecmd = $config['rrdtool'] ." update $procrrd N:$proc";
shell_exec($updatecmd);
mysql_query("UPDATE `cpmCPU` SET `cpmCPUTotal5minRev` = '$proc' WHERE `cpmCPU_id` = '".$processor['cpmCPU_id']."'");
}
?>
@@ -31,8 +31,8 @@
#CISCO-REMOTE-ACCESS-MONITOR-MIB::crasWebvpnCumulateSessions.0 = Counter32: 29 Sessions
#CISCO-REMOTE-ACCESS-MONITOR-MIB::crasWebvpnPeakConcurrentSessions.0 = Gauge32: 9 Sessions
if($device['os_group'] == "ios") {
if ($device['os_group'] == "ios")
{
$oid_list = "crasEmailNumSessions.0 crasIPSecNumSessions.0 crasL2LNumSessions.0 crasLBNumSessions.0 crasSVCNumSessions.0 crasWebvpnNumSessions.0";
$data = snmp_get_multi($device, $oid_list, "-OUQs", "CISCO-REMOTE-ACCESS-MONITOR-MIB");
$data = $data[0];
@@ -80,8 +80,8 @@ if($device['os_group'] == "ios") {
$graphs['cras_sessions'] = TRUE;
echo(" CRAS Sessions");
}
unset($data, $$rrd_filename, $rrd_create, $rrd_update);
}
+6 -6
View File
@@ -2,8 +2,8 @@
$query = "SELECT * FROM sensors WHERE sensor_class='current' AND device_id = '" . $device['device_id'] . "' AND poller_type='snmp'";
$current_data = mysql_query($query);
while($dbcurrent = mysql_fetch_array($current_data)) {
while ($dbcurrent = mysql_fetch_array($current_data))
{
echo("Checking current " . $dbcurrent['sensor_descr'] . "... ");
$current = snmp_get($device, $dbcurrent['sensor_oid'], "-OUqnv", "SNMPv2-MIB");
@@ -13,14 +13,14 @@ while($dbcurrent = mysql_fetch_array($current_data)) {
$currentrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("current-" . $dbcurrent['sensor_descr'] . ".rrd");
if (!is_file($currentrrd)) {
`rrdtool create $currentrrd \
--step 300 \
if (!is_file($currentrrd))
{
rrdtool_create($currentrrd,"--step 300 \
DS:sensor:GAUGE:600:-273:1000 \
RRA:AVERAGE:0.5:1:1200 \
RRA:MIN:0.5:12:2400 \
RRA:MAX:0.5:12:2400 \
RRA:AVERAGE:0.5:12:2400`;
RRA:AVERAGE:0.5:12:2400");
}
echo($current . " A\n");
+2 -3
View File
@@ -19,13 +19,12 @@ while ($fanspeed = mysql_fetch_array($fan_data))
if (!is_file($rrd_file))
{
`rrdtool create $rrd_file \
--step 300 \
rrdtool_create($rrd_file,"--step 300 \
DS:sensor:GAUGE:600:0:20000 \
RRA:AVERAGE:0.5:1:1200 \
RRA:MIN:0.5:12:2400 \
RRA:MAX:0.5:12:2400 \
RRA:AVERAGE:0.5:12:2400`;
RRA:AVERAGE:0.5:12:2400");
}
echo($fan . " rpm\n");
+6 -5
View File
@@ -2,8 +2,9 @@
$query = "SELECT * FROM `sensors` WHERE device_id = '" . $device['device_id'] . "' AND `sensor_class` = 'freq' AND poller_type='snmp'";
$sensor_data = mysql_query($query);
while($sensor = mysql_fetch_array($sensor_data)) {
while ($sensor = mysql_fetch_array($sensor_data))
{
echo("Checking frequency " . $sensor['sensor_descr'] . "... ");
$freq = snmp_get($device, $sensor['sensor_oid'], "-OUqnv", "SNMPv2-MIB");
@@ -13,14 +14,14 @@ while($sensor = mysql_fetch_array($sensor_data)) {
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("frequency-" . $sensor['sensor_descr'] . ".rrd");
if (!is_file($rrd_file)) {
`rrdtool create $rrd_file \
--step 300 \
if (!is_file($rrd_file))
{
rrdtool_create($rrd_file,"--step 300 \
DS:sensor:GAUGE:600:-273:1000 \
RRA:AVERAGE:0.5:1:1200 \
RRA:MIN:0.5:12:2400 \
RRA:MAX:0.5:12:2400 \
RRA:AVERAGE:0.5:12:2400`;
RRA:AVERAGE:0.5:12:2400");
}
echo($freq . " Hz\n");
+6 -2
View File
@@ -11,7 +11,8 @@ echo("HR Stats:");
if (is_numeric($hrSystem[0]['hrSystemProcesses']))
{
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/hr_processes.rrd";
if (!is_file($rrd_file)) {
if (!is_file($rrd_file))
{
rrdtool_create($rrd_file,"--step 300 \
DS:procs:GAUGE:600:0:U \
RRA:AVERAGE:0.5:1:800 \
@@ -23,6 +24,7 @@ if(is_numeric($hrSystem[0]['hrSystemProcesses']))
RRA:MAX:0.5:24:800 \
RRA:MAX:0.5:288:800");
}
rrdtool_update($rrd_file, "N:".$hrSystem[0]['hrSystemProcesses']);
$graphs['hr_processes'] = TRUE;
echo(" Processes");
@@ -31,7 +33,8 @@ if(is_numeric($hrSystem[0]['hrSystemProcesses']))
if (is_numeric($hrSystem[0]['hrSystemNumUsers']))
{
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/hr_users.rrd";
if (!is_file($rrd_file)) {
if (!is_file($rrd_file))
{
rrdtool_create($rrd_file, "--step 300 \
DS:users:GAUGE:600:0:U \
RRA:AVERAGE:0.5:1:800 \
@@ -43,6 +46,7 @@ if(is_numeric($hrSystem[0]['hrSystemNumUsers']))
RRA:MAX:0.5:24:800 \
RRA:MAX:0.5:288:800");
}
rrdtool_update($rrd_file, "N:".$hrSystem[0]['hrSystemNumUsers']);
$graphs['hr_users'] = TRUE;
echo(" Users");
+6 -6
View File
@@ -2,8 +2,8 @@
$query = "SELECT * FROM sensors WHERE sensor_class='humidity' AND device_id = '" . $device['device_id'] . "' AND poller_type='snmp'";
$hum_data = mysql_query($query);
while($humidity = mysql_fetch_array($hum_data)) {
while ($humidity = mysql_fetch_array($hum_data))
{
echo("Checking humidity " . $humidity['sensor_descr'] . "... ");
$hum = snmp_get($device, $humidity['sensor_oid'], "-OUqnv", "SNMPv2-MIB");
@@ -13,14 +13,14 @@ while($humidity = mysql_fetch_array($hum_data)) {
$humrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("humidity-" . $humidity['sensor_descr'] . ".rrd");
if (!is_file($humrrd)) {
`rrdtool create $humrrd \
--step 300 \
if (!is_file($humrrd))
{
rrdtool_create($humrrd,"--step 300 \
DS:sensor:GAUGE:600:-273:1000 \
RRA:AVERAGE:0.5:1:1200 \
RRA:MIN:0.5:12:2400 \
RRA:MAX:0.5:12:2400 \
RRA:AVERAGE:0.5:12:2400`;
RRA:AVERAGE:0.5:12:2400");
}
echo($hum . " %\n");
+8 -7
View File
@@ -51,10 +51,10 @@
$ipSystemStats = snmpwalk_cache_oid($device, "ipSystemStats", NULL, "IP-MIB");
if($ipSystemStats) {
foreach($ipSystemStats as $af => $stats) {
if ($ipSystemStats)
{
foreach ($ipSystemStats as $af => $stats)
{
echo("$af ");
$oids = array('ipSystemStatsInReceives','ipSystemStatsInHdrErrors','ipSystemStatsInAddrErrors','ipSystemStatsInUnknownProtos','ipSystemStatsInForwDatagrams','ipSystemStatsReasmReqds',
@@ -73,18 +73,20 @@
$rrdfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("ipSystemStats-".$af.".rrd");
$rrd_create = "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797";
$rrdupdate = "N";
foreach($oids as $oid){
foreach ($oids as $oid)
{
$oid_ds = str_replace("ipSystemStats", "", $oid);
$oid_ds = truncate($oid_ds, 19, '');
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:100000000000";
if (strstr($stats[$oid], "No") || strstr($stats[$oid], "d") || strstr($stats[$oid], "s")) { $stats[$oid] = "0"; }
$rrdupdate .= ":".$stats[$oid];
}
if (!file_exists($rrdfile)) { rrdtool_create($rrdfile,$rrd_create); }
rrdtool_update($rrdfile, $rrdupdate);
unset($rrdupdate, $rrd_create);
## FIXME per-AF?
@@ -96,5 +98,4 @@
echo("\n");
?>
+2 -3
View File
@@ -30,8 +30,7 @@ if ($ipmi['host'] = get_dev_attrib($device,'ipmi_hostname'))
if (!is_file($sensorrrd))
{
`rrdtool create $sensorrrd \
--step 300 \
rrdtool_create($sensorrrd,"--step 300 \
DS:sensor:GAUGE:600:-20000:20000 \
RRA:AVERAGE:0.5:1:600 \
RRA:AVERAGE:0.5:6:700 \
@@ -44,7 +43,7 @@ if ($ipmi['host'] = get_dev_attrib($device,'ipmi_hostname'))
RRA:MIN:0.5:1:600 \
RRA:MIN:0.5:6:700 \
RRA:MIN:0.5:24:775 \
RRA:MIN:0.5:288:797`;
RRA:MIN:0.5:288:797");
}
echo($sensor . " $unit\n");
+6 -9
View File
@@ -3,9 +3,8 @@
$sql = "SELECT * FROM `ports` AS P, `juniAtmVp` AS J WHERE P.`device_id` = '".$device['device_id']."' AND J.interface_id = P.interface_id";
$vp_data = mysql_query($sql);
if(mysql_affected_rows()) {
if (mysql_affected_rows())
{
$vp_cache = array();
$vp_cache = snmpwalk_cache_multi_oid($device, "juniAtmVpStatsInCells", $vp_cache, "Juniper-UNI-ATM-MIB" , $config['install_dir']."/mibs/junose");
$vp_cache = snmpwalk_cache_multi_oid($device, "juniAtmVpStatsInPackets", $vp_cache, "Juniper-UNI-ATM-MIB" , $config['install_dir']."/mibs/junose");
@@ -18,8 +17,8 @@ if(mysql_affected_rows()) {
echo("Checking JunOSe ATM vps: ");
while($vp=mysql_fetch_array($vp_data)) {
while ($vp=mysql_fetch_array($vp_data))
{
echo(".");
$oid = $vp['ifIndex'].".".$vp['vp_id'];
@@ -37,8 +36,8 @@ if(mysql_affected_rows()) {
if ($debug) { echo("$rrd "); }
if (!is_file($rrd)) {
if (!is_file($rrd))
{
rrdtool_create ($rrd, "--step 300 \
DS:incells:DERIVE:600:0:125000000000 \
DS:outcells:DERIVE:600:0:125000000000 \
@@ -63,13 +62,11 @@ if(mysql_affected_rows()) {
}
rrdtool_update($rrd,"N:$vp_update");
}
echo("\n");
unset($vp_cache);
}
?>
+6 -7
View File
@@ -1,15 +1,15 @@
<?php
$query = "SELECT * FROM mempools WHERE device_id = '" . $device['device_id'] . "'";
$mempool_data = mysql_query($query);
while($mempool = mysql_fetch_array($mempool_data)) {
while ($mempool = mysql_fetch_array($mempool_data))
{
echo("Mempool ". $mempool['mempool_descr'] . ": ");
$mempoolrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("mempool-" . $mempool['mempool_type'] . "-" . $mempool['mempool_index'] . ".rrd");
if (!is_file($mempoolrrd)) {
if (!is_file($mempoolrrd))
{
rrdtool_create($mempoolrrd, "--step 300 \
DS:used:GAUGE:600:-273:100000000000 \
DS:free:GAUGE:600:-273:100000000000 \
@@ -28,7 +28,8 @@ while($mempool = mysql_fetch_array($mempool_data)) {
}
$file = $config['install_dir']."/includes/polling/mempools/".$mempool['mempool_type'].".inc.php";
if(is_file($file)) {
if (is_file($file))
{
include($file);
} else {
### Do we need a generic mempool poller?
@@ -58,10 +59,8 @@ while($mempool = mysql_fetch_array($mempool_data)) {
if ($debug) { echo($update_query); }
echo("\n");
}
unset($mempool_cache);
?>
+11 -6
View File
@@ -1,7 +1,7 @@
<?php
if($device[os] != "Snom") {
if ($device['os'] != "Snom")
{
echo(" ICMP");
#### Below have more oids, and are in trees by themselves, so we can snmpwalk_cache_oid them
@@ -18,7 +18,8 @@ if($device[os] != "Snom") {
$rrd_create = "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 \
RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797";
foreach($oids as $oid){
foreach ($oids as $oid)
{
$oid_ds = truncate($oid, 19, '');
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:100000000000";
$snmpstring .= " $oid.0";
@@ -28,8 +29,10 @@ if($device[os] != "Snom") {
$rrdupdate = "N";
foreach($oids as $oid){
if(is_numeric($data_array[0][$oid])) {
foreach ($oids as $oid)
{
if (is_numeric($data_array[0][$oid]))
{
$value = $data_array[0][$oid];
} else {
$value = "0";
@@ -39,12 +42,14 @@ if($device[os] != "Snom") {
unset($snmpstring);
if(isset($data_array[0]['icmpInMsgs']) && isset($data_array[0]['icmpOutMsgs'])) {
if (isset($data_array[0]['icmpInMsgs']) && isset($data_array[0]['icmpOutMsgs']))
{
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
rrdtool_update($rrd_file, $rrdupdate);
$graphs['netstat_icmp'] = TRUE;
$graphs['netstat_icmp_info'] = TRUE;
}
unset($oids, $data, $data_array, $oid, $protos);
}
+9 -7
View File
@@ -1,7 +1,7 @@
<?php
if($device[os] != "Snom") {
if ($device['os'] != "Snom")
{
echo(" IP");
#### These are at the start of large trees that we don't want to walk the entirety of, so we snmp_get_multi them
@@ -16,7 +16,8 @@ if($device[os] != "Snom") {
$rrd_create = "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 \
RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797";
foreach($oids as $oid){
foreach ($oids as $oid)
{
$oid_ds = truncate($oid, 19, '');
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:100000000000";
$snmpstring .= " $oid.0";
@@ -26,7 +27,8 @@ if($device[os] != "Snom") {
$rrdupdate = "N";
foreach($oids as $oid){
foreach ($oids as $oid)
{
if (is_numeric($data[0][$oid]))
{
$value = $data[0][$oid];
@@ -36,16 +38,16 @@ if($device[os] != "Snom") {
$rrdupdate .= ":$value";
}
if(isset($data[0]['ipOutRequests']) && isset($data[0]['ipInReceives'])) {
if (isset($data[0]['ipOutRequests']) && isset($data[0]['ipInReceives']))
{
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
rrdtool_update($rrd_file, $rrdupdate);
$graphs['netstat_ip'] = TRUE;
$graphs['netstat_ip_frag'] = TRUE;
}
}
unset($oids, $data, $data_array, $oid);
?>
+10 -6
View File
@@ -1,7 +1,7 @@
<?php
if($device[os] != "Snom") {
if ($device['os'] != "Snom")
{
echo(" SNMP");
#### Below have more oids, and are in trees by themselves, so we can snmpwalk_cache_oid them
@@ -17,7 +17,8 @@ if($device[os] != "Snom") {
$rrd_create = "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 \
RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797";
foreach($oids as $oid){
foreach ($oids as $oid)
{
$oid_ds = truncate($oid, 19, '');
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:100000000000";
}
@@ -26,8 +27,10 @@ if($device[os] != "Snom") {
$rrdupdate = "N";
foreach($oids as $oid){
if(is_numeric($data_array[0][$oid])) {
foreach ($oids as $oid)
{
if (is_numeric($data_array[0][$oid]))
{
$value = $data_array[0][$oid];
} else {
$value = "0";
@@ -35,7 +38,8 @@ if($device[os] != "Snom") {
$rrdupdate .= ":$value";
}
if(isset($data_array[0]['snmpInPkts']) && isset($data_array[0]['snmpOutPkts'])) {
if (isset($data_array[0]['snmpInPkts']) && isset($data_array[0]['snmpOutPkts']))
{
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
rrdtool_update($rrd_file, $rrdupdate);
$graphs['netstat_snmp'] = TRUE;
+8 -5
View File
@@ -1,7 +1,7 @@
<?php
if($device[os] != "Snom") {
if ($device['os'] != "Snom")
{
echo(" TCP");
$oids = array ('tcpActiveOpens', 'tcpPassiveOpens', 'tcpAttemptFails', 'tcpEstabResets', 'tcpCurrEstab',
@@ -17,7 +17,8 @@ if($device[os] != "Snom") {
$rrd_create = "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 \
RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797";
foreach($oids as $oid){
foreach ($oids as $oid)
{
$oid_ds = truncate($oid, 19, '');
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:10000000"; ## Limit to 10MPPS
$snmpstring .= " $oid.0";
@@ -30,7 +31,8 @@ if($device[os] != "Snom") {
$rrdupdate = "N";
foreach($oids as $oid){
foreach ($oids as $oid)
{
if (is_numeric($data[0][$oid]))
{
$value = $data[0][$oid];
@@ -42,7 +44,8 @@ if($device[os] != "Snom") {
unset($snmpstring);
if(isset($data[0]['tcpInSegs']) && isset($data[0]['tcpOutSegs'])) {
if (isset($data[0]['tcpInSegs']) && isset($data[0]['tcpOutSegs']))
{
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
rrdtool_update($rrd_file, $rrdupdate);
$graphs['netstat_tcp'] = TRUE;
+9 -4
View File
@@ -1,6 +1,7 @@
<?php
if($device[os] != "Snom") {
if ($device['os'] != "Snom")
{
echo(" UDP");
@@ -14,7 +15,8 @@ if($device[os] != "Snom") {
$rrd_create = "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 \
RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797";
foreach($oids as $oid){
foreach ($oids as $oid)
{
$oid_ds = truncate($oid, 19, '');
$rrd_create .= " DS:$oid_ds:COUNTER:600:U:1000000"; ## Limit to 1MPPS?
$snmpstring .= " $oid.0";
@@ -24,7 +26,8 @@ if($device[os] != "Snom") {
$rrdupdate = "N";
foreach($oids as $oid){
foreach ($oids as $oid)
{
if (is_numeric($data[0][$oid]))
{
$value = $data[0][$oid];
@@ -34,12 +37,14 @@ if($device[os] != "Snom") {
$rrdupdate .= ":$value";
}
if(isset($data[0]['udpInDatagrams']) && isset($data[0]['udpOutDatagrams'])) {
if (isset($data[0]['udpInDatagrams']) && isset($data[0]['udpOutDatagrams']))
{
if (!file_exists($rrd_file)) { rrdtool_create($rrd_file, $rrd_create); }
rrdtool_update($rrd_file, $rrdupdate);
$graphs['netstat_udp'] = TRUE;
}
}
unset($oids, $data, $data_array, $oid, $protos, $snmpstring);
?>
+14 -7
View File
@@ -40,7 +40,8 @@
# adslAturPerfValidIntervals.1 = 0
# adslAturPerfInvalidIntervals.1 = 0
if(isset($port_stats[$port['ifIndex']]['adslLineCoding'])) { // Check to make sure Port data is cached.
if (isset($port_stats[$port['ifIndex']]['adslLineCoding']))
{ // Check to make sure Port data is cached.
$this_port = &$port_stats[$port['ifIndex']];
@@ -82,13 +83,19 @@
$adsl_tenth_oids = array('adslAtucCurrSnrMgn','adslAtucCurrAtn','adslAtucCurrOutputPwr','adslAturCurrSnrMgn', 'adslAturCurrAtn', 'adslAturCurrOutputPwr');
foreach($adsl_tenth_oids as $oid) {
foreach ($adsl_tenth_oids as $oid)
{
$this_port[$oid] = $this_port[$oid] / 10;
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `ports_adsl` WHERE `interface_id` = '".$port['interface_id']."'"),0) == "0") { mysql_query("INSERT INTO `ports_adsl` (`interface_id`) VALUES ('".$port['interface_id']."')"); }
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ports_adsl` WHERE `interface_id` = '".$port['interface_id']."'"),0) == "0")
{
mysql_query("INSERT INTO `ports_adsl` (`interface_id`) VALUES ('".$port['interface_id']."')");
}
$mysql_update = "UPDATE `ports_adsl` SET `port_adsl_updated` = NOW()";
foreach($adsl_db_oids as $oid) {
foreach ($adsl_db_oids as $oid)
{
$data = str_replace("\"", "", $this_port[$oid]);
$mysql_update .= ",`".$oid."` = '".$data."'";
}
@@ -97,9 +104,9 @@
if ($debug) { echo($mysql_update); echo(mysql_affected_rows()); echo(mysql_error()); }
$rrdupdate = "N";
foreach($adsl_oids as $oid) {
foreach ($adsl_oids as $oid)
{
$oid = "adsl".$oid;
$data = str_replace("\"", "", $this_port[$oid]);
## Set data to be "unknown" if it's garbled, unexistant or zero
@@ -111,6 +118,6 @@
rrdtool_update ($rrdfile, $rrdupdate);
echo("ADSL ");
}
?>
+15 -10
View File
@@ -1,38 +1,43 @@
<?php
if ($port_stats[$port['ifIndex']] && $port['ifType'] == "ethernetCsmacd"
&& isset($port_stats[$port['ifIndex']]['dot3StatsIndex'])) { // Check to make sure Port data is cached.
&& isset($port_stats[$port['ifIndex']]['dot3StatsIndex']))
{ // Check to make sure Port data is cached.
$this_port = &$port_stats[$port[ifIndex]];
$old_rrdfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("etherlike-".$port['ifIndex'].".rrd");
$rrdfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("port-".$port['ifIndex']."-dot3.rrd");
$rrd_create = $config['rrdtool'] . " create $rrdfile ";
$rrd_create .= "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 \
RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797";
if(!file_exists($rrdfile)) {
if(file_exists($old_rrdfile)) {
shell_exec('mv '.$old_rrdfile.' '.$rrd_file);
} else {
foreach($etherlike_oids as $oid){
if (!file_exists($rrdfile))
{
if (file_exists($old_rrdfile))
{
rename($old_rrdfile,$rrd_file);
}
else
{
foreach ($etherlike_oids as $oid)
{
$oid = truncate(str_replace("dot3Stats", "", $oid), 19, '');
$rrd_create .= " DS:$oid:COUNTER:600:U:100000000000";
}
shell_exec($rrd_create);
rrd_create($rrdfile, $rrd_create);
}
}
$rrdupdate = "N";
foreach($etherlike_oids as $oid) {
foreach ($etherlike_oids as $oid)
{
$data = $this_port[$oid] + 0;
$rrdupdate .= ":$data";
}
rrdtool_update($rrdfile, $rrdupdate);
echo("EtherLike ");
}
?>
+2 -2
View File
@@ -22,7 +22,6 @@ if($port_stats[$port['ifIndex']] && $port['ifType'] == "ethernetCsmacd"
if (!file_exists($rrdfile))
{
$rrd_create = $config['rrdtool'] . " create $rrdfile ";
$rrd_create .= "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 \
RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797";
@@ -32,7 +31,7 @@ if($port_stats[$port['ifIndex']] && $port['ifType'] == "ethernetCsmacd"
$rrd_create .= " DS:PortConsumption:DERIVE:600:0:U";
$rrd_create .= " DS:PortMaxPwrDrawn:GAUGE:600:0:U ";
shell_exec($rrd_create);*/
rrd_create($rrdfile, $rrd_create);
}
$upd = "$polled:".$port['cpeExtPsePortPwrAllocated'].":".$port['cpeExtPsePortPwrAvailable'].":".$port['cpeExtPsePortPwrConsumption'].":".$port['cpeExtPsePortMaxPwrDrawn'];
@@ -40,4 +39,5 @@ if($port_stats[$port['ifIndex']] && $port['ifType'] == "ethernetCsmacd"
echo("PoE ");
}
?>
+8 -4
View File
@@ -247,9 +247,12 @@
/// End Update IF-MIB
/// Update PAgP
if ($this_port['pagpOperationMode']) {
foreach ($pagp_oids as $oid) { // Loop the OIDs
if ( $this_port[$oid] != $port[$oid] ) { // If data has changed, build a query
if ($this_port['pagpOperationMode'])
{
foreach ($pagp_oids as $oid)
{ // Loop the OIDs
if ($this_port[$oid] != $port[$oid] )
{ // If data has changed, build a query
$update .= ", `$oid` = '".mres($this_port[$oid])."'";
echo("PAgP ");
log_event("$oid -> ".$this_port[$oid], $device['device_id'], 'interface', $port['interface_id']);
@@ -268,7 +271,8 @@
if ($config['enable_ports_poe']) { include("port-poe.inc.php"); }
// Update MySQL
if ($update) {
if ($update)
{
$update_query = "UPDATE `ports` SET ".$update." WHERE `interface_id` = '" . $port['interface_id'] . "'";
@mysql_query($update_query);
if ($debug) {echo("\nMYSQL : [ $update_query ]"); }
+6 -5
View File
@@ -2,12 +2,13 @@
$query = "SELECT * FROM processors WHERE device_id = '" . $device['device_id'] . "'";
$proc_data = mysql_query($query);
while($processor = mysql_fetch_array($proc_data)) {
while ($processor = mysql_fetch_array($proc_data))
{
echo("Processor " . $processor['processor_descr'] . "... ");
$file = $config['install_dir']."/includes/polling/processors-".$processor['processor_type'].".inc.php";
if(is_file($file)) {
if (is_file($file))
{
include($file);
} else {
$proc = snmp_get ($device, $processor['processor_oid'], "-O Uqnv");
@@ -15,7 +16,8 @@ while($processor = mysql_fetch_array($proc_data)) {
$procrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("processor-" . $processor['processor_type'] . "-" . $processor['processor_index'] . ".rrd");
if (!is_file($procrrd)) {
if (!is_file($procrrd))
{
rrdtool_create($procrrd, "--step 300 \
DS:usage:GAUGE:600:-273:1000 \
RRA:AVERAGE:0.5:1:1200 \
@@ -35,7 +37,6 @@ while($processor = mysql_fetch_array($proc_data)) {
rrdtool_update($procrrd,"N:$proc");
mysql_query("UPDATE `processors` SET `processor_usage` = '$proc' WHERE `processor_id` = '".$processor['processor_id']."'");
}
?>
+2 -1
View File
@@ -2,7 +2,8 @@
### HOST-RESOURCES-MIB - Storage Objects
if(!is_array($storage_cache['hrstorage'])) {
if (!is_array($storage_cache['hrstorage']))
{
$storage_cache['hrstorage'] = snmpwalk_cache_oid($device, "hrStorageEntry", NULL, "HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES");
if ($debug) { print_r($storage_cache); }
}
+6 -5
View File
@@ -6,13 +6,14 @@ $storage_cache = array();
$query = "SELECT * FROM storage WHERE device_id = '" . $device['device_id'] . "'";
$storage_data = mysql_query($query);
while($storage = mysql_fetch_array($storage_data)) {
while ($storage = mysql_fetch_array($storage_data))
{
echo("Storage ".$storage['storage_descr'] . ": ");
$storage_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("storage-" . $storage['storage_mib'] . "-" . safename($storage['storage_descr']) . ".rrd");
if (!is_file($storage_rrd)) {
if (!is_file($storage_rrd))
{
rrdtool_create($storage_rrd, "--step 300 \
DS:used:GAUGE:600:0:U \
DS:free:GAUGE:600:0:U \
@@ -31,7 +32,8 @@ while($storage = mysql_fetch_array($storage_data)) {
}
$file = $config['install_dir']."/includes/polling/storage-".$storage['storage_mib'].".inc.php";
if(is_file($file)) {
if (is_file($file))
{
include($file);
} else {
### Generic poller goes here if we ever have a discovery module which uses it.
@@ -60,7 +62,6 @@ while($storage = mysql_fetch_array($storage_data)) {
mysql_query($update_query);
echo("\n");
}
unset($storage);
+6 -6
View File
@@ -2,8 +2,8 @@
$query = "SELECT * FROM sensors WHERE sensor_class='temperature' AND device_id = '" . $device['device_id'] . "' AND poller_type='snmp'";
$temp_data = mysql_query($query);
while($temperature = mysql_fetch_array($temp_data)) {
while ($temperature = mysql_fetch_array($temp_data))
{
echo("Checking temp " . $temperature['sensor_descr'] . "... ");
for ($i = 0;$i < 5;$i++) # Try 5 times to get a valid temp reading
@@ -24,9 +24,9 @@ while($temperature = mysql_fetch_array($temp_data)) {
if (is_file($old_rrd_file)) { rename($old_rrd_file, $rrd_file); }
if (!is_file($rrd_file)) {
`rrdtool create $rrd_file \
--step 300 \
if (!is_file($rrd_file))
{
rrdtool_create($rrd_file,"--step 300 \
DS:sensor:GAUGE:600:-273:1000 \
RRA:AVERAGE:0.5:1:600 \
RRA:AVERAGE:0.5:6:700 \
@@ -39,7 +39,7 @@ while($temperature = mysql_fetch_array($temp_data)) {
RRA:MIN:0.5:1:600 \
RRA:MIN:0.5:6:700 \
RRA:MIN:0.5:24:775 \
RRA:MIN:0.5:288:797`;
RRA:MIN:0.5:288:797");
}
echo($temp . "C\n");
+2 -3
View File
@@ -18,13 +18,12 @@ if ($config['enable_printers'])
if (!is_file($tonerrrd))
{
`rrdtool create $tonerrrd \
--step 300 \
rrdtool_create($tonerrrd,"--step 300 \
DS:toner:GAUGE:600:0:20000 \
RRA:AVERAGE:0.5:1:1200 \
RRA:MIN:0.5:12:2400 \
RRA:MAX:0.5:12:2400 \
RRA:AVERAGE:0.5:12:2400`;
RRA:AVERAGE:0.5:12:2400");
}
echo($tonerperc . " %\n");
+6 -8
View File
@@ -4,16 +4,15 @@ $sql = "SELECT * FROM `ucd_diskio` WHERE `device_id` = '".$device['device_id'].
if ($debug) { echo("$sql"); }
$diskio_data = mysql_query($sql);
if(mysql_affected_rows()) {
if (mysql_affected_rows())
{
$diskio_cache = array();
$diskio_cache = snmpwalk_cache_oid($device, "diskIOEntry", $diskio_cache);
echo("Checking UCD DiskIO MIB: ");
while($diskio = mysql_fetch_array($diskio_data)) {
while ($diskio = mysql_fetch_array($diskio_data))
{
$index = $diskio['diskio_index'];
$entry = $diskio_cache[$index];
@@ -29,7 +28,8 @@ if(mysql_affected_rows()) {
if ($debug) { echo("$rrd "); }
if (!is_file($rrd)) {
if (!is_file($rrd))
{
rrdtool_create ($rrd, "--step 300 \
DS:read:DERIVE:600:0:125000000000 \
DS:written:DERIVE:600:0:125000000000 \
@@ -51,11 +51,9 @@ if(mysql_affected_rows()) {
rrdtool_update($rrd,"N:$rrd_update");
unset($rrd_update);
}
echo("\n");
}
unset($diskio_data);
+3 -2
View File
@@ -62,7 +62,6 @@
rrdtool_update($cpu_rrd, "N:".$ss['ssCpuRawUser'].":".$ss['ssCpuRawSystem'].":".$ss['ssCpuRawNice'].":".$ss['ssCpuRawIdle']);
}
### This is how we'll collect in the future, start now so people don't have zero data.
$collect_oids = array('ssCpuRawUser','ssCpuRawNice','ssCpuRawSystem','ssCpuRawIdle','ssCpuRawInterrupt', 'ssCpuRawSoftIRQ', 'ssCpuRawKernel', 'ssCpuRawWait', 'ssIORawSent', 'ssIORawReceived', 'ssRawInterrupts', 'ssRawContexts', 'ssRawSwapIn', 'ssRawSwapOut');
@@ -169,10 +168,12 @@
## Check to see that the OIDs are actually populated before we make the rrd
if (is_numeric($load1) && is_numeric($load5) && is_numeric($load10))
{
if (!is_file($load_rrd)) {
if (!is_file($load_rrd))
{
rrdtool_create($load_rrd, $la_load_create);
}
rrdtool_update($load_rrd, "N:$load1:$load5:$load10");
$graphs['ucd_load'] = "TRUE";
}
?>
+6 -5
View File
@@ -2,8 +2,9 @@
$query = "SELECT * FROM sensors WHERE sensor_class='voltage' AND device_id = '" . $device['device_id'] . "' AND poller_type='snmp'";
$volt_data = mysql_query($query);
while($sensor = mysql_fetch_array($volt_data)) {
while ($sensor = mysql_fetch_array($volt_data))
{
echo("Checking voltage " . $sensor['sensor_descr'] . "... ");
$volt = snmp_get($device, $sensor['sensor_oid'], "-OUqnv", "SNMPv2-MIB");
@@ -16,14 +17,14 @@ while($sensor = mysql_fetch_array($volt_data)) {
if (is_file($old_rrd_file)) { rename($old_rrd_file, $rrd_file); }
if (!is_file($rrd_file)) {
`rrdtool create $rrd_file \
--step 300 \
if (!is_file($rrd_file))
{
rrdtool_create($rrd_file,"--step 300 \
DS:sensor:GAUGE:600:-273:1000 \
RRA:AVERAGE:0.5:1:1200 \
RRA:MIN:0.5:12:2400 \
RRA:MAX:0.5:12:2400 \
RRA:AVERAGE:0.5:12:2400`;
RRA:AVERAGE:0.5:12:2400");
}
echo($volt . " V\n");
+8 -15
View File
@@ -4,11 +4,9 @@ echo("Wireless: ");
if ($device['type'] == 'network')
{
##### GENERIC FRAMEWORK, FILLING VARIABLES
if ($device['os'] == 'airport')
{
echo("Checking Airport Wireless clients... ");
$wificlients1 = snmp_get($device, "wirelessNumber.0", "-OUqnv", "AIRPORT-BASESTATION-3-MIB") +0;
@@ -20,7 +18,6 @@ if ($device['type'] == 'network')
if ($device['os'] == 'ios' and substr($device['hardware'],0,4) == 'AIR-')
{
echo("Checking Aironet Wireless clients... ");
$wificlients1 = snmp_get($device, "cDot11ActiveWirelessClients.1", "-OUqnv", "CISCO-DOT11-ASSOCIATION-MIB");
@@ -29,51 +26,47 @@ if ($device['type'] == 'network')
echo(($wificlients1 +0) . " clients on dot11Radio0, " . ($wificlients2 +0) . " clients on dot11Radio1\n");
}
##### RRD Filling Code
if (isset($wificlients1) && $wificlients1 != "")
{
$wificlientsrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("wificlients-radio1.rrd");
if (!is_file($wificlientsrrd)) {
`rrdtool create $wificlientsrrd \
--step 300 \
if (!is_file($wificlientsrrd))
{
rrdtool_create($wificlientsrrd,"--step 300 \
DS:wificlients:GAUGE:600:-273:1000 \
RRA:AVERAGE:0.5:1:1200 \
RRA:MIN:0.5:12:2400 \
RRA:MAX:0.5:12:2400 \
RRA:AVERAGE:0.5:12:2400`;
RRA:AVERAGE:0.5:12:2400");
}
rrdtool_update($wificlientsrrd,"N:".$wificlients1);
$graphs['wifi_clients'] = TRUE;
}
if (isset($wificlients2) && $wificlients2 != "")
{
$wificlientsrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("wificlients-radio2.rrd");
if (!is_file($wificlientsrrd)) {
`rrdtool create $wificlientsrrd \
--step 300 \
if (!is_file($wificlientsrrd))
{
rrdtool_create($wificlientsrrd,"--step 300 \
DS:wificlients:GAUGE:600:-273:1000 \
RRA:AVERAGE:0.5:1:1200 \
RRA:MIN:0.5:12:2400 \
RRA:MAX:0.5:12:2400 \
RRA:AVERAGE:0.5:12:2400`;
RRA:AVERAGE:0.5:12:2400");
}
rrdtool_update($wificlientsrrd,"N:".$wificlients2);
$graphs['wifi_clients'] = TRUE;
}
unset($wificlients2, $wificlients1);
}
echo("\n");