updates additions

git-svn-id: http://www.observium.org/svn/observer/trunk@505 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2009-11-09 15:52:04 +00:00
parent f263850092
commit 1ab6f3cded
22 changed files with 268 additions and 1557 deletions

View File

@@ -62,6 +62,9 @@ while ($device = mysql_fetch_array($device_query)) {
## Discover Storage ## Discover Storage
include("includes/discovery/storage.php"); include("includes/discovery/storage.php");
## hr-device.inc.php
include("includes/discovery/hr-device.inc.php");
if($device['os'] == "Netscreen") { } if($device['os'] == "Netscreen") { }
if($device['os'] == "JunOS") { include("includes/discovery/bgp-peers.php"); } if($device['os'] == "JunOS") { include("includes/discovery/bgp-peers.php"); }

View File

@@ -43,7 +43,7 @@ if($row['username'] && $row['username'] == $_SESSION['username']) {
setcookie("username", $_SESSION['username'], time()+60*60*24*100, "/"); setcookie("username", $_SESSION['username'], time()+60*60*24*100, "/");
setcookie("password", $_SESSION['password'], time()+60*60*24*100, "/"); setcookie("password", $_SESSION['password'], time()+60*60*24*100, "/");
} }
} else { } elseif ($_SESSION['username']) {
$auth_message = "Authentication Failed"; $auth_message = "Authentication Failed";
unset ($_SESSION['authenticated']); unset ($_SESSION['authenticated']);
mysql_query("INSERT INTO authlog (`user`,`address`,`result`) VALUES ('".$_SESSION['username']."', '".$_SERVER["REMOTE_ADDR"]."', 'authentication failure')"); mysql_query("INSERT INTO authlog (`user`,`address`,`result`) VALUES ('".$_SESSION['username']."', '".$_SERVER["REMOTE_ADDR"]."', 'authentication failure')");

View File

@@ -1,9 +1,41 @@
<?php <?php
include("common.inc.php"); $query = mysql_query("SELECT * FROM `hrDevice` where `device_id` = '".mres($device_id)."' AND hrDeviceType = 'hrDeviceProcessor'");
$rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/" . "cpu.rrd"; $i=0;
while($proc = mysql_fetch_array($query)) {
$rrd_filename = $config['rrd_dir'] . "/$hostname/hrProcessor-" . $proc['hrDeviceIndex'] . ".rrd";
if(is_file($rrd_filename)) {
$descr = str_pad($proc['hrDeviceDescr'], 8);
$descr = substr($descr,0,8);
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = $descr;
$rrd_list[$i]['rra'] = "usage";
$i++;
}
}
$unit_text = "Load %";
$units='%';
$total_units='%';
$colours='mixed';
$scale_min = "0";
$scale_max = "100";
$nototal = 1;
include ("generic_multi_line.inc.php");
if ($not) {
include("common.inc.php");
$rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/" . "ucd_cpu.rrd";
$rrd_options .= " DEF:user=$rrd_filename:user:AVERAGE"; $rrd_options .= " DEF:user=$rrd_filename:user:AVERAGE";
$rrd_options .= " DEF:nice=$rrd_filename:nice:AVERAGE"; $rrd_options .= " DEF:nice=$rrd_filename:nice:AVERAGE";
$rrd_options .= " DEF:system=$rrd_filename:system:AVERAGE"; $rrd_options .= " DEF:system=$rrd_filename:system:AVERAGE";
@@ -31,4 +63,6 @@ include("common.inc.php");
$rrd_options .= " GPRINT:idle_perc:AVERAGE:\ \ \ %5.2lf%%"; $rrd_options .= " GPRINT:idle_perc:AVERAGE:\ \ \ %5.2lf%%";
$rrd_options .= " GPRINT:idle_perc:MAX:\ \ \ %5.2lf%%\\\\n"; $rrd_options .= " GPRINT:idle_perc:MAX:\ \ \ %5.2lf%%\\\\n";
}
?> ?>

View File

@@ -1,9 +1,41 @@
<?php <?php
include("common.inc.php"); $query = mysql_query("SELECT * FROM `hrDevice` where `device_id` = '".mres($device_id)."' AND hrDeviceType = 'hrDeviceProcessor'");
$rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/" . "cpu.rrd"; $i=0;
while($proc = mysql_fetch_array($query)) {
$rrd_filename = $config['rrd_dir'] . "/$hostname/hrProcessor-" . $proc['hrDeviceIndex'] . ".rrd";
if(is_file($rrd_filename)) {
$descr = str_pad($proc['hrDeviceDescr'], 8);
$descr = substr($descr,0,8);
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = $descr;
$rrd_list[$i]['rra'] = "usage";
$i++;
}
}
$unit_text = "Load %";
$units='%';
$total_units='%';
$colours='mixed';
$scale_min = "0";
$scale_max = "100";
$nototal = 1;
include ("generic_multi_line.inc.php");
if ($not) {
include("common.inc.php");
$rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/" . "ucd_cpu.rrd";
$rrd_options .= " DEF:user=$rrd_filename:user:AVERAGE"; $rrd_options .= " DEF:user=$rrd_filename:user:AVERAGE";
$rrd_options .= " DEF:nice=$rrd_filename:nice:AVERAGE"; $rrd_options .= " DEF:nice=$rrd_filename:nice:AVERAGE";
$rrd_options .= " DEF:system=$rrd_filename:system:AVERAGE"; $rrd_options .= " DEF:system=$rrd_filename:system:AVERAGE";
@@ -31,4 +63,6 @@ include("common.inc.php");
$rrd_options .= " GPRINT:idle_perc:AVERAGE:\ \ \ %5.2lf%%"; $rrd_options .= " GPRINT:idle_perc:AVERAGE:\ \ \ %5.2lf%%";
$rrd_options .= " GPRINT:idle_perc:MAX:\ \ \ %5.2lf%%\\\\n"; $rrd_options .= " GPRINT:idle_perc:MAX:\ \ \ %5.2lf%%\\\\n";
}
?> ?>

View File

@@ -12,10 +12,8 @@ include("common.inc.php");
if($iter=="1") {$colour="CC0000";} elseif($iter=="2") {$colour="008C00";} elseif($iter=="3") {$colour="4096EE"; if($iter=="1") {$colour="CC0000";} elseif($iter=="2") {$colour="008C00";} elseif($iter=="3") {$colour="4096EE";
} elseif($iter=="4") {$colour="73880A";} elseif($iter=="5") {$colour="D01F3C";} elseif($iter=="6") {$colour="36393D"; } elseif($iter=="4") {$colour="73880A";} elseif($iter=="5") {$colour="D01F3C";} elseif($iter=="6") {$colour="36393D";
} elseif($iter=="7") {$colour="FF0084"; $iter = "0"; } } elseif($iter=="7") {$colour="FF0084"; $iter = "0"; }
$descr = str_pad($fs[hrStorageDescr], 14); $descr = str_pad($fs[hrStorageDescr], 14);
$descr = substr($descr,0,14); $descr = substr($descr,0,14);
$text = str_replace("/", "_", $fs['hrStorageDescr']);
$rrd = $config['rrd_dir'] . "/$hostname/hrStorage-".$fs['hrStorageIndex'].".rrd"; $rrd = $config['rrd_dir'] . "/$hostname/hrStorage-".$fs['hrStorageIndex'].".rrd";
$rrd_options .= " DEF:$fs[storage_id]=$rrd:used:AVERAGE"; $rrd_options .= " DEF:$fs[storage_id]=$rrd:used:AVERAGE";
$rrd_options .= " DEF:$fs[storage_id]s=$rrd:size:AVERAGE"; $rrd_options .= " DEF:$fs[storage_id]s=$rrd:size:AVERAGE";

View File

@@ -2,7 +2,7 @@
include("common.inc.php"); include("common.inc.php");
$rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/load.rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/ucd_load.rrd";
$rrd_options .= " DEF:1min=$rrd_filename:1min:AVERAGE"; $rrd_options .= " DEF:1min=$rrd_filename:1min:AVERAGE";
$rrd_options .= " DEF:5min=$rrd_filename:5min:AVERAGE"; $rrd_options .= " DEF:5min=$rrd_filename:5min:AVERAGE";

View File

@@ -2,7 +2,7 @@
include("common.inc.php"); include("common.inc.php");
$rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/mem.rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/ucd_mem.rrd";
$rrd_options .= " -b 1024"; $rrd_options .= " -b 1024";

View File

@@ -0,0 +1,28 @@
<?php
$scale_min = "0";
$scale_max = "100";
include("common.inc.php");
$iter = "1";
$sql = mysql_query("SELECT * FROM `hrDevice` AS C, `devices` AS D where C.`hrDevice_id` = '".mres($_GET['id'])."' AND C.device_id = D.device_id");
$rrd_options .= " COMMENT:' Cur Max\\n'";
while($proc = mysql_fetch_array($sql)) {
if($iter=="1") {$colour="CC0000";} elseif($iter=="2") {$colour="008C00";} elseif($iter=="3") {$colour="4096EE";
} elseif($iter=="4") {$colour="73880A";} elseif($iter=="5") {$colour="D01F3C";} elseif($iter=="6") {$colour="36393D";
} elseif($iter=="7") {$colour="FF0084"; unset($iter); }
$proc['descr_fixed'] = str_pad($proc['hrDeviceDescr'], 28);
$proc['descr_fixed'] = substr($proc['descr_fixed'],0,28);
$proc['descr_fixed'] = str_replace(":", "\:", $proc['descr_fixed']);
$rrd = $config['rrd_dir'] . "/".$proc['hostname']."/hrProcessor-" . $proc['hrDeviceIndex'] . ".rrd";
$rrd_options .= " DEF:proc" . $proc['hrDeviceIndex'] . "=$rrd:usage:AVERAGE ";
$rrd_options .= " LINE1:proc" . $proc['hrDeviceIndex'] . "#" . $colour . ":'" . $proc['descr_fixed'] . "' ";
$rrd_options .= " GPRINT:proc" . $proc['hrDeviceIndex'] . ":LAST:%3.0lf";
$rrd_options .= " GPRINT:proc" . $proc['hrDeviceIndex'] . ":MAX:%3.0lf\\\l ";
$iter++;
}
?>

View File

@@ -14,9 +14,8 @@ $rrd_options .= " -b 1024";
if($iter=="1") {$colour="CC0000";} elseif($iter=="2") {$colour="008C00";} elseif($iter=="3") {$colour="4096EE"; if($iter=="1") {$colour="CC0000";} elseif($iter=="2") {$colour="008C00";} elseif($iter=="3") {$colour="4096EE";
} elseif($iter=="4") {$colour="73880A";} elseif($iter=="5") {$colour="D01F3C";} elseif($iter=="6") {$colour="36393D"; } elseif($iter=="4") {$colour="73880A";} elseif($iter=="5") {$colour="D01F3C";} elseif($iter=="6") {$colour="36393D";
} elseif($iter=="7") {$colour="FF0084"; $iter = "0"; } } elseif($iter=="7") {$colour="FF0084"; $iter = "0"; }
$descr = str_pad($fs[hrStorageDescr], 12); $descr = substr(str_pad($fs[hrStorageDescr], 12),0,12);
$descr = substr($descr,0,12); $descr = str_replace(":","\:",$descr);
$text = str_replace("/", "_", $fs['hrStorageDescr']);
$rrd = $config['rrd_dir'] . "/$hostname/hrStorage-".$fs['hrStorageIndex'].".rrd"; $rrd = $config['rrd_dir'] . "/$hostname/hrStorage-".$fs['hrStorageIndex'].".rrd";
$rrd_options .= " DEF:$fs[storage_id]=$rrd:used:AVERAGE"; $rrd_options .= " DEF:$fs[storage_id]=$rrd:used:AVERAGE";
$rrd_options .= " DEF:$fs[storage_id]s=$rrd:size:AVERAGE"; $rrd_options .= " DEF:$fs[storage_id]s=$rrd:size:AVERAGE";

View File

@@ -4,16 +4,22 @@ $temp = mysql_result(mysql_query("select count(*) from temperature WHERE temp_ho
$storage = mysql_result(mysql_query("select count(*) from storage WHERE host_id = '" . $device['device_id'] . "'"), 0); $storage = mysql_result(mysql_query("select count(*) from storage WHERE host_id = '" . $device['device_id'] . "'"), 0);
$cemp = mysql_result(mysql_query("select count(*) from cempMemPool WHERE device_id = '" . $device['device_id'] . "'"), 0); $cemp = mysql_result(mysql_query("select count(*) from cempMemPool WHERE device_id = '" . $device['device_id'] . "'"), 0);
$cpm = mysql_result(mysql_query("select count(*) from cpmCPU WHERE device_id = '" . $device['device_id'] . "'"), 0); $cpm = mysql_result(mysql_query("select count(*) from cpmCPU WHERE device_id = '" . $device['device_id'] . "'"), 0);
$hrprocessor = mysql_result(mysql_query("select count(*) from hrDevice WHERE device_id = '" . $device['device_id'] . "' AND `hrDeviceType` = 'hrDeviceProcessor'"), 0);
if($temp) { $datas[] = 'temp'; } if($temp) { $datas[] = 'temp'; }
if($storage) { $datas[] = 'storage'; } if($storage) { $datas[] = 'storage'; }
if($cemp) { $datas[] = 'cemp'; } if($cemp) { $datas[] = 'cemp'; }
if($cpm) { $datas[] = 'cpm'; } if($cpm) { $datas[] = 'cpm'; }
if($hrprocessor) { $datas[] = 'hrprocessors'; }
$type_text['temp'] = "Temperatures"; $type_text['temp'] = "Temperatures";
$type_text['cemp'] = "Memory Pools"; $type_text['cemp'] = "Memory Pools";
$type_text['cpm'] = "Processor Usage"; $type_text['cpm'] = "Processor Usage";
$type_text['storage'] = "Disk Usage"; $type_text['storage'] = "Disk Usage";
$type_text['hrprocessors'] = "Processor Usage";
echo("<div style='margin:auto; text-align: center; margin-top: 0px; margin-bottom: 10px;'> echo("<div style='margin:auto; text-align: center; margin-top: 0px; margin-bottom: 10px;'>
<b class='rounded'> <b class='rounded'>

View File

@@ -0,0 +1,52 @@
<?php
echo("<div style='margin-top: 5px; padding: 0px;'>");
echo("<table width=100% cellpadding=6 cellspacing=0>");
$i = '1';
$procs = mysql_query("SELECT * FROM `hrDevice` WHERE device_id = '" . $device['device_id'] . "' AND hrDeviceType = 'hrDeviceProcessor'");
while($proc = mysql_fetch_array($procs)) {
$proc_url = "?page=device/".$device['device_id']."/health/hrprocessors/";
$proc_popup = "onmouseover=\"return overlib('<div class=list-large>".$device['hostname']." - ".$proc['entPhysicalDescr'];
$proc_popup .= "</div><img src=\'graph.php?id=" . $proc['hrDevice_id'] . "&type=hrProcessor&from=$month&to=$now&width=400&height=125\'>";
$proc_popup .= "', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"";
if($proc['cpuCPMTotal5minRev'] > '60') { $proc_colour='#cc0000'; } else { $proc_colour='#0000cc'; }
echo("<tr><td class=tablehead width=350><a href='' $proc_popup>" . $proc['entPhysicalDescr'] . "</a></td>
<td><a href='#' $proc_popup><img src='percentage.php?per=" . $proc['hrProcessorTotal5minRev'] . "&width=600'></a></td>
<td style='font-weight: bold; color: $drv_colour'>" . $proc['hrProcessorTotal5minRev'] . "%</td>
</tr>");
echo("<tr bgcolor='$row_colour'><td colspan=5>");
$daily_graph = "graph.php?id=" . $proc['hrDevice_id'] . "&type=hrProcessor&from=$day&to=$now&width=211&height=100";
$daily_url = "graph.php?id=" . $proc['hrDevice_id'] . "&type=hrProcessor&from=$day&to=$now&width=400&height=150";
$weekly_graph = "graph.php?id=" . $proc['hrDevice_id'] . "&type=hrProcessor&from=$week&to=$now&width=211&height=100";
$weekly_url = "graph.php?id=" . $proc['hrDevice_id'] . "&type=hrProcessor&from=$week&to=$now&width=400&height=150";
$monthly_graph = "graph.php?id=" . $proc['hrDevice_id'] . "&type=hrProcessor&from=$month&to=$now&width=211&height=100";
$monthly_url = "graph.php?id=" . $proc['hrDevice_id'] . "&type=hrProcessor&from=$month&to=$now&width=400&height=150";
$yearly_graph = "graph.php?id=" . $proc['hrDevice_id'] . "&type=hrProcessor&from=$year&to=$now&width=211&height=100";
$yearly_url = "graph.php?id=" . $proc['hrDevice_id'] . "&type=hrProcessor&from=$year&to=$now&width=400&height=150";
echo("<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$daily_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$weekly_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$monthly_graph' border=0></a> ");
echo("<a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
<img src='$yearly_graph' border=0></a>");
echo("</td></tr>");
$i++;
}
echo("</table>");
echo("</div>");
?>

View File

@@ -0,0 +1,44 @@
<?php
echo("hrDevice : ");
$hrDevice_oids = array('hrDeviceIndex','hrDeviceType','hrDeviceDescr','hrDeviceStatus','hrDeviceErrors','hrProcessorLoad');
foreach ($hrDevice_oids as $oid) { echo("$oid "); $hrDevice_array = snmp_cache_oid($oid, $device, $hrDevice_array, "HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES"); }
foreach($hrDevice_array[$device[device_id]] as $hrDevice) {
if(is_array($hrDevice)) {
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `hrDevice` WHERE device_id = '".$device['device_id']."' AND hrDeviceIndex = '".$hrDevice['hrDeviceIndex']."'"),0)) {
$update_query = "UPDATE `hrDevice` SET";
$update_query .= " `hrDeviceType` = '".mres($hrDevice[hrDeviceType])."'";
$update_query .= ", `hrDeviceDescr` = '".mres($hrDevice[hrDeviceDescr])."'";
$update_query .= ", `hrDeviceStatus` = '".mres($hrDevice[hrDeviceStatus])."'";
$update_query .= ", `hrDeviceErrors` = '".mres($hrDevice[hrDeviceErrors])."'";
if($hrDevice['hrDeviceType'] == "hrDeviceProcessor") {
$update_query .= ", `hrProcessorLoad` = '".mres($hrDevice[hrProcessorLoad])."'";
}
$update_query .= " WHERE device_id = '".$device['device_id']."' AND hrDeviceIndex = '".$hrDevice['hrDeviceIndex']."'";
@mysql_query($update_query); $mysql++; echo(".");
} else {
$insert_query = "INSERT INTO `hrDevice` (`hrDeviceIndex`,`device_id`,`hrDeviceType`,`hrDeviceDescr`,`hrDeviceStatus`,`hrDeviceErrors`) ";
$insert_query .= " VALUES ('".mres($hrDevice[hrDeviceIndex])."','".mres($device[device_id])."','".mres($hrDevice[hrDeviceType])."','".mres($hrDevice[hrDeviceDescr])."','".mres($hrDevice[hrDeviceStatus])."','".mres($hrDevice[hrDeviceErrors])."')";
@mysql_query($insert_query); $mysql++; echo("+");
}
$valid_hrDevice[$hrDevice[hrDeviceIndex]] = 1;
}
}
$sql = "SELECT * FROM `hrDevice` WHERE `device_id` = '".$device['device_id']."'";
$query = mysql_query($sql);
while ($test_hrDevice = mysql_fetch_array($query)) {
if(!$valid_hrDevice[$test_hrDevice[hrDeviceIndex]]) {
echo("-");
mysql_query("DELETE FROM `hrDevice` WHERE hrDevice_id = '" . $test['hrDevice_id'] . "'");
}
}
unset($valid_hrDevice);
echo("\n");
?>

View File

@@ -2,19 +2,21 @@
unset( $storage_exists ); unset( $storage_exists );
echo("hrStorage : "); echo("HOST-RESOURCES-MIB Storage : ");
$oids = shell_exec($config['snmpwalk'] . " -m HOST-RESOURCES-MIB -Osq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " hrStorageIndex"); $oids = shell_exec($config['snmpwalk'] . " -CI -m HOST-RESOURCES-MIB -Osq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " hrStorageIndex");
$oids = trim(str_replace("hrStorageIndex.","",$oids)); $oids = trim(str_replace("hrStorageIndex.","",$oids));
echo(".. $oids .. ");
foreach(explode("\n", $oids) as $data) { foreach(explode("\n", $oids) as $data) {
if($data) {
$data = trim($data); $data = trim($data);
list($oid,$hrStorageIndex) = explode(" ", $data); list($oid,$hrStorageIndex) = explode(" ", $data);
$temp = shell_exec($config['snmpget'] . " -m HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " hrStorageDescr.$oid hrStorageAllocationUnits.$oid hrStorageSize.$oid hrStorageType.$oid"); $temp = shell_exec($config['snmpget'] . " -m HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " hrStorageDescr.$oid hrStorageAllocationUnits.$oid hrStorageSize.$oid hrStorageType.$oid");
$temp = trim($temp); $temp = trim($temp);
list($descr, $units, $size, $fstype) = explode("\n", $temp); list($descr, $units, $size, $fstype) = explode("\n", $temp);
list($units) = explode(" ", $units); list($units) = explode(" ", $units);
$allow = 1; $allow = 1;
foreach($config['ignore_mount'] as $bi) { foreach($config['ignore_mount'] as $bi) {
if($descr == $bi) { if($descr == $bi) {
@@ -39,6 +41,7 @@
} }
$storage_exists[] = $device[device_id]." $hrStorageIndex"; $storage_exists[] = $device[device_id]." $hrStorageIndex";
} else { echo("X"); }; } else { echo("X"); };
}
} }

View File

@@ -2,14 +2,14 @@
function snmp_cache_cip($oid, $device, $array, $mib = 0) { function snmp_cache_cip($oid, $device, $array, $mib = 0) {
global $config; global $config;
$cmd = $config['snmpbulkwalk'] . " -O snq -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " "; $cmd = $config['snmpbulkwalk'] . " -O snQ -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ";
if($mib) { $cmd .= "-m $mib "; } if($mib) { $cmd .= "-m $mib "; }
$cmd .= $oid; $cmd .= $oid;
$data = trim(shell_exec($cmd)); $data = trim(shell_exec($cmd));
$device_id = $device['device_id']; $device_id = $device['device_id'];
#echo("Caching: $oid\n"); #echo("Caching: $oid\n");
foreach(explode("\n", $data) as $entry) { foreach(explode("\n", $data) as $entry) {
list ($this_oid, $this_value) = split(" ", $entry); list ($this_oid, $this_value) = split("=", $entry);
$this_oid = trim($this_oid); $this_oid = trim($this_oid);
$this_value = trim($this_value); $this_value = trim($this_value);
$this_oid = substr($this_oid, 30); $this_oid = substr($this_oid, 30);

View File

@@ -20,7 +20,7 @@ if($device[os] != "Snom") {
'snmpOutBadValues','snmpOutGenErrs','snmpOutGetRequests','snmpOutGetNexts','snmpOutSetRequests','snmpOutGetResponses','snmpOutTraps', 'snmpOutBadValues','snmpOutGenErrs','snmpOutGetRequests','snmpOutGetNexts','snmpOutSetRequests','snmpOutGetResponses','snmpOutTraps',
'snmpEnableAuthenTraps','snmpSilentDrops','snmpProxyDrops'); 'snmpEnableAuthenTraps','snmpSilentDrops','snmpProxyDrops');
$oids['tcp'] = array ('tcpRtoMin', 'tcpRtoMax', 'tcpMaxConn', 'tcpActiveOpens', 'tcpPassiveOpens', 'tcpAttemptFails', 'tcpEstabResets', 'tcpCurrEstab', $oids['tcp'] = array ('tcpActiveOpens', 'tcpPassiveOpens', 'tcpAttemptFails', 'tcpEstabResets', 'tcpCurrEstab',
'tcpInSegs', 'tcpOutSegs', 'tcpRetransSegs', 'tcpInErrs', 'tcpOutRsts', 'tcpHCInSegs', 'tcpHCOutSegs'); 'tcpInSegs', 'tcpOutSegs', 'tcpRetransSegs', 'tcpInErrs', 'tcpOutRsts', 'tcpHCInSegs', 'tcpHCOutSegs');
$oids['udp'] = array ('udpInDatagrams','udpOutDatagrams','udpInErrors','udpNoPorts'); $oids['udp'] = array ('udpInDatagrams','udpOutDatagrams','udpInErrors','udpNoPorts');

View File

@@ -1,9 +1,5 @@
<?php <?php
$loadrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/load.rrd";
$cpurrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/cpu.rrd";
$memrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/mem.rrd";
if ($device['os'] == "FreeBSD") { if ($device['os'] == "FreeBSD") {
$sysDescr = str_replace(" 0 ", " ", $sysDescr); $sysDescr = str_replace(" 0 ", " ", $sysDescr);
list(,,$version) = explode (" ", $sysDescr); list(,,$version) = explode (" ", $sysDescr);
@@ -39,100 +35,5 @@ $memrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/mem.rrd";
if(strstr($hw, "No")) { unset($hw); } else { $hardware = "Dell " . $hw; } if(strstr($hw, "No")) { unset($hw); } else { $hardware = "Dell " . $hw; }
} }
include("ucd-mib.inc.php");
## Set OIDs include("hr-mib.inc.php");
$oid_ssCpuRawUser = ".1.3.6.1.4.1.2021.11.50.0";
$oid_ssCpuRawNice = ".1.3.6.1.4.1.2021.11.51.0";
$oid_ssCpuRawSystem = ".1.3.6.1.4.1.2021.11.52.0";
$oid_ssCpuRawIdle = ".1.3.6.1.4.1.2021.11.53.0";
$oid_ssCpuUser = ".1.3.6.1.4.1.2021.11.9.0";
$oid_ssCpuSystem = ".1.3.6.1.4.1.2021.11.10.0";
$cpu_cmd = $config['snmpget'] ." -m UCD-SNMP-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$cpu_cmd .= " $oid_ssCpuRawUser $oid_ssCpuRawSystem $oid_ssCpuRawNice $oid_ssCpuRawIdle $oid_ssCpuUser $oid_ssCpuSystem";
$cpu = `$cpu_cmd`;
list ($cpuUser, $cpuSystem, $cpuNice, $cpuIdle, $UsageUser, $UsageSystem) = explode("\n", $cpu);
$cpuUsage = $UsageUser + $UsageSystem;
if(mysql_result(mysql_query("SELECT COUNT(*) FROM devices_attribs WHERE `device_id` = '" . $device['device_id'] . "' AND `attrib_type` = 'cpuusage'"),0)) {
$update_usage = mysql_query("UPDATE devices_attribs SET attrib_value = '$cpuUsage' WHERE `device_id` = '" . $device['device_id'] . "' AND `attrib_type` = 'cpuusage'");
} else {
$insert_usage = mysql_query("INSERT INTO devices_attribs (`device_id`, `attrib_type`, `attrib_value`) VALUES ('" . $device['device_id'] . "', 'cpuusage', '$cpuUsage')");
}
## Create CPU RRD if it doesn't already exist
if (!is_file($cpurrd)) {
shell_exec($config['rrdtool'] . " create $cpurrd \
--step 300 \
DS:user:COUNTER:600:0:U \
DS:system:COUNTER:600:0:U \
DS:nice:COUNTER:600:0:U \
DS:idle:COUNTER: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($cpurrd, "N:$cpuUser:$cpuSystem:$cpuNice:$cpuIdle");
## If the device isn't monowall or pfsense, monitor all the pretty things
if($device[os] != "m0n0wall" && $device[os] != "Voswall" && $device[os] != "pfSense" ) {
if (!is_file($memrrd)) {
shell_exec($config['rrdtool'] . " create $memrrd \
--step 300 \
DS:totalswap:GAUGE:600:0:10000000000 \
DS:availswap:GAUGE:600:0:10000000000 \
DS:totalreal:GAUGE:600:0:10000000000 \
DS:availreal:GAUGE:600:0:10000000000 \
DS:totalfree:GAUGE:600:0:10000000000 \
DS:shared:GAUGE:600:0:10000000000 \
DS:buffered:GAUGE:600:0:10000000000 \
DS:cached:GAUGE:600:0:10000000000 \
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");
} // end create mem rrd
if(!is_file($loadrrd)) {
shell_exec($config['rrdtool'] . " create $loadrrd \
--step 300 \
DS:1min:GAUGE:600:0:5000 \
DS:5min:GAUGE:600:0:5000 \
DS:15min:GAUGE:600:0:5000 \
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");
} // end create load rrd
$mem_cmd = $config['snmpget'] . " -m UCD-SNMP-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$mem_cmd .= " memTotalSwap.0 memAvailSwap.0 memTotalReal.0 memAvailReal.0 memTotalFree.0 memShared.0 memBuffer.0 memCached.0";
$mem_raw = shell_exec($mem_cmd);
list($memTotalSwap, $memAvailSwap, $memTotalReal, $memAvailReal, $memTotalFree, $memShared, $memBuffer, $memCached) = explode("\n", str_replace(" kB", "", $mem_raw));
$load_get = "laLoadInt.1 laLoadInt.2 laLoadInt.3";
$load_cmd = "snmpget -m UCD-SNMP-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $load_get;
$load_raw = `$load_cmd`;
list ($load1, $load5, $load10) = explode ("\n", $load_raw);
rrdtool_update($loadrrd, "N:$load1:$load5:$load10");
rrdtool_update($memrrd, "N:$memTotalSwap:$memAvailSwap:$memTotalReal:$memAvailReal:$memTotalFree:$memShared:$memBuffer:$memCached");
} // end Non-m0n0wall

View File

@@ -7,105 +7,7 @@
if(strstr($sysDescr, "Uniprocessor Free")) { $features = "Uniprocessor"; } if(strstr($sysDescr, "Uniprocessor Free")) { $features = "Uniprocessor"; }
if(strstr($sysDescr, "Multiprocessor Free")) { $features = "Multiprocessor"; } if(strstr($sysDescr, "Multiprocessor Free")) { $features = "Multiprocessor"; }
$loadrrd = $host_rrd . "/load.rrd"; include("ucd-mib.inc.php");
$cpurrd = $host_rrd . "/cpu.rrd"; include("hr-mib.inc.php");
$memrrd = $host_rrd . "/mem.rrd";
$sysrrd = $host_rrd . "/sys.rrd";
$oid_ssCpuRawUser = ".1.3.6.1.4.1.2021.11.50.0";
$oid_ssCpuRawSystem = ".1.3.6.1.4.1.2021.11.51.0";
$oid_ssCpuRawNice = ".1.3.6.1.4.1.2021.11.52.0";
$oid_ssCpuRawIdle = ".1.3.6.1.4.1.2021.11.53.0";
$oid_hrSystemProcesses = ".1.3.6.1.2.1.25.1.6.0";
$oid_hrSystemNumUsers = ".1.3.6.1.2.1.25.1.5.0";
$s_cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$s_cmd .= " $oid_ssCpuRawUser $oid_ssCpuRawSystem $oid_ssCpuRawNice $oid_ssCpuRawIdle $oid_hrSystemProcesses $oid_hrSystemNumUsers";
$s = shell_exec($s_cmd);
list ($cpuUser, $cpuSystem, $cpuNice, $cpuIdle, $procs, $users) = explode("\n", $s);
if (!is_file($cpurrd)) {
shell_exec($config['rrdtool'] . " create $cpurrd \
--step 300 \
DS:user:COUNTER:600:0:U \
DS:system:COUNTER:600:0:U \
DS:nice:COUNTER:600:0:U \
DS:idle:COUNTER: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");
}
if (!is_file($sysrrd)) {
shell_exec($config['rrdtool'] . " create $sysrrd \
--step 300 \
DS:users:GAUGE:600:0:U \
DS:procs: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");
}
if (!is_file($memrrd)) {
shell_exec($config['rrdtool'] . " create $memrrd \
--step 300 \
DS:totalswap:GAUGE:600:0:10000000000 \
DS:availswap:GAUGE:600:0:10000000000 \
DS:totalreal:GAUGE:600:0:10000000000 \
DS:availreal:GAUGE:600:0:10000000000 \
DS:totalfree:GAUGE:600:0:10000000000 \
DS:shared:GAUGE:600:0:10000000000 \
DS:buffered:GAUGE:600:0:10000000000 \
DS:cached:GAUGE:600:0:10000000000 \
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");
}
if(!is_file($loadrrd)) {
shell_exec($config['rrdtool'] . " create $loadrrd \
--step 300 \
DS:1min:GAUGE:600:0:5000 \
DS:5min:GAUGE:600:0:5000 \
DS:15min:GAUGE:600:0:5000 \
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");
}
$mem_get = "memTotalSwap.0 memAvailSwap.0 memTotalReal.0 memAvailReal.0 memTotalFree.0 memShared.0 memBuffer.0 memCached.0";
$mem_cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $mem_get;
$mem_raw = shell_exec($mem_cmd);
list($memTotalSwap, $memAvailSwap, $memTotalReal, $memAvailReal, $memTotalFree, $memShared, $memBuffer, $memCached) = explode("\n", $mem_raw);
$load_get = "laLoadInt.1 laLoadInt.2 laLoadInt.3";
$load_cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $load_get;
$load_raw = shell_exec($load_cmd);
list ($load1, $load5, $load10) = explode ("\n", $load_raw);
rrdtool_update($sysrrd, "N:$users:$procs");
rrdtool_update($loadrrd, "N:$load1:$load5:$load10");
rrdtool_update($memrrd, "N:$memTotalSwap:$memAvailSwap:$memTotalReal:$memAvailReal:$memTotalFree:$memShared:$memBuffer:$memCached");
rrdtool_update($cpurrd, "N:$cpuUser:$cpuSystem:$cpuNice:$cpuIdle");
?> ?>

View File

@@ -32,5 +32,6 @@ if (!is_file($hrSystem_rrd)) {
rrdtool_update($hrSystem_rrd, "N:$hrSystemNumUsers:$hrSystemProcesses:$uptime"); rrdtool_update($hrSystem_rrd, "N:$hrSystemNumUsers:$hrSystemProcesses:$uptime");
include("hr-mib_storage.inc.php"); // Run HOST-RESOURCES-MIB Storage include("hr-mib_storage.inc.php"); // Run HOST-RESOURCES-MIB Storage
include("hr-mib_processor.inc.php"); // Run HOST-RESOURCES-MIB ProcessorLoad
?> ?>

View File

@@ -0,0 +1,41 @@
<?php
echo("hrDevice : ");
$hrDevice_oids = array('hrDeviceStatus','hrDeviceErrors','hrProcessorLoad');
foreach ($hrDevice_oids as $oid) { echo("$oid "); $hrDevice_array = snmp_cache_oid($oid, $device, $hrDevice_array, "HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES"); }
$sql = "SELECT * FROM `hrDevice` WHERE `device_id` = '".$device['device_id']."' AND `hrDeviceType` = 'hrDeviceProcessor'";
$query = mysql_query($sql);
while ($hrDevice = mysql_fetch_array($query)) {
$this_hrDevice = $hrDevice_array[$device[device_id]][$hrDevice[hrDeviceIndex]];
$update_query = "UPDATE `hrDevice` SET";
$update_query .= ", `hrDeviceStatus` = '".mres($this_hrDevice[hrDeviceStatus])."'";
$update_query .= ", `hrDeviceErrors` = '".mres($this_hrDevice[hrDeviceErrors])."'";
$update_query .= ", `hrProcessorLoad` = '".mres($this_hrDevice[hrProcessorLoad])."'";
$update_query .= " WHERE device_id = '".$device['device_id']."' AND hrDeviceIndex = '".$hrDevice['hrDeviceIndex']."'";
@mysql_query($update_query); $mysql++; echo(".");
$procrrd = addslashes($config['rrd_dir'] . "/" . $device['hostname'] . "/hrProcessor-" . $hrDevice['hrDeviceIndex'] . ".rrd");
if (!is_file($procrrd)) {
shell_exec($config['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");
}
echo($this_hrDevice['hrProcessorLoad'] . "% ");
rrdtool_update ($procrrd, "N:".$this_hrDevice['hrProcessorLoad']);
}
echo("\n");
?>

View File

@@ -40,8 +40,6 @@ if (!is_file($cpurrd)) {
rrdtool_update($cpurrd, "N:$cpuUser:$cpuSystem:$cpuNice:$cpuIdle"); rrdtool_update($cpurrd, "N:$cpuUser:$cpuSystem:$cpuNice:$cpuIdle");
## If the device isn't monowall or pfsense, monitor all the pretty things
if($device[os] != "m0n0wall" && $device[os] != "Voswall" && $device[os] != "pfSense" ) {
if (!is_file($memrrd)) { if (!is_file($memrrd)) {
shell_exec($config['rrdtool'] . " create $memrrd \ shell_exec($config['rrdtool'] . " create $memrrd \
--step 300 \ --step 300 \
@@ -93,5 +91,3 @@ if($device[os] != "m0n0wall" && $device[os] != "Voswall" && $device[os] != "pfSe
rrdtool_update($loadrrd, "N:$load1:$load5:$load10"); rrdtool_update($loadrrd, "N:$load1:$load5:$load10");
rrdtool_update($memrrd, "N:$memTotalSwap:$memAvailSwap:$memTotalReal:$memAvailReal:$memTotalFree:$memShared:$memBuffer:$memCached"); rrdtool_update($memrrd, "N:$memTotalSwap:$memAvailSwap:$memTotalReal:$memAvailReal:$memTotalFree:$memShared:$memBuffer:$memCached");
} // end Non-m0n0wall

File diff suppressed because it is too large Load Diff

View File

@@ -3,6 +3,7 @@
include("config.php"); include("config.php");
include("includes/functions.php"); include("includes/functions.php");
include("includes/functions-poller.inc.php");
$start = utime(); $start = utime();
@@ -47,7 +48,7 @@ while ($device = mysql_fetch_array($device_query)) {
echo($device['hostname'] . "(".$device['sysName']."|".$device['device_id'].")\n"); echo($device['hostname'] . "(".$device['sysName']."|".$device['device_id'].")\n");
include("includes/discovery/".$type.".php"); include("includes/discovery/".$type);
echo("\n"); $devices_polled++; echo("\n"); $devices_polled++;
} }
@@ -55,7 +56,7 @@ while ($device = mysql_fetch_array($device_query)) {
$end = utime(); $run = $end - $start; $end = utime(); $run = $end - $start;
$proctime = substr($run, 0, 5); $proctime = substr($run, 0, 5);
echo("$devices_polled devices polled in $proctime secs\n"); echo("$devices_polled devices polled in $proctime secs\n $mysql SQL");
?> ?>