updates et al

git-svn-id: http://www.observium.org/svn/observer/trunk@503 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2009-11-07 02:30:38 +00:00
parent 65b8eb183e
commit 975c3a2a93
28 changed files with 303 additions and 303 deletions

View File

@@ -10,30 +10,34 @@ $start = utime();
echo("Observer v".$config['version']." Discovery\n\n"); echo("Observer v".$config['version']." Discovery\n\n");
if($argv[1] == "--device" && $argv[2]) { $options = getopt("h:t:i:n:d::a::");
$where = "AND `device_id` = '".$argv[2]."'";
} elseif ($argv[1] == "--os") { if ($options['h'] == "odd") {
$where = "AND `os` = '".$argv[2]."'"; $where = "AND MOD(device_id,2) = 1"; $doing = $options['h'];
} elseif ($argv[1] == "--odd") { } elseif ($options['h'] == "even") {
$where = "AND MOD(device_id,2) = 1"; $where = "AND MOD(device_id,2) = 0"; $doing = $options['h'];
} elseif ($argv[1] == "--even") { } elseif ($options['h'] == "all") {
$where = "AND MOD(device_id,2) = 0"; $where = " "; $doing = "all";
} elseif ($argv[1] == "--all") { } elseif($options['h']) {
$where = ""; $where = "AND `device_id` = '".$options['h']."'"; $doing = "Host ".$options['h'];
} elseif ($argv[1] == "--forced") { } elseif ($options['i'] && isset($options['n'])) {
echo("Doing forced discoveries\n"); $where = "AND MOD(device_id,".$options['i'].") = '" . $options['n'] . "'"; $doing = "Proc ".$options['n'] ."/".$options['i'];
$sql = mysql_query("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_type = 'discover' AND A.device_id = D.device_id AND D.ignore = '0' AND D.disabled = '0'"); }
while($device = mysql_fetch_array($sql)){
echo(shell_exec("./discovery.php --device " . $device['device_id'])); if(!$where) {
} echo("-h <device id> Poll single device\n");
exit; echo("-h odd Poll odd numbered devices (same as -i 2 -n 0)\n");
} else { echo("-h even Poll even numbered devices (same as -i 2 -n 1)\n");
echo("--device <device id> Poll single device\n"); echo("-h all Poll all devices\n\n");
echo("--os <os string> Poll all devices of a given OS\n"); echo("-i <instances> -n <number> Poll as instance <number> of <instances>\n");
echo("--all Poll all devices\n\n"); echo(" Instances start at 0. 0-3 for -n 4\n\n");
echo("-d Enable some debugging output\n");
echo("\n");
echo("No polling type specified!\n"); echo("No polling type specified!\n");
exit; exit;
} }
if(isset($options['d'])) { echo("DEBUG!\n"); $debug = 1; }
$devices_discovered = 0; $devices_discovered = 0;
@@ -55,17 +59,12 @@ while ($device = mysql_fetch_array($device_query)) {
## Discover Temperatures ## Discover Temperatures
include("includes/discovery/temperatures.php"); include("includes/discovery/temperatures.php");
if($device['os'] == "Linux" || $device['os'] == "FreeBSD") { ## Discover Storage
include("includes/discovery/storage.php"); include("includes/discovery/storage.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");
}
if($device['os'] == "IOS" || $device['os'] == "IOS XE" || $device['os'] == "CatOS") { if($device['os'] == "IOS" || $device['os'] == "IOS XE" || $device['os'] == "CatOS") {

View File

@@ -41,10 +41,17 @@ if($_GET['debug']) {
$graphfile = $config['temp_dir'] . "/" . strgen() . ".png"; $graphfile = $config['temp_dir'] . "/" . strgen() . ".png";
$os = gethostosbyid($device_id); $os = gethostosbyid($device_id);
$os_lower = strtolower($os);
if($os_groups[$os_lower]) {$os_group = $os_groups[$os_lower];}
if(is_file($config['install_dir'] . "/html/includes/graphs/".$type."_".strtolower($os).".inc.php")) { if(is_file($config['install_dir'] . "/html/includes/graphs/".$type."_".$os_lower.".inc.php")) {
include($config['install_dir'] . "/html/includes/graphs/".$type."_".strtolower($os).".inc.php"); /// Type + OS Specific
include($config['install_dir'] . "/html/includes/graphs/".$type."_".$os_lower.".inc.php");
}elseif($os_group && is_file($config['install_dir'] . "/html/includes/graphs/".$type."_".$os_group.".inc.php")) {
/// Type + OS Group Specific
include($config['install_dir'] . "/html/includes/graphs/".$type."_".$os_group.".inc.php");
} elseif(is_file($config['install_dir'] . "/html/includes/graphs/$type.inc.php")) { } elseif(is_file($config['install_dir'] . "/html/includes/graphs/$type.inc.php")) {
/// Type Specific
include($config['install_dir'] . "/html/includes/graphs/$type.inc.php"); include($config['install_dir'] . "/html/includes/graphs/$type.inc.php");
} }

View File

@@ -1,5 +1,7 @@
<?php <?php
$scale_min = "0";
$data = mysql_fetch_array(mysql_query("SELECT * FROM bgpPeers AS B, devices AS D WHERE bgpPeer_id = '".$_GET['peer']."' AND D.device_id = B.device_id")); $data = mysql_fetch_array(mysql_query("SELECT * FROM bgpPeers AS B, devices AS D WHERE bgpPeer_id = '".$_GET['peer']."' AND D.device_id = B.device_id"));
$rrd_filename = $config['rrd_dir'] . "/" . $data['hostname'] . "/bgp-" . $data['bgpPeerIdentifier'] . ".rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $data['hostname'] . "/bgp-" . $data['bgpPeerIdentifier'] . ".rrd";

View File

@@ -1,5 +1,9 @@
<?php <?php
include("common.inc.php");
$scale_min = "0";
$data = mysql_fetch_array(mysql_query("SELECT * FROM bgpPeers AS B, devices AS D WHERE bgpPeer_id = '".$_GET['peer']."' AND D.device_id = B.device_id")); $data = mysql_fetch_array(mysql_query("SELECT * FROM bgpPeers AS B, devices AS D WHERE bgpPeer_id = '".$_GET['peer']."' AND D.device_id = B.device_id"));
$rrd_filename = $config['rrd_dir'] . "/" . $data['hostname'] . "/cbgp-" . $data['bgpPeerIdentifier'] . ".".$_GET['afi'].".".$_GET['safi'].".rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $data['hostname'] . "/cbgp-" . $data['bgpPeerIdentifier'] . ".".$_GET['afi'].".".$_GET['safi'].".rrd";

View File

@@ -1,9 +1,4 @@
<?php <?php
$os = strtolower($os);
if($os == "linux" || $os == "netbsd" || $os == "freebsd" || $os == "dragonfly" || $os == "openbsd" || $os == "windows" || $os == "m0n0wall" || $os == "Voswall" || $os == "pfsense" || $os == "dragonfly" || $os == "openbsd") {
include("device_cpu_unix.inc.php");
}
?> ?>

View File

@@ -4,7 +4,7 @@ $scale_min = "0";
include("common.inc.php"); include("common.inc.php");
$database = $config['rrd_dir'] . "/" . $hostname . "/sys.rrd"; $database = $config['rrd_dir'] . "/" . $hostname . "/hrSystem.rrd";
$rrd_options .= " DEF:procs=$database:procs:AVERAGE"; $rrd_options .= " DEF:procs=$database:procs:AVERAGE";
$rrd_options .= " COMMENT:Processes\ \ \ \ Cur\ \ \ \ \ Ave\ \ \ \ \ \ Min\ \ \ \ \ Max\\\\n"; $rrd_options .= " COMMENT:Processes\ \ \ \ Cur\ \ \ \ \ Ave\ \ \ \ \ \ Min\ \ \ \ \ Max\\\\n";

View File

@@ -1,5 +1,8 @@
<?php <?php
$scale_min = "0";
$scale_max = "100";
include("common.inc.php"); include("common.inc.php");
$iter = "1"; $iter = "1";
@@ -13,7 +16,7 @@ include("common.inc.php");
$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']); $text = str_replace("/", "_", $fs['hrStorageDescr']);
$rrd = $config['rrd_dir'] . "/$hostname/storage-$text.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";
$rrd_options .= " DEF:$fs[storage_id]p=$rrd:perc:AVERAGE"; $rrd_options .= " DEF:$fs[storage_id]p=$rrd:perc:AVERAGE";

View File

@@ -4,7 +4,7 @@ $scale_min = "0";
include("common.inc.php"); include("common.inc.php");
$database = $config['rrd_dir'] . "/" . $hostname . "/sys.rrd"; $database = $config['rrd_dir'] . "/" . $hostname . "/hrSystem.rrd";
$rrd_options .= " DEF:users=$database:users:AVERAGE"; $rrd_options .= " DEF:users=$database:users:AVERAGE";
$rrd_options .= " DEF:users_max=$database:users:MAX"; $rrd_options .= " DEF:users_max=$database:users:MAX";

View File

@@ -4,50 +4,64 @@ include('common.inc.php');
$rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/netstats-icmp.rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/netstats-icmp.rrd";
$rrd_options .= " DEF:sqIn=$rrd_filename:icmpInSrcQuenchs:AVERAGE"; $rrd_options .= " DEF:InSrcQuenchs=$rrd_filename:icmpInSrcQuenchs:AVERAGE";
$rrd_options .= " DEF:sqOut=$rrd_filename:icmpOutSrcQuenchs:AVERAGE"; $rrd_options .= " DEF:OutSrcQuenchs=$rrd_filename:icmpOutSrcQuenchs:AVERAGE";
$rrd_options .= " DEF:redirIn=$rrd_filename:icmpInRedirects:AVERAGE"; $rrd_options .= " DEF:InRedirects=$rrd_filename:icmpInRedirects:AVERAGE";
$rrd_options .= " DEF:redirOut=$rrd_filename:icmpOutRedirects:AVERAGE"; $rrd_options .= " DEF:OutRedirects=$rrd_filename:icmpOutRedirects:AVERAGE";
$rrd_options .= " DEF:maskIn=$rrd_filename:icmpInAddrMasks:AVERAGE"; $rrd_options .= " DEF:InAddrMasks=$rrd_filename:icmpInAddrMasks:AVERAGE";
$rrd_options .= " DEF:maskOut=$rrd_filename:icmpOutAddrMasks:AVERAGE"; $rrd_options .= " DEF:OutAddrMasks=$rrd_filename:icmpOutAddrMasks:AVERAGE";
$rrd_options .= " DEF:maskrepIn=$rrd_filename:icmpInAddrMaskReps:AVERAGE"; $rrd_options .= " DEF:InAddrMaskReps=$rrd_filename:icmpInAddrMaskReps:AVERAGE";
$rrd_options .= " DEF:maskrepOut=$rrd_filename:icmpOutAddrMaskReps:AVERAGE"; $rrd_options .= " DEF:OutAddrMaskReps=$rrd_filename:icmpOutAddrMaskReps:AVERAGE";
$rrd_options .= " CDEF:sqOutInv=sqOut,-1,*"; $rrd_options .= " DEF:InSrcQuenchs_m=$rrd_filename:icmpInSrcQuenchs:MAX";
$rrd_options .= " CDEF:redirOutInv=redirOut,-1,*"; $rrd_options .= " DEF:OutSrcQuenchs_m=$rrd_filename:icmpOutSrcQuenchs:MAX";
$rrd_options .= " CDEF:maskOutInv=maskOut,-1,*"; $rrd_options .= " DEF:InRedirects_m=$rrd_filename:icmpInRedirects:MAX";
$rrd_options .= " CDEF:maskrepOutInv=maskrepOut,-1,*"; $rrd_options .= " DEF:OutRedirects_m=$rrd_filename:icmpOutRedirects:MAX";
$rrd_options .= " AREA:sqIn#00ff00:'Source Quenches In '"; $rrd_options .= " DEF:InAddrMasks_m=$rrd_filename:icmpInAddrMasks:MAX";
$rrd_options .= " GPRINT:sqIn:AVERAGE:'Avg \\: %8.2lf %s'"; $rrd_options .= " DEF:OutAddrMasks_m=$rrd_filename:icmpOutAddrMasks:MAX";
$rrd_options .= " GPRINT:sqIn:MIN:'Min \\: %8.2lf %s'"; $rrd_options .= " DEF:InAddrMaskReps_m=$rrd_filename:icmpInAddrMaskReps:MAX";
$rrd_options .= " GPRINT:sqIn:MAX:'Max \\: %8.2lf %s\\n'"; $rrd_options .= " DEF:OutAddrMaskReps_m=$rrd_filename:icmpOutAddrMaskReps:MAX";
$rrd_options .= " STACK:redirIn#0000ff:'Redirects In '";
$rrd_options .= " GPRINT:redirIn:AVERAGE:'Avg \\: %8.2lf %s'"; $rrd_options .= " CDEF:OutSrcQuenchs_Inv=OutSrcQuenchs,-1,*";
$rrd_options .= " GPRINT:redirIn:MIN:'Min \\: %8.2lf %s'"; $rrd_options .= " CDEF:OutRedirects_Inv=OutRedirects,-1,*";
$rrd_options .= " GPRINT:redirIn:MAX:'Max \\: %8.2lf %s\\n'"; $rrd_options .= " CDEF:OutAddrMasks_Inv=OutAddrMasks,-1,*";
$rrd_options .= " STACK:maskIn#ff00b4:'Mask Requests In '"; $rrd_options .= " CDEF:OutAddrMaskReps_Inv=OutAddrMaskReps,-1,*";
$rrd_options .= " GPRINT:maskIn:AVERAGE:'Avg \\: %8.2lf %s'";
$rrd_options .= " GPRINT:maskIn:MIN:'Min \\: %8.2lf %s'"; $rrd_options .= " COMMENT:Packets/sec\ \ \ \ Current\ \ \ \ Average\ \ \ Maximum\\\\n";
$rrd_options .= " GPRINT:maskIn:MAX:'Max \\: %8.2lf %s\\n'";
$rrd_options .= " STACK:maskrepIn#00ff72:'Mask Replies In '"; $rrd_options .= " LINE1.25:InSrcQuenchs#00cc00:'InSrcQuenchs '";
$rrd_options .= " GPRINT:maskrepIn:AVERAGE:'Avg \\: %8.2lf %s'"; $rrd_options .= " GPRINT:InSrcQuenchs:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:maskrepIn:MIN:'Min \\: %8.2lf %s'"; $rrd_options .= " GPRINT:InSrcQuenchs:AVERAGE:%6.2lf%s";
$rrd_options .= " GPRINT:maskrepIn:MAX:'Max \\: %8.2lf %s\\n'"; $rrd_options .= " GPRINT:InSrcQuenchs_m:MAX:%6.2lf%s\\\\n";
$rrd_options .= " COMMENT:'\\n'"; $rrd_options .= " LINE1.25:OutSrcQuenchs_Inv#006600:'OutSrcQuenchs '";
$rrd_options .= " AREA:sqOut#00ff00:'Source Quenches Out'"; $rrd_options .= " GPRINT:OutSrcQuenchs:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:sqOut:AVERAGE:'Avg \\: %8.2lf %s'"; $rrd_options .= " GPRINT:OutSrcQuenchs:AVERAGE:%6.2lf%s";
$rrd_options .= " GPRINT:sqOut:MIN:'Min \\: %8.2lf %s'"; $rrd_options .= " GPRINT:OutSrcQuenchs_m:MAX:%6.2lf%s\\\\n";
$rrd_options .= " GPRINT:sqOut:MAX:'Max \\: %8.2lf %s\\n'";
$rrd_options .= " STACK:redirOut#0000ff:'Redirects Out '"; $rrd_options .= " LINE1.25:InRedirects#cc0000:'InRedirects '";
$rrd_options .= " GPRINT:redirOut:AVERAGE:'Avg \\: %8.2lf %s'"; $rrd_options .= " GPRINT:InRedirects:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:redirOut:MIN:'Min \\: %8.2lf %s'"; $rrd_options .= " GPRINT:InRedirects:AVERAGE:%6.2lf%s";
$rrd_options .= " GPRINT:redirOut:MAX:'Max \\: %8.2lf %s\\n'"; $rrd_options .= " GPRINT:InRedirects_m:MAX:'%6.2lf%s\\n'";
$rrd_options .= " STACK:maskOut#ff00b4:'Mask Requests Out '"; $rrd_options .= " LINE1.25:OutRedirects_Inv#660000:'OutRedirects '";
$rrd_options .= " GPRINT:maskOut:AVERAGE:'Avg \\: %8.2lf %s'"; $rrd_options .= " GPRINT:OutRedirects:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:maskOut:MIN:'Min \\: %8.2lf %s'"; $rrd_options .= " GPRINT:OutRedirects:AVERAGE:%6.2lf%s";
$rrd_options .= " GPRINT:maskOut:MAX:'Max \\: %8.2lf %s\\n'"; $rrd_options .= " GPRINT:OutRedirects_m:MAX:'%6.2lf%s\\n'";
$rrd_options .= " STACK:maskrepOut#00ff72:'Mask Replies Out '";
$rrd_options .= " GPRINT:maskrepOut:AVERAGE:'Avg \\: %8.2lf %s'"; $rrd_options .= " LINE1.25:InAddrMasks#0066cc:'InAddrMasks '";
$rrd_options .= " GPRINT:maskrepOut:MIN:'Min \\: %8.2lf %s'"; $rrd_options .= " GPRINT:InAddrMasks:LAST:'%6.2lf%s'";
$rrd_options .= " GPRINT:maskrepOut:MAX:'Max \\: %8.2lf %s'"; $rrd_options .= " GPRINT:InAddrMasks:AVERAGE:'%6.2lf%s'";
$rrd_options .= " GPRINT:InAddrMasks:MAX:'%6.2lf%s\\n'";
$rrd_options .= " LINE1.25:OutAddrMasks_Inv#003399:'OutAddrMasks '";
$rrd_options .= " GPRINT:OutAddrMasks:LAST:'%6.2lf%s'";
$rrd_options .= " GPRINT:OutAddrMasks:AVERAGE:'%6.2lf%s'";
$rrd_options .= " GPRINT:OutAddrMasks_m:MAX:'%6.2lf%s\\n'";
$rrd_options .= " LINE1.25:InAddrMaskReps#cc00cc:'InAddrMaskReps '";
$rrd_options .= " GPRINT:InAddrMaskReps:LAST:'%6.2lf%s'";
$rrd_options .= " GPRINT:InAddrMaskReps:AVERAGE:'%6.2lf%s'";
$rrd_options .= " GPRINT:InAddrMaskReps:MAX:'%6.2lf%s\\n'";
$rrd_options .= " LINE1.25:OutAddrMaskReps_Inv#990099:'OutAddrMaskReps'";
$rrd_options .= " GPRINT:OutAddrMaskReps:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:OutAddrMaskReps:AVERAGE:%6.2lf%s";
$rrd_options .= " GPRINT:OutAddrMaskReps_m:MAX:%6.2lf%s\\\\n";
?> ?>

View File

@@ -30,22 +30,37 @@ $rrd_options .= " CDEF:MReasmFails=MipReasmFails,ipInDelivers,/,100,*";
$rrd_options .= " CDEF:MFragOKs=MipFragOKs,ipInDelivers,/,100,*"; $rrd_options .= " CDEF:MFragOKs=MipFragOKs,ipInDelivers,/,100,*";
$rrd_options .= " CDEF:MFragFails=MipFragFails,ipInDelivers,/,100,*"; $rrd_options .= " CDEF:MFragFails=MipFragFails,ipInDelivers,/,100,*";
$rrd_options .= " CDEF:MFragCreates=MipFragCreates,ipInDelivers,/,100,*"; $rrd_options .= " CDEF:MFragCreates=MipFragCreates,ipInDelivers,/,100,*";
$rrd_options .= " LINE1:FragOKs#00ff00:'Fragmentation OK'";
$rrd_options .= " LINE2:FragFails#ff0000:'Fragmentation Fail'"; $rrd_options .= " COMMENT:'% ipInDelivers Current Average Maximum\\n'";
$rrd_options .= " LINE1:ReasmOKs#0033aa:'Reassembly OK'";
$rrd_options .= " LINE2:ReasmFails#000000:'Reassembly Fail'"; $rrd_options .= " LINE1.25:FragOKs#00cc00:'Frag OK '";
$rrd_options .= " GPRINT:ReasmReqds:AVERAGE:Avg\ ReasmReqd\ %1.2lf\ %%"; $rrd_options .= " GPRINT:FragOKs:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:MReasmReqds:MAX:Max\ ReasmReqd\ %1.2lf\ %%"; $rrd_options .= " GPRINT:FragOKs:AVERAGE:%6.2lf%s";
$rrd_options .= " GPRINT:ReasmOKs:AVERAGE:Avg\ ReasmOK\ %1.2lf\ %%"; $rrd_options .= " GPRINT:MFragOKs:MAX:%6.2lf%s\\\\n";
$rrd_options .= " GPRINT:MReasmOKs:MAX:Max\ ReasmOK\ %1.2lf\ %%";
$rrd_options .= " GPRINT:ReasmFails:AVERAGE:Avg\ ReasmFail\ %1.2lf\ %%"; $rrd_options .= " LINE1.25:FragFails#cc0000:'Frag Fail '";
$rrd_options .= " GPRINT:MReasmFails:MAX:Max\ ReasmFail\ %1.2lf\ %%"; $rrd_options .= " GPRINT:FragFails:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:FragOKs:AVERAGE:Avg\ FragOK\ %1.2lf\ %%"; $rrd_options .= " GPRINT:FragFails:AVERAGE:%6.2lf%s";
$rrd_options .= " GPRINT:MFragOKs:MAX:Max\ FragOK\ %1.2lf\ %%"; $rrd_options .= " GPRINT:MFragFails:MAX:%6.2lf%s\\\\n";
$rrd_options .= " GPRINT:FragFails:AVERAGE:Avg\ FragFail\ %1.2lf\ %%";
$rrd_options .= " GPRINT:MFragFails:MAX:Max\ FragFail\ %1.2lf\ %%"; $rrd_options .= " LINE1.25:ReasmOKs#006600:'Reasm OK '";
$rrd_options .= " GPRINT:FragCreates:AVERAGE:Avg\ FragCreate\ %1.2lf\ %%"; $rrd_options .= " GPRINT:ReasmOKs:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:MFragCreates:MAX:Max\ FragCreate\ %1.2lf\ %%"; $rrd_options .= " GPRINT:ReasmOKs:AVERAGE:%6.2lf%s";
$rrd_options .= " COMMENT:' Calculated as a % of ipInDelivers'" $rrd_options .= " GPRINT:MReasmOKs:MAX:%6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:ReasmFails#660000:'Reasm Fail '";
$rrd_options .= " GPRINT:ReasmFails:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:ReasmFails:AVERAGE:%6.2lf%s";
$rrd_options .= " GPRINT:MReasmFails:MAX:%6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:FragCreates#00cc:'Frag Create '";
$rrd_options .= " GPRINT:FragCreates:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:FragCreates:AVERAGE:%6.2lf%s";
$rrd_options .= " GPRINT:MFragCreates:MAX:%6.2lf%s\\\\n";
$rrd_options .= " LINE1.25:ReasmReqds#000066:'Reasm Reqd '";
$rrd_options .= " GPRINT:ReasmReqds:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:ReasmReqds:AVERAGE:%6.2lf%s";
$rrd_options .= " GPRINT:MReasmReqds:MAX:%6.2lf%s\\\\n";
?> ?>

View File

@@ -2,29 +2,29 @@
include("common.inc.php"); include("common.inc.php");
$rrd_filename = $config['rrd_dir'] . "/" . $_GET['device'] . "/uptime.rrd"; $rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/load.rrd";
$options .= " DEF:1min=$rrd_filename:1min:AVERAGE"; $rrd_options .= " DEF:1min=$rrd_filename:1min:AVERAGE";
$options .= " DEF:5min=$rrd_filename:5min:AVERAGE"; $rrd_options .= " DEF:5min=$rrd_filename:5min:AVERAGE";
$options .= " DEF:15min=$rrd_filename:15min:AVERAGE"; $rrd_options .= " DEF:15min=$rrd_filename:15min:AVERAGE";
$options .= " CDEF:a=1min,100,/"; $rrd_options .= " CDEF:a=1min,100,/";
$options .= " CDEF:b=5min,100,/"; $rrd_options .= " CDEF:b=5min,100,/";
$options .= " CDEF:c=15min,100,/"; $rrd_options .= " CDEF:c=15min,100,/";
$options .= " CDEF:cdefd=a,b,c,+,+"; $rrd_options .= " CDEF:cdefd=a,b,c,+,+";
$options .= " COMMENT:Load\ Average\ \ Current\ \ \ \ Average\ \ \ \ Maximum\\\\n"; $rrd_options .= " COMMENT:Load\ Average\ \ Current\ \ \ \ Average\ \ \ \ Maximum\\\\n";
$options .= " AREA:a#ffeeaa:1\ Min:"; $rrd_options .= " AREA:a#ffeeaa:1\ Min:";
$options .= " LINE1:a#c5aa00:"; $rrd_options .= " LINE1:a#c5aa00:";
$options .= " GPRINT:a:LAST:\ \ \ \ %7.2lf"; $rrd_options .= " GPRINT:a:LAST:\ \ \ \ %7.2lf";
$options .= " GPRINT:a:AVERAGE:\ \ %7.2lf"; $rrd_options .= " GPRINT:a:AVERAGE:\ \ %7.2lf";
$options .= " GPRINT:a:MAX:\ \ %7.2lf\\\\n"; $rrd_options .= " GPRINT:a:MAX:\ \ %7.2lf\\\\n";
$options .= " LINE1.25:b#ea8f00:5\ Min:"; $rrd_options .= " LINE1.25:b#ea8f00:5\ Min:";
$options .= " GPRINT:b:LAST:\ \ \ \ %7.2lf"; $rrd_options .= " GPRINT:b:LAST:\ \ \ \ %7.2lf";
$options .= " GPRINT:b:AVERAGE:\ \ %7.2lf"; $rrd_options .= " GPRINT:b:AVERAGE:\ \ %7.2lf";
$options .= " GPRINT:b:MAX:\ \ %7.2lf\\\\n"; $rrd_options .= " GPRINT:b:MAX:\ \ %7.2lf\\\\n";
$options .= " LINE1.25:c#cc0000:15\ Min"; $rrd_options .= " LINE1.25:c#cc0000:15\ Min";
$options .= " GPRINT:c:LAST:\ \ \ %7.2lf"; $rrd_options .= " GPRINT:c:LAST:\ \ \ %7.2lf";
$options .= " GPRINT:c:AVERAGE:\ \ %7.2lf"; $rrd_options .= " GPRINT:c:AVERAGE:\ \ %7.2lf";
$options .= " GPRINT:c:MAX:\ \ %7.2lf\\\\n"; $rrd_options .= " GPRINT:c:MAX:\ \ %7.2lf\\\\n";
?> ?>

View File

@@ -1,9 +1,4 @@
<?php <?php
$os = strtolower($os);
if($os == "linux" || $os == "netbsd" || $os == "freebsd" || $os == "dragonfly" || $os == "openbsd" || $os == "windows" || $os == "m0n0wall" || $os == "Voswall" || $os == "pfsense" || $os == "dragonfly" || $os == "openbsd") {
include("device_memory_unix.inc.php");
}
?> ?>

View File

@@ -5,7 +5,7 @@ include("common.inc.php");
$rrd_options .= " -l 0 -E -b 1024 -u 100 -r"; $rrd_options .= " -l 0 -E -b 1024 -u 100 -r";
$iter = "1"; $iter = "1";
$rrd_options .= " COMMENT:' Cur Max\\n'"; $rrd_options .= " COMMENT:' Currently Used Max\\n'";
$sql = mysql_query("SELECT * FROM `cempMemPool` where `device_id` = '$device_id'"); $sql = mysql_query("SELECT * FROM `cempMemPool` where `device_id` = '$device_id'");
while($mempool = mysql_fetch_array($sql)) { while($mempool = mysql_fetch_array($sql)) {
@@ -18,16 +18,20 @@ include("common.inc.php");
$mempool['descr_fixed'] = str_replace("Routing Processor", "RP", $mempool['descr_fixed']); $mempool['descr_fixed'] = str_replace("Routing Processor", "RP", $mempool['descr_fixed']);
$mempool['descr_fixed'] = str_replace("Switching Processor", "SP", $mempool['descr_fixed']); $mempool['descr_fixed'] = str_replace("Switching Processor", "SP", $mempool['descr_fixed']);
$mempool['descr_fixed'] = str_replace("Processor", "Proc", $mempool['descr_fixed']); $mempool['descr_fixed'] = str_replace("Processor", "Proc", $mempool['descr_fixed']);
$mempool['descr_fixed'] = str_pad($mempool['descr_fixed'], 28); $mempool['descr_fixed'] = str_pad($mempool['descr_fixed'], 20);
$mempool['descr_fixed'] = substr($mempool['descr_fixed'],0,28); $mempool['descr_fixed'] = substr($mempool['descr_fixed'],0,20);
$oid = $mempool['entPhysicalIndex'] . "." . $mempool['Index']; $oid = $mempool['entPhysicalIndex'] . "." . $mempool['Index'];
$rrd = $config['rrd_dir'] . "/$hostname/cempMemPool-$oid.rrd"; $rrd = $config['rrd_dir'] . "/$hostname/cempMemPool-$oid.rrd";
$rrd_options .= " DEF:mempool" . $iter . "free=$rrd:free:AVERAGE "; $rrd_options .= " DEF:mempool" . $iter . "free=$rrd:free:AVERAGE";
$rrd_options .= " DEF:mempool" . $iter . "used=$rrd:used:AVERAGE "; $rrd_options .= " DEF:mempool" . $iter . "used=$rrd:used:AVERAGE";
$rrd_options .= " DEF:mempool" . $iter . "free_m=$rrd:free:MAX";
$rrd_options .= " DEF:mempool" . $iter . "used_m=$rrd:used:MAX";
$rrd_options .= " CDEF:mempool" . $iter . "total=mempool" . $iter . "used,mempool" . $iter . "used,mempool" . $iter . "free,+,/,100,* "; $rrd_options .= " CDEF:mempool" . $iter . "total=mempool" . $iter . "used,mempool" . $iter . "used,mempool" . $iter . "free,+,/,100,* ";
$rrd_options .= " LINE1:mempool" . $iter . "total#" . $colour . ":'" . $mempool['descr_fixed'] . "' "; $rrd_options .= " LINE1:mempool" . $iter . "total#" . $colour . ":'" . $mempool['descr_fixed'] . "' ";
$rrd_options .= " GPRINT:mempool" . $iter . "total:LAST:%3.0lf"; $rrd_options .= " GPRINT:mempool" . $iter . "used:LAST:%6.2lf%s";
$rrd_options .= " GPRINT:mempool" . $iter . "total:MAX:%3.0lf\\\l "; $rrd_options .= " GPRINT:mempool" . $iter . "total:LAST:%3.0lf%%";
$rrd_options .= " GPRINT:mempool" . $iter . "total:MAX:%3.0lf%%\\\\n";
$iter++; $iter++;
} }

View File

@@ -1,8 +1,14 @@
<?php <?php
$scale_min = "0";
include("common.inc.php"); include("common.inc.php");
$rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/uptime.rrd"; if (is_file($config['rrd_dir'] . "/" . $hostname . "/hrSystem.rrd")) {
$rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/hrSystem.rrd";
} else {
$rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/uptime.rrd";
}
$rrd_options .= " DEF:uptime=$rrd_filename:uptime:AVERAGE"; $rrd_options .= " DEF:uptime=$rrd_filename:uptime:AVERAGE";
$rrd_options .= " CDEF:cuptime=uptime,86400,/"; $rrd_options .= " CDEF:cuptime=uptime,86400,/";
@@ -12,6 +18,4 @@ $rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/uptime.rrd";
$rrd_options .= " GPRINT:cuptime:LAST:%6.2lf\ GPRINT:cuptime:AVERAGE:%6.2lf\ "; $rrd_options .= " GPRINT:cuptime:LAST:%6.2lf\ GPRINT:cuptime:AVERAGE:%6.2lf\ ";
$rrd_options .= " GPRINT:cuptime:MAX:%6.2lf\ GPRINT:cuptime:AVERAGE:%6.2lf\\\\n"; $rrd_options .= " GPRINT:cuptime:MAX:%6.2lf\ GPRINT:cuptime:AVERAGE:%6.2lf\\\\n";
$scale_min = "0";
?> ?>

View File

@@ -17,7 +17,7 @@ $rrd_options .= " -b 1024";
$descr = str_pad($fs[hrStorageDescr], 12); $descr = str_pad($fs[hrStorageDescr], 12);
$descr = substr($descr,0,12); $descr = substr($descr,0,12);
$text = str_replace("/", "_", $fs['hrStorageDescr']); $text = str_replace("/", "_", $fs['hrStorageDescr']);
$rrd = $config['rrd_dir'] . "/$hostname/storage-$text.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";
$rrd_options .= " DEF:$fs[storage_id]p=$rrd:perc:AVERAGE"; $rrd_options .= " DEF:$fs[storage_id]p=$rrd:perc:AVERAGE";

View File

@@ -84,18 +84,41 @@ while($device = mysql_fetch_array($device_query)) {
break; break;
case "Windows": case "Windows":
echo("<div class=graphhead>CPU Usage</div>");
$graph_type = "device_cpu"; $graph_type = "device_cpu";
include ("includes/print-device-graph.php"); include ("includes/print-device-graph.php");
$memgraph = memgraphWin ($device[hostname] . "-mem.rrd", $device[hostname] . "-mem.png", $day, $now, 335, 100); echo("<div class=graphhead>Memory Utilisation</div>");
$loadgraph = loadgraphWin ($device[hostname] . "-load.rrd", $device[hostname] . "-load.png", $day, $now, 335, 100); $graph_type = "device_memory"; include ("includes/print-device-graph.php");
$cpugraphm = cpugraphWin ($device[hostname] . "-cpu.rrd", $device[hostname] . "-cpu-m.png", $month, $now, 335, 100); echo("<br />");
$memgraphm = memgraphWin ($device[hostname] . "-mem.rrd", $device[hostname] . "-mem-m.png", $month, $now, 335, 100);
$loadgraphm = loadgraphWin ($device[hostname] . "-load.rrd", $device[hostname] . "-load-m.png", $month, $now, 335, 100); if(mysql_result(mysql_query("SELECT count(storage_id) FROM storage WHERE host_id = '" . $device['device_id'] . "'"),0)) {
$usersgraph = usersgraphWin ($device[hostname] . "-sys.rrd", $device[hostname] . "-users.png", $day, $now, 335, 100); echo("<div class=graphhead>Storage</div>");
$usersgraphm = usersgraphWin ($device[hostname] . "-sys.rrd", $device[hostname] . "-users-m.png", $month, $now, 335, 100); $graph_type = "device_hrstorage"; include ("includes/print-device-graph.php");
$procsgraph = procsgraphWin ($device[hostname] . "-sys.rrd", $device[hostname] . "-procs.png", $day, $now, 335, 100); echo("<br />");
$procsgraphm = procsgraphWin ($device[hostname] . "-sys.rrd", $device[hostname] . "-procs-m.png", $month, $now, 335, 100); }
if(mysql_result(mysql_query("SELECT count(*) FROM temperature WHERE temp_host = '" . $device['device_id'] . "'"),0)) {
echo("<div class=graphhead>Temperatures</div>");
$graph_type = "device_temperatures"; include ("includes/print-device-graph.php");
echo("<br />");
}
include("graphs/netstats.inc.php");
include("graphs/uptime.inc.php");
# $memgraph = memgraphWin ($device[hostname] . "-mem.rrd", $device[hostname] . "-mem.png", $day, $now, 335, 100);
# $loadgraph = loadgraphWin ($device[hostname] . "-load.rrd", $device[hostname] . "-load.png", $day, $now, 335, 100);
# $cpugraphm = cpugraphWin ($device[hostname] . "-cpu.rrd", $device[hostname] . "-cpu-m.png", $month, $now, 335, 100);
# $memgraphm = memgraphWin ($device[hostname] . "-mem.rrd", $device[hostname] . "-mem-m.png", $month, $now, 335, 100);
# $loadgraphm = loadgraphWin ($device[hostname] . "-load.rrd", $device[hostname] . "-load-m.png", $month, $now, 335, 100);
# $usersgraph = usersgraphWin ($device[hostname] . "-sys.rrd", $device[hostname] . "-users.png", $day, $now, 335, 100);
# $usersgraphm = usersgraphWin ($device[hostname] . "-sys.rrd", $device[hostname] . "-users-m.png", $month, $now, 335, 100);
# $procsgraph = procsgraphWin ($device[hostname] . "-sys.rrd", $device[hostname] . "-procs.png", $day, $now, 335, 100);
# $procsgraphm = procsgraphWin ($device[hostname] . "-sys.rrd", $device[hostname] . "-procs-m.png", $month, $now, 335, 100);
break; break;
case "FreeBSD": case "FreeBSD":
case "NetBSD": case "NetBSD":
@@ -124,7 +147,7 @@ while($device = mysql_fetch_array($device_query)) {
if(mysql_result(mysql_query("SELECT count(storage_id) FROM storage WHERE host_id = '" . $device['device_id'] . "'"),0)) { if(mysql_result(mysql_query("SELECT count(storage_id) FROM storage WHERE host_id = '" . $device['device_id'] . "'"),0)) {
echo("<div class=graphhead>Storage</div>"); echo("<div class=graphhead>Storage</div>");
$graph_type = "device_unixfs"; include ("includes/print-device-graph.php"); $graph_type = "device_hrstorage"; include ("includes/print-device-graph.php");
echo("<br />"); echo("<br />");
} }
@@ -141,10 +164,10 @@ while($device = mysql_fetch_array($device_query)) {
$graph_type = "device_load"; include ("includes/print-device-graph.php"); $graph_type = "device_load"; include ("includes/print-device-graph.php");
echo("<br />"); echo("<br />");
echo("<div class=graphhead>Users Logged On</div>"); echo("<div class=graphhead>Users Logged On</div>");
$graph_type = "device_users"; include ("includes/print-device-graph.php"); $graph_type = "device_hrusers"; include ("includes/print-device-graph.php");
echo("<br />"); echo("<br />");
echo("<div class=graphhead>Running Processes</div>"); echo("<div class=graphhead>Running Processes</div>");
$graph_type = "device_processes"; include ("includes/print-device-graph.php"); $graph_type = "device_hrprocesses"; include ("includes/print-device-graph.php");
echo("<br />"); echo("<br />");
break; break;

View File

@@ -3,6 +3,9 @@
echo("<div class=graphhead>IP Statistics</div>"); echo("<div class=graphhead>IP Statistics</div>");
$graph_type = "device_ip"; include ("includes/print-device-graph.php"); $graph_type = "device_ip"; include ("includes/print-device-graph.php");
echo("<br />"); echo("<br />");
echo("<div class=graphhead>IP Fragmented Statistics</div>");
$graph_type = "device_ip_fragmented"; include ("includes/print-device-graph.php");
echo("<br />");
echo("<div class=graphhead>TCP Statistics</div>"); echo("<div class=graphhead>TCP Statistics</div>");
$graph_type = "device_tcp"; include ("includes/print-device-graph.php"); $graph_type = "device_tcp"; include ("includes/print-device-graph.php");
echo("<br />"); echo("<br />");
@@ -12,6 +15,9 @@
echo("<div class=graphhead>ICMP Statistics</div>"); echo("<div class=graphhead>ICMP Statistics</div>");
$graph_type = "device_icmp"; include ("includes/print-device-graph.php"); $graph_type = "device_icmp"; include ("includes/print-device-graph.php");
echo("<br />"); echo("<br />");
echo("<div class=graphhead>ICMP Informational Statistics</div>");
$graph_type = "device_icmp_informational"; include ("includes/print-device-graph.php");
echo("<br />");
?> ?>

View File

@@ -1,5 +1,4 @@
<?php <?php
#include("group-collectd.inc.php");
?> ?>

View File

@@ -29,7 +29,7 @@ while($drive = mysql_fetch_array($query)) {
$fs_url = "?page=device&id=".$device['device_id']."&section=dev-storage"; $fs_url = "?page=device&id=".$device['device_id']."&section=dev-storage";
$fs_popup = "onmouseover=\"return overlib('<div class=list-large>".$device['hostname']." - ".$drive['hrStorageDescr']; $fs_popup = "onmouseover=\"return overlib('<div class=list-large>".$device['hostname']." - ".$drive['hrStorageDescr'];
$fs_popup .= "</div><img src=\'graph.php?id=" . $drive['storage_id'] . "&type=unixfs&from=$month&to=$now&width=400&height=125\'>"; $fs_popup .= "</div><img src=\'graph.php?id=" . $drive['storage_id'] . "&type=hrstorage&from=$month&to=$now&width=400&height=125\'>";
$fs_popup .= "', RIGHT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\""; $fs_popup .= "', RIGHT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\"";
$drv_colour = percent_colour($perc); $drv_colour = percent_colour($perc);
@@ -39,7 +39,7 @@ while($drive = mysql_fetch_array($query)) {
</td><td style='font-weight: bold; color: $drv_colour'>" . $perc . "%</td><td>" . $total . "</td><td>" . $used . "</td><td></td></tr>"); </td><td style='font-weight: bold; color: $drv_colour'>" . $perc . "%</td><td>" . $total . "</td><td>" . $used . "</td><td></td></tr>");
$graph_type = "unixfs"; $graph_type = "hrstorage";
// start temperature graphs // start temperature graphs
@@ -73,7 +73,6 @@ while($drive = mysql_fetch_array($query)) {
} }
echo("</table>"); echo("</table>");
?> ?>

View File

@@ -118,10 +118,10 @@ echo("<a onmouseover=\"return overlib('<img src=\'graph.php?type=bits&if=36".
echo("<div style='clear: both; margin-top: 10px;'></div>"); echo("<div style='clear: both; margin-top: 10px;'></div>");
echo("<a onmouseover=\"return overlib('<img src=\'graph.php?type=unixfs&id=54". echo("<a onmouseover=\"return overlib('<img src=\'graph.php?type=hrstorage&id=54".
"&from=".$day."&to=".$now."&width=400&height=150\'>', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >". "&from=".$day."&to=".$now."&width=400&height=150\'>', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >".
"<div style='font-size: 18px; font-weight: bold;'>Alpha Storage</div>". "<div style='font-size: 18px; font-weight: bold;'>Alpha Storage</div>".
"<img src='graph.php?type=unixfs&id=54". "<img src='graph.php?type=hrstorage&id=54".
"&from=".$day."&to=".$now."&width=200&height=100'></a>"); "&from=".$day."&to=".$now."&width=200&height=100'></a>");
#} #}

View File

@@ -1,4 +1,4 @@
<?php \<?php
if($_SESSION['userlevel'] >= '5') { if($_SESSION['userlevel'] >= '5') {
$sql = "SELECT * FROM `storage` AS S, `devices` AS D WHERE S.host_id = D.device_id ORDER BY D.hostname, S.hrStorageDescr"; $sql = "SELECT * FROM `storage` AS S, `devices` AS D WHERE S.host_id = D.device_id ORDER BY D.hostname, S.hrStorageDescr";
@@ -33,7 +33,7 @@ while($drive = mysql_fetch_array($query)) {
$total = formatStorage($total); $total = formatStorage($total);
$used = formatStorage($used); $used = formatStorage($used);
$store_url = "graph.php?id=" . $drive['storage_id'] . "&type=unixfs&from=$month&to=$now&width=400&height=125"; $store_url = "graph.php?id=" . $drive['storage_id'] . "&type=hrstorage&from=$month&to=$now&width=400&height=125";
$store_popup = "onmouseover=\"return overlib('<img src=\'$store_url\'>', LEFT);\" onmouseout=\"return nd();\""; $store_popup = "onmouseover=\"return overlib('<img src=\'$store_url\'>', LEFT);\" onmouseout=\"return nd();\"";
$drv_colour = percent_colour($perc); $drv_colour = percent_colour($perc);

View File

@@ -2,7 +2,7 @@
unset( $storage_exists ); unset( $storage_exists );
echo("Storage : "); echo("hrStorage : ");
$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'] . " -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));
@@ -17,14 +17,11 @@
$allow = 1; $allow = 1;
foreach($config['ignore_mount'] as $bi) { foreach($config['ignore_mount'] as $bi) {
# echo("$descr == $bi\n");
if($descr == $bi) { if($descr == $bi) {
$allow = 0; $allow = 0;
} }
} }
# echo("$fstype\n");
if(strstr($fstype, "FixedDisk") && $size > '0' && $allow) { if(strstr($fstype, "FixedDisk") && $size > '0' && $allow) {
if(mysql_result(mysql_query("SELECT count(storage_id) FROM `storage` WHERE hrStorageIndex = '$hrStorageIndex' AND host_id = '".$device['device_id']."'"),0) == '0') { if(mysql_result(mysql_query("SELECT count(storage_id) FROM `storage` WHERE hrStorageIndex = '$hrStorageIndex' AND host_id = '".$device['device_id']."'"),0) == '0') {
$query = "INSERT INTO storage (`host_id`, `hrStorageIndex`, `hrStorageDescr`,`hrStorageSize`,`hrStorageAllocationUnits`) "; $query = "INSERT INTO storage (`host_id`, `hrStorageIndex`, `hrStorageDescr`,`hrStorageSize`,`hrStorageAllocationUnits`) ";
@@ -49,22 +46,17 @@ $sql = "SELECT * FROM storage AS S, devices AS D where S.host_id = D.device_id A
$query = mysql_query($sql); $query = mysql_query($sql);
while ($store = mysql_fetch_array($query)) { while ($store = mysql_fetch_array($query)) {
unset($exists); unset($exists);
$i = 0; $i = 0;
while ($i < count($storage_exists) && !$exists) { while ($i < count($storage_exists) && !$exists) {
$thisstore = $store['host_id'] . " " . $store['hrStorageIndex']; $thisstore = $store['host_id'] . " " . $store['hrStorageIndex'];
if ($storage_exists[$i] == $thisstore) { $exists = 1; } if ($storage_exists[$i] == $thisstore) { $exists = 1; }
$i++; $i++;
} }
if(!$exists) { if(!$exists) {
echo("-"); echo("-");
mysql_query("DELETE FROM storage WHERE storage_id = '" . $store['storage_id'] . "'"); mysql_query("DELETE FROM storage WHERE storage_id = '" . $store['storage_id'] . "'");
} }
} }
echo("\n"); echo("\n");

View File

@@ -91,9 +91,16 @@ function shorthost($hostname, $len=16) {
function rrdtool_update($rrdfile, $rrdupdate) { function rrdtool_update($rrdfile, $rrdupdate) {
global $config; global $config;
echo($config['rrdtool'] . " update $rrdfile $rrdupdate \n");
return shell_exec($config['rrdtool'] . " update $rrdfile $rrdupdate"); return shell_exec($config['rrdtool'] . " update $rrdfile $rrdupdate");
} }
function rrdtool($command, $file, $options) {
global $config;
if($config['debug']) { echo($config['rrdtool'] . " $command $file $options \n"); }
return shell_exec($config['rrdtool'] . " $command $file $options");
}
function getHostOS($hostname, $community, $snmpver, $port) { function getHostOS($hostname, $community, $snmpver, $port) {
global $config; global $config;
@@ -155,8 +162,7 @@ function devicepermitted($device_id)
} }
function formatRates($rate) function formatRates($rate) {
{
$rate = format_si($rate) . "bps"; $rate = format_si($rate) . "bps";
return $rate; return $rate;
} }
@@ -331,7 +337,6 @@ $data = mysql_fetch_array(mysql_query($sql));
$type = strtolower($data['os']); $type = strtolower($data['os']);
if(file_exists($config['html_dir'] . "/images/os/$type" . ".png")){ $image = "<img src='".$config['base_url']."/images/os/$type.png'>"; if(file_exists($config['html_dir'] . "/images/os/$type" . ".png")){ $image = "<img src='".$config['base_url']."/images/os/$type.png'>";
} elseif(file_exists($config['html_dir'] . "/images/os/$type" . ".gif")){ $image = "<img src='".$config['base_url']."/images/os/$type.gif'>"; } } elseif(file_exists($config['html_dir'] . "/images/os/$type" . ".gif")){ $image = "<img src='".$config['base_url']."/images/os/$type.gif'>"; }
if($device['monowall']) {$image = "<img src='".$config['base_url']."images/os/m0n0wall.png'>";}
if($type == "linux") { if($type == "linux") {
$features = strtolower(trim($data[features])); $features = strtolower(trim($data[features]));
list($distro) = split(" ", $features); list($distro) = split(" ", $features);
@@ -342,8 +347,7 @@ $type = strtolower($data['os']);
} }
function renamehost($id, $new) function renamehost($id, $new) {
{
global $config; global $config;
$host = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '$id'"), 0); $host = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '$id'"), 0);
shell_exec("mv ".$config['rrd_dir']."/$host ".$config['rrd_dir']."/$new"); shell_exec("mv ".$config['rrd_dir']."/$host ".$config['rrd_dir']."/$new");
@@ -517,8 +521,7 @@ function isSNMPable($hostname, $community, $snmpver, $port)
return $status; return $status;
} }
function isPingable($hostname) function isPingable($hostname) {
{
global $config; global $config;
$status = shell_exec($config['fping'] . " $hostname"); $status = shell_exec($config['fping'] . " $hostname");
if(strstr($status, "alive")) { if(strstr($status, "alive")) {
@@ -529,13 +532,11 @@ function isPingable($hostname)
} }
function is_odd($number) function is_odd($number) {
{ return $number & 1; // 0 = even, 1 = odd
return $number & 1; // 0 = even, 1 = odd
} }
function isValidInterface($if) function isValidInterface($if) {
{
global $config; global $config;
$if = strtolower($if); $if = strtolower($if);
$nullintf = 0; $nullintf = 0;
@@ -561,8 +562,7 @@ function ifclass($ifOperStatus, $ifAdminStatus)
return $ifclass; return $ifclass;
} }
function utime() function utime() {
{
$time = explode( " ", microtime()); $time = explode( " ", microtime());
$usec = (double)$time[0]; $usec = (double)$time[0];
$sec = (double)$time[1]; $sec = (double)$time[1];

View File

@@ -28,7 +28,7 @@
echo("$hostname\n"); echo("$hostname\n");
if (!is_file($cpurrd)) { if (!is_file($cpurrd)) {
$rrdcreate = `rrdtool create $cpurrd --step 300 \ $rrdcreate = shell_exec($config['rrdtool'] . " create $cpurrd --step 300 \
DS:LOAD5S:GAUGE:600:-1:100 \ DS:LOAD5S:GAUGE:600:-1:100 \
DS:LOAD5M:GAUGE:600:-1:100 \ DS:LOAD5M:GAUGE:600:-1:100 \
RRA:AVERAGE:0.5:1:2000 \ RRA:AVERAGE:0.5:1:2000 \
@@ -38,10 +38,10 @@
RRA:MAX:0.5:1:2000 \ RRA:MAX:0.5:1:2000 \
RRA:MAX:0.5:6:2000 \ RRA:MAX:0.5:6:2000 \
RRA:MAX:0.5:24:2000 \ RRA:MAX:0.5:24:2000 \
RRA:MAX:0.5:288:2000`; RRA:MAX:0.5:288:2000");
} }
`rrdtool update $cpurrd N:$cpu5s:$cpu5m`; shell_exec($config['rrdtool'] . " update $cpurrd N:$cpu5s:$cpu5m");
include("includes/polling/bgpPeer.inc.php"); include("includes/polling/bgpPeer.inc.php");
include("includes/polling/cisco-processors.inc.php"); include("includes/polling/cisco-processors.inc.php");

View File

@@ -3,7 +3,6 @@
$loadrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/load.rrd"; $loadrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/load.rrd";
$cpurrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/cpu.rrd"; $cpurrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/cpu.rrd";
$memrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/mem.rrd"; $memrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/mem.rrd";
$sysrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/sys.rrd";
if ($device['os'] == "FreeBSD") { if ($device['os'] == "FreeBSD") {
$sysDescr = str_replace(" 0 ", " ", $sysDescr); $sysDescr = str_replace(" 0 ", " ", $sysDescr);
@@ -41,70 +40,18 @@ $sysrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/sys.rrd";
} }
## Check Disks
$dq = mysql_query("SELECT * FROM storage WHERE host_id = '" . $device['device_id'] . "'");
while ($dr = mysql_fetch_array($dq)) {
$hrStorageIndex = $dr['hrStorageIndex'];
$hrStorageAllocationUnits = $dr['hrStorageAllocationUnits'];
$hrStorageSize = $dr['hrStorageAllocationUnits'] * $dr['hrStorageSize'];
$hrStorageDescr = $dr['hrStorageDescr'];
$cmd = "snmpget -m HOST-RESOURCES-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " hrStorageUsed.$hrStorageIndex";
$used_units = trim(`$cmd`);
$used = $used_units * $hrStorageAllocationUnits;
$perc = round($used / $hrStorageSize * 100, 2);
$filedesc = str_replace("\"", "", str_replace("/", "_", $hrStorageDescr));
$storage_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/storage-" . $filedesc . ".rrd";
if (!is_file($storage_rrd)) {
shell_exec($config['rrdtool'] . " create $storage_rrd \
--step 300 \
DS:size:GAUGE:600:0:U \
DS:used:GAUGE:600:0:U \
DS:perc: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($storage_rrd, "N:$hrStorageSize:$used:$perc");
mysql_query("UPDATE `storage` SET `hrStorageUsed` = '$used_units', `storage_perc` = '$perc' WHERE storage_id = '" . $dr['storage_id'] . "'");
if($dr['storage_perc'] < '40' && $perc >= '40') {
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
$msg = "Disk Alarm: " . $device['hostname'] . " " . $dr['hrStorageDescr'] . " is " . $perc;
$msg .= " at " . date('l dS F Y h:i:s A');
mail($email, "Disk Alarm: " . $device['hostname'] . " " . $dr['hrStorageDescr'], $msg, $config['email_headers']);
echo("Alerting for " . $device['hostname'] . " " . $dr['hrStorageDescr'] . "/n");
}
}
## Set OIDs ## Set OIDs
$oid_ssCpuRawUser = ".1.3.6.1.4.1.2021.11.50.0"; $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_ssCpuRawNice = ".1.3.6.1.4.1.2021.11.51.0";
$oid_ssCpuRawSystem = ".1.3.6.1.4.1.2021.11.52.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_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";
$oid_ssCpuUser = ".1.3.6.1.4.1.2021.11.9.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"; $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 = $config['snmpget'] ." -m UCD-SNMP-MIB:HOST-RESOURCES-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_cmd .= " $oid_ssCpuRawUser $oid_ssCpuRawSystem $oid_ssCpuRawNice $oid_ssCpuRawIdle $oid_hrSystemProcesses";
$cpu_cmd .= " $oid_hrSystemNumUsers $oid_ssCpuUser $oid_ssCpuSystem";
$cpu = `$cpu_cmd`; $cpu = `$cpu_cmd`;
list ($cpuUser, $cpuSystem, $cpuNice, $cpuIdle, $procs, $users, $UsageUser, $UsageSystem) = explode("\n", $cpu); list ($cpuUser, $cpuSystem, $cpuNice, $cpuIdle, $UsageUser, $UsageSystem) = explode("\n", $cpu);
$cpuUsage = $UsageUser + $UsageSystem; $cpuUsage = $UsageUser + $UsageSystem;
@@ -136,21 +83,6 @@ rrdtool_update($cpurrd, "N:$cpuUser:$cpuSystem:$cpuNice:$cpuIdle");
## If the device isn't monowall or pfsense, monitor all the pretty things ## If the device isn't monowall or pfsense, monitor all the pretty things
if($device[os] != "m0n0wall" && $device[os] != "Voswall" && $device[os] != "pfSense" ) { if($device[os] != "m0n0wall" && $device[os] != "Voswall" && $device[os] != "pfSense" ) {
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)) { if (!is_file($memrrd)) {
shell_exec($config['rrdtool'] . " create $memrrd \ shell_exec($config['rrdtool'] . " create $memrrd \
--step 300 \ --step 300 \
@@ -199,8 +131,8 @@ if($device[os] != "m0n0wall" && $device[os] != "Voswall" && $device[os] != "pfSe
$load_raw = `$load_cmd`; $load_raw = `$load_cmd`;
list ($load1, $load5, $load10) = explode ("\n", $load_raw); list ($load1, $load5, $load10) = explode ("\n", $load_raw);
rrdtool_update($sysrrd, "N:$users:$procs");
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 } // end Non-m0n0wall

View File

@@ -1,19 +1,16 @@
<?php <?php
if(strstr($sysDescr, "x86")) { $hardware = "Generic x86"; } if(strstr($sysDescr, "x86")) { $hardware = "Generic x86"; }
if(strstr($sysDescr, "AMD64")) { $hardware = "Generic x64"; }
if(strstr($sysDescr, "Windows Version 5.2")) { $version = "2003 Server"; } if(strstr($sysDescr, "Windows Version 5.2")) { $version = "2003 Server"; }
if(strstr($sysDescr, "Windows Version 6.1")) { $version = "Windows 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"; }
$hostname = $device['hostname']; $loadrrd = $host_rrd . "/load.rrd";
$hardware = $device['hardware']; $cpurrd = $host_rrd . "/cpu.rrd";
$version = $device['version']; $memrrd = $host_rrd . "/mem.rrd";
$features = $device['features']; $sysrrd = $host_rrd . "/sys.rrd";
$loadrrd = "rrd/" . $hostname . "-load.rrd";
$cpurrd = "rrd/" . $hostname . "-cpu.rrd";
$memrrd = "rrd/" . $hostname . "-mem.rrd";
$sysrrd = "rrd/" . $hostname . "-sys.rrd";
$oid_ssCpuRawUser = ".1.3.6.1.4.1.2021.11.50.0"; $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_ssCpuRawSystem = ".1.3.6.1.4.1.2021.11.51.0";
@@ -22,9 +19,9 @@
$oid_hrSystemProcesses = ".1.3.6.1.2.1.25.1.6.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"; $oid_hrSystemNumUsers = ".1.3.6.1.2.1.25.1.5.0";
$s_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; $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_cmd .= " $oid_ssCpuRawUser $oid_ssCpuRawSystem $oid_ssCpuRawNice $oid_ssCpuRawIdle $oid_hrSystemProcesses $oid_hrSystemNumUsers";
$s = `$s_cmd`; $s = shell_exec($s_cmd);
list ($cpuUser, $cpuSystem, $cpuNice, $cpuIdle, $procs, $users) = explode("\n", $s); list ($cpuUser, $cpuSystem, $cpuNice, $cpuIdle, $procs, $users) = explode("\n", $s);
if (!is_file($cpurrd)) { if (!is_file($cpurrd)) {
@@ -97,13 +94,13 @@
} }
$mem_get = "memTotalSwap.0 memAvailSwap.0 memTotalReal.0 memAvailReal.0 memTotalFree.0 memShared.0 memBuffer.0 memCached.0"; $mem_get = "memTotalSwap.0 memAvailSwap.0 memTotalReal.0 memAvailReal.0 memTotalFree.0 memShared.0 memBuffer.0 memCached.0";
$mem_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $mem_get; $mem_cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $mem_get;
$mem_raw = `$mem_cmd`; $mem_raw = shell_exec($mem_cmd);
list($memTotalSwap, $memAvailSwap, $memTotalReal, $memAvailReal, $memTotalFree, $memShared, $memBuffer, $memCached) = explode("\n", $mem_raw); list($memTotalSwap, $memAvailSwap, $memTotalReal, $memAvailReal, $memTotalFree, $memShared, $memBuffer, $memCached) = explode("\n", $mem_raw);
$load_get = "laLoadInt.1 laLoadInt.2 laLoadInt.3"; $load_get = "laLoadInt.1 laLoadInt.2 laLoadInt.3";
$load_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $load_get; $load_cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $load_get;
$load_raw = `$load_cmd`; $load_raw = shell_exec($load_cmd);
list ($load1, $load5, $load10) = explode ("\n", $load_raw); list ($load1, $load5, $load10) = explode ("\n", $load_raw);
rrdtool_update($sysrrd, "N:$users:$procs"); rrdtool_update($sysrrd, "N:$users:$procs");

View File

@@ -6,7 +6,6 @@ $config['ifdescr']['IOS XE'] = true;
$config['ifname']['ASA'] = true; $config['ifname']['ASA'] = true;
$config['ifname']['CatOS'] = true; $config['ifname']['CatOS'] = true;
## AFI / SAFI pairs for BGP (and other stuff, perhaps) ## AFI / SAFI pairs for BGP (and other stuff, perhaps)
$config['afi']['ipv4']['unicast'] = "IPv4"; $config['afi']['ipv4']['unicast'] = "IPv4";
$config['afi']['ipv4']['multiicast'] = "IPv4 Multicast"; $config['afi']['ipv4']['multiicast'] = "IPv4 Multicast";
@@ -14,6 +13,17 @@ $config['afi']['ipv4']['vpn'] = "VPNv4";
$config['afi']['ipv6']['unicast'] = "IPv6"; $config['afi']['ipv6']['unicast'] = "IPv6";
$config['afi']['ipv6']['multicast'] = "IPv6 Multicast"; $config['afi']['ipv6']['multicast'] = "IPv6 Multicast";
## Set OS Groups
$os_groups['linux'] = "unix";
$os_groups['freebsd'] = "unix";
$os_groups['openbsd'] = "unix";
$os_groups['netbsd'] = "unix";
$os_groups['dragonfly'] = "unix";
$os_groups['solaris'] = "unix";
$os_groups['ios xe'] = "ios";
if(!$config['graph_colours']['greens']) { if(!$config['graph_colours']['greens']) {
$config['graph_colours']['greens'] = array('B6D14B','91B13C','6D912D','48721E','24520F','003300'); $config['graph_colours']['greens'] = array('B6D14B','91B13C','6D912D','48721E','24520F','003300');
} }
@@ -34,7 +44,7 @@ if(!$config['graph_colours']['default']) {
# No changes below this line # # No changes below this line #
############################## ##############################
$config['version'] = "0.6.0"; $config['version'] = "0.7.0";
if($config['enable_nagios']) { if($config['enable_nagios']) {

View File

@@ -6,28 +6,38 @@ include("includes/functions.php");
include("includes/functions-poller.inc.php"); include("includes/functions-poller.inc.php");
$poller_start = utime(); $poller_start = utime();
echo("Observer Poller v".$config['version']."\n\n"); echo("Observer Poller v".$config['version']."\n\n");
$options = getopt("h:t:i:n:d::a::"); $options = getopt("h:t:i:n:d::a::");
if ($options['h'] == "odd") { if ($options['h'] == "odd") {
$where = "AND MOD(device_id,2) = 1"; $where = "AND MOD(device_id,2) = 1"; $doing = $options['h'];
$doing = $options['h'];
} elseif ($options['h'] == "even") { } elseif ($options['h'] == "even") {
$where = "AND MOD(device_id,2) = 0"; $where = "AND MOD(device_id,2) = 0"; $doing = $options['h'];
$doing = $options['h'];
} elseif($options['h']) {
$where = "AND `device_id` = '".$options['h']."'";
$doing = "Host ".$options['h'];
} elseif ($options['i'] && isset($options['n'])) {
$where = "AND MOD(device_id,".$options['i'].") = '" . $options['n'] . "'";
$doing = "Proc ".$options['n'] ."/".$options['i'];
} elseif ($options['h'] == "all") { } elseif ($options['h'] == "all") {
$where = " "; $where = " "; $doing = "all";
$doing = "all"; } elseif($options['h']) {
$where = "AND `device_id` = '".$options['h']."'"; $doing = "Host ".$options['h'];
} elseif ($options['i'] && isset($options['n'])) {
$where = "AND MOD(device_id,".$options['i'].") = '" . $options['n'] . "'"; $doing = "Proc ".$options['n'] ."/".$options['i'];
} }
if(!$where) {
echo("-h <device id> Poll single device\n");
echo("-h odd Poll odd numbered devices (same as -i 2 -n 0)\n");
echo("-h even Poll even numbered devices (same as -i 2 -n 1)\n");
echo("-h all Poll all devices\n\n");
echo("-i <instances> -n <number> Poll as instance <number> of <instances>\n");
echo(" Instances start at 0. 0-3 for -n 4\n\n");
echo("-d Enable some debugging output\n");
echo("\n");
echo("No polling type specified!\n");
exit;
}
if(isset($options['d'])) { echo("DEBUG!\n"); $debug = 1; }
echo("Starting polling run:\n\n"); echo("Starting polling run:\n\n");
$i = 0; $i = 0;
$device_query = mysql_query("SELECT * FROM `devices` WHERE `ignore` = '0' $where ORDER BY `device_id` ASC"); $device_query = mysql_query("SELECT * FROM `devices` WHERE `ignore` = '0' $where ORDER BY `device_id` ASC");
@@ -58,13 +68,8 @@ while ($device = mysql_fetch_array($device_query)) {
if ($snmpable) { if ($snmpable) {
$status = '1'; $status = '1';
if($device['os'] == "FreeBSD" || $device['os'] == "OpenBSD" || $device['os'] == "Linux" || $device['os'] == "Windows" || $device['os'] == "Voswall") { $snmp_cmd = $config['snmpget'] . " -m SNMPv2-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$uptimeoid = ".1.3.6.1.2.1.25.1.1.0"; $snmp_cmd .= " sysUptime.0 sysLocation.0 sysContact.0 sysName.0";
} else {
$uptimeoid = "1.3.6.1.2.1.1.3.0";
}
$snmp_cmd = $config['snmpget'] . " -m SNMPv2-MIB:HOST-RESOURCES-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$snmp_cmd .= " $uptimeoid sysLocation.0 sysContact.0 sysName.0";
#$snmp_cmd .= " | grep -v 'Cisco Internetwork Operating System Software'"; #$snmp_cmd .= " | grep -v 'Cisco Internetwork Operating System Software'";
if($device['os'] == "IOS" || $device['os'] == "IOS XE") { if($device['os'] == "IOS" || $device['os'] == "IOS XE") {
$snmp_cmdb = $config['snmpget'] . " -m ENTITY-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; $snmp_cmdb = $config['snmpget'] . " -m ENTITY-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
@@ -85,7 +90,6 @@ while ($device = mysql_fetch_array($device_query)) {
$sysUptime = str_replace(")", "", $sysUptime); $sysUptime = str_replace(")", "", $sysUptime);
list($days, $hours, $mins, $secs) = explode(":", $sysUptime); list($days, $hours, $mins, $secs) = explode(":", $sysUptime);
list($secs, $microsecs) = explode(".", $secs); list($secs, $microsecs) = explode(".", $secs);
$timeticks = mktime(0, $secs, $mins, $hours, $days, 0);
$hours = $hours + ($days * 24); $hours = $hours + ($days * 24);
$mins = $mins + ($hours * 60); $mins = $mins + ($hours * 60);
$secs = $secs + ($mins * 60); $secs = $secs + ($mins * 60);
@@ -163,16 +167,11 @@ while ($device = mysql_fetch_array($device_query)) {
include("includes/polling/ports-etherlike.inc.php"); include("includes/polling/ports-etherlike.inc.php");
include("includes/polling/cisco-mac-accounting.inc.php"); include("includes/polling/cisco-mac-accounting.inc.php");
$update_uptime_attrib = mysql_query("UPDATE devices_attribs SET attrib_value = NOW() WHERE `device_id` = '" . $device['device_id'] . "' AND `attrib_type` = 'polled'"); $update_uptime_attrib = mysql_query("UPDATE devices_attribs SET attrib_value = NOW() WHERE `device_id` = '" . $device['device_id'] . "' AND `attrib_type` = 'polled'");
if(mysql_affected_rows() == '0') { if(mysql_affected_rows() == '0') {
$insert_uptime_attrib = mysql_query("INSERT INTO devices_attribs (`device_id`, `attrib_type`, `attrib_value`) VALUES ('" . $device['device_id'] . "', 'polled', NOW())"); $insert_uptime_attrib = mysql_query("INSERT INTO devices_attribs (`device_id`, `attrib_type`, `attrib_value`) VALUES ('" . $device['device_id'] . "', 'polled', NOW())");
} }
} else { } else {
$status = '0'; $status = '0';
} }
@@ -292,4 +291,5 @@ $string = $argv[0] . " $doing " . date("F j, Y, G:i") . " - $i devices polled i
echo("$string\n"); echo("$string\n");
shell_exec("echo '".$string."' >> /opt/observer/observer.log"); shell_exec("echo '".$string."' >> /opt/observer/observer.log");
?> ?>