From 975c3a2a931b71b80f7c8d604dfc915ff35ac55f Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Sat, 7 Nov 2009 02:30:38 +0000 Subject: [PATCH] updates et al git-svn-id: http://www.observium.org/svn/observer/trunk@503 61d68cd4-352d-0410-923a-c4978735b2b8 --- discovery.php | 61 +++++----- html/graph.php | 11 +- html/includes/graphs/bgp_updates.inc.php | 2 + html/includes/graphs/cbgp_prefixes.inc.php | 4 + html/includes/graphs/device_cpu.inc.php | 5 - ...ses.inc.php => device_hrprocesses.inc.php} | 2 +- ...nixfs.inc.php => device_hrstorage.inc.php} | 5 +- ...e_users.inc.php => device_hrusers.inc.php} | 2 +- .../graphs/device_icmp_informational.inc.php | 104 ++++++++++-------- ...g.inc.php => device_ip_fragmented.inc.php} | 49 ++++++--- html/includes/graphs/device_load_unix.inc.php | 44 ++++---- html/includes/graphs/device_memory.inc.php | 5 - .../includes/graphs/device_memory_ios.inc.php | 18 +-- html/includes/graphs/device_uptime.inc.php | 10 +- .../{unixfs.inc.php => hrstorage.inc.php} | 2 +- html/pages/device/graphs.inc.php | 47 ++++++-- html/pages/device/graphs/netstats.inc.php | 6 + html/pages/device/graphs/os-unix.inc.php | 1 - html/pages/device/health/storage.inc.php | 7 +- html/pages/front/demo.php | 4 +- html/pages/storage.php | 4 +- includes/discovery/storage.php | 10 +- includes/functions.php | 28 ++--- includes/polling/device-ios.inc.php | 6 +- includes/polling/device-unix.inc.php | 76 +------------ includes/polling/device-windows.inc.php | 27 ++--- includes/static-config.php | 14 ++- poll-device.php | 52 ++++----- 28 files changed, 303 insertions(+), 303 deletions(-) rename html/includes/graphs/{device_processes.inc.php => device_hrprocesses.inc.php} (87%) rename html/includes/graphs/{device_unixfs.inc.php => device_hrstorage.inc.php} (90%) rename html/includes/graphs/{device_users.inc.php => device_hrusers.inc.php} (89%) rename html/includes/graphs/{device_ipfrag.inc.php => device_ip_fragmented.inc.php} (56%) rename html/includes/graphs/{unixfs.inc.php => hrstorage.inc.php} (93%) diff --git a/discovery.php b/discovery.php index 10fb3bb29b..98ad3fc28b 100755 --- a/discovery.php +++ b/discovery.php @@ -10,30 +10,34 @@ $start = utime(); echo("Observer v".$config['version']." Discovery\n\n"); -if($argv[1] == "--device" && $argv[2]) { - $where = "AND `device_id` = '".$argv[2]."'"; -} elseif ($argv[1] == "--os") { - $where = "AND `os` = '".$argv[2]."'"; -} elseif ($argv[1] == "--odd") { - $where = "AND MOD(device_id,2) = 1"; -} elseif ($argv[1] == "--even") { - $where = "AND MOD(device_id,2) = 0"; -} elseif ($argv[1] == "--all") { - $where = ""; -} elseif ($argv[1] == "--forced") { - echo("Doing forced discoveries\n"); - $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'])); - } - exit; -} else { - echo("--device Poll single device\n"); - echo("--os Poll all devices of a given OS\n"); - echo("--all Poll all devices\n\n"); +$options = getopt("h:t:i:n:d::a::"); + +if ($options['h'] == "odd") { + $where = "AND MOD(device_id,2) = 1"; $doing = $options['h']; +} elseif ($options['h'] == "even") { + $where = "AND MOD(device_id,2) = 0"; $doing = $options['h']; +} elseif ($options['h'] == "all") { + $where = " "; $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 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 -n Poll as instance of \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; } $devices_discovered = 0; @@ -55,17 +59,12 @@ while ($device = mysql_fetch_array($device_query)) { ## Discover Temperatures include("includes/discovery/temperatures.php"); - if($device['os'] == "Linux" || $device['os'] == "FreeBSD") { - include("includes/discovery/storage.php"); - } + ## Discover Storage + 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") { diff --git a/html/graph.php b/html/graph.php index 5f3243ca9f..5298e8403a 100644 --- a/html/graph.php +++ b/html/graph.php @@ -41,10 +41,17 @@ if($_GET['debug']) { $graphfile = $config['temp_dir'] . "/" . strgen() . ".png"; $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")) { - include($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")) { + /// 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")) { + /// Type Specific include($config['install_dir'] . "/html/includes/graphs/$type.inc.php"); } diff --git a/html/includes/graphs/bgp_updates.inc.php b/html/includes/graphs/bgp_updates.inc.php index 56c5fa71f5..d05da86134 100644 --- a/html/includes/graphs/bgp_updates.inc.php +++ b/html/includes/graphs/bgp_updates.inc.php @@ -1,5 +1,7 @@ diff --git a/html/includes/graphs/device_processes.inc.php b/html/includes/graphs/device_hrprocesses.inc.php similarity index 87% rename from html/includes/graphs/device_processes.inc.php rename to html/includes/graphs/device_hrprocesses.inc.php index 21452085c9..f75d96fae1 100644 --- a/html/includes/graphs/device_processes.inc.php +++ b/html/includes/graphs/device_hrprocesses.inc.php @@ -4,7 +4,7 @@ $scale_min = "0"; 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 .= " COMMENT:Processes\ \ \ \ Cur\ \ \ \ \ Ave\ \ \ \ \ \ Min\ \ \ \ \ Max\\\\n"; diff --git a/html/includes/graphs/device_unixfs.inc.php b/html/includes/graphs/device_hrstorage.inc.php similarity index 90% rename from html/includes/graphs/device_unixfs.inc.php rename to html/includes/graphs/device_hrstorage.inc.php index 93fbf9406c..3ec0b5cecf 100644 --- a/html/includes/graphs/device_unixfs.inc.php +++ b/html/includes/graphs/device_hrstorage.inc.php @@ -1,5 +1,8 @@ diff --git a/html/includes/graphs/device_ipfrag.inc.php b/html/includes/graphs/device_ip_fragmented.inc.php similarity index 56% rename from html/includes/graphs/device_ipfrag.inc.php rename to html/includes/graphs/device_ip_fragmented.inc.php index 4032d7f7cc..8bc1d9cced 100644 --- a/html/includes/graphs/device_ipfrag.inc.php +++ b/html/includes/graphs/device_ip_fragmented.inc.php @@ -30,22 +30,37 @@ $rrd_options .= " CDEF:MReasmFails=MipReasmFails,ipInDelivers,/,100,*"; $rrd_options .= " CDEF:MFragOKs=MipFragOKs,ipInDelivers,/,100,*"; $rrd_options .= " CDEF:MFragFails=MipFragFails,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 .= " LINE1:ReasmOKs#0033aa:'Reassembly OK'"; -$rrd_options .= " LINE2:ReasmFails#000000:'Reassembly Fail'"; -$rrd_options .= " GPRINT:ReasmReqds:AVERAGE:Avg\ ReasmReqd\ %1.2lf\ %%"; -$rrd_options .= " GPRINT:MReasmReqds:MAX:Max\ ReasmReqd\ %1.2lf\ %%"; -$rrd_options .= " GPRINT:ReasmOKs:AVERAGE:Avg\ ReasmOK\ %1.2lf\ %%"; -$rrd_options .= " GPRINT:MReasmOKs:MAX:Max\ ReasmOK\ %1.2lf\ %%"; -$rrd_options .= " GPRINT:ReasmFails:AVERAGE:Avg\ ReasmFail\ %1.2lf\ %%"; -$rrd_options .= " GPRINT:MReasmFails:MAX:Max\ ReasmFail\ %1.2lf\ %%"; -$rrd_options .= " GPRINT:FragOKs:AVERAGE:Avg\ FragOK\ %1.2lf\ %%"; -$rrd_options .= " GPRINT:MFragOKs:MAX:Max\ FragOK\ %1.2lf\ %%"; -$rrd_options .= " GPRINT:FragFails:AVERAGE:Avg\ FragFail\ %1.2lf\ %%"; -$rrd_options .= " GPRINT:MFragFails:MAX:Max\ FragFail\ %1.2lf\ %%"; -$rrd_options .= " GPRINT:FragCreates:AVERAGE:Avg\ FragCreate\ %1.2lf\ %%"; -$rrd_options .= " GPRINT:MFragCreates:MAX:Max\ FragCreate\ %1.2lf\ %%"; -$rrd_options .= " COMMENT:' Calculated as a % of ipInDelivers'" + +$rrd_options .= " COMMENT:'% ipInDelivers Current Average Maximum\\n'"; + +$rrd_options .= " LINE1.25:FragOKs#00cc00:'Frag OK '"; +$rrd_options .= " GPRINT:FragOKs:LAST:%6.2lf%s"; +$rrd_options .= " GPRINT:FragOKs:AVERAGE:%6.2lf%s"; +$rrd_options .= " GPRINT:MFragOKs:MAX:%6.2lf%s\\\\n"; + +$rrd_options .= " LINE1.25:FragFails#cc0000:'Frag Fail '"; +$rrd_options .= " GPRINT:FragFails:LAST:%6.2lf%s"; +$rrd_options .= " GPRINT:FragFails:AVERAGE:%6.2lf%s"; +$rrd_options .= " GPRINT:MFragFails:MAX:%6.2lf%s\\\\n"; + +$rrd_options .= " LINE1.25:ReasmOKs#006600:'Reasm OK '"; +$rrd_options .= " GPRINT:ReasmOKs:LAST:%6.2lf%s"; +$rrd_options .= " GPRINT:ReasmOKs:AVERAGE:%6.2lf%s"; +$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"; ?> diff --git a/html/includes/graphs/device_load_unix.inc.php b/html/includes/graphs/device_load_unix.inc.php index 7b9e64dbf1..d764b7bb1b 100644 --- a/html/includes/graphs/device_load_unix.inc.php +++ b/html/includes/graphs/device_load_unix.inc.php @@ -2,29 +2,29 @@ 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"; - $options .= " DEF:5min=$rrd_filename:5min:AVERAGE"; - $options .= " DEF:15min=$rrd_filename:15min:AVERAGE"; - $options .= " CDEF:a=1min,100,/"; - $options .= " CDEF:b=5min,100,/"; - $options .= " CDEF:c=15min,100,/"; - $options .= " CDEF:cdefd=a,b,c,+,+"; - $options .= " COMMENT:Load\ Average\ \ Current\ \ \ \ Average\ \ \ \ Maximum\\\\n"; - $options .= " AREA:a#ffeeaa:1\ Min:"; - $options .= " LINE1:a#c5aa00:"; - $options .= " GPRINT:a:LAST:\ \ \ \ %7.2lf"; - $options .= " GPRINT:a:AVERAGE:\ \ %7.2lf"; - $options .= " GPRINT:a:MAX:\ \ %7.2lf\\\\n"; - $options .= " LINE1.25:b#ea8f00:5\ Min:"; - $options .= " GPRINT:b:LAST:\ \ \ \ %7.2lf"; - $options .= " GPRINT:b:AVERAGE:\ \ %7.2lf"; - $options .= " GPRINT:b:MAX:\ \ %7.2lf\\\\n"; - $options .= " LINE1.25:c#cc0000:15\ Min"; - $options .= " GPRINT:c:LAST:\ \ \ %7.2lf"; - $options .= " GPRINT:c:AVERAGE:\ \ %7.2lf"; - $options .= " GPRINT:c:MAX:\ \ %7.2lf\\\\n"; + $rrd_options .= " DEF:1min=$rrd_filename:1min:AVERAGE"; + $rrd_options .= " DEF:5min=$rrd_filename:5min:AVERAGE"; + $rrd_options .= " DEF:15min=$rrd_filename:15min:AVERAGE"; + $rrd_options .= " CDEF:a=1min,100,/"; + $rrd_options .= " CDEF:b=5min,100,/"; + $rrd_options .= " CDEF:c=15min,100,/"; + $rrd_options .= " CDEF:cdefd=a,b,c,+,+"; + $rrd_options .= " COMMENT:Load\ Average\ \ Current\ \ \ \ Average\ \ \ \ Maximum\\\\n"; + $rrd_options .= " AREA:a#ffeeaa:1\ Min:"; + $rrd_options .= " LINE1:a#c5aa00:"; + $rrd_options .= " GPRINT:a:LAST:\ \ \ \ %7.2lf"; + $rrd_options .= " GPRINT:a:AVERAGE:\ \ %7.2lf"; + $rrd_options .= " GPRINT:a:MAX:\ \ %7.2lf\\\\n"; + $rrd_options .= " LINE1.25:b#ea8f00:5\ Min:"; + $rrd_options .= " GPRINT:b:LAST:\ \ \ \ %7.2lf"; + $rrd_options .= " GPRINT:b:AVERAGE:\ \ %7.2lf"; + $rrd_options .= " GPRINT:b:MAX:\ \ %7.2lf\\\\n"; + $rrd_options .= " LINE1.25:c#cc0000:15\ Min"; + $rrd_options .= " GPRINT:c:LAST:\ \ \ %7.2lf"; + $rrd_options .= " GPRINT:c:AVERAGE:\ \ %7.2lf"; + $rrd_options .= " GPRINT:c:MAX:\ \ %7.2lf\\\\n"; ?> diff --git a/html/includes/graphs/device_memory.inc.php b/html/includes/graphs/device_memory.inc.php index ae844f7d38..6eff33c4ec 100644 --- a/html/includes/graphs/device_memory.inc.php +++ b/html/includes/graphs/device_memory.inc.php @@ -1,9 +1,4 @@ diff --git a/html/includes/graphs/device_memory_ios.inc.php b/html/includes/graphs/device_memory_ios.inc.php index f1cac1a6da..e5a874a336 100644 --- a/html/includes/graphs/device_memory_ios.inc.php +++ b/html/includes/graphs/device_memory_ios.inc.php @@ -5,7 +5,7 @@ include("common.inc.php"); $rrd_options .= " -l 0 -E -b 1024 -u 100 -r"; $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'"); 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("Switching Processor", "SP", $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'] = substr($mempool['descr_fixed'],0,28); + $mempool['descr_fixed'] = str_pad($mempool['descr_fixed'], 20); + $mempool['descr_fixed'] = substr($mempool['descr_fixed'],0,20); $oid = $mempool['entPhysicalIndex'] . "." . $mempool['Index']; $rrd = $config['rrd_dir'] . "/$hostname/cempMemPool-$oid.rrd"; - $rrd_options .= " DEF:mempool" . $iter . "free=$rrd:free:AVERAGE "; - $rrd_options .= " DEF:mempool" . $iter . "used=$rrd:used:AVERAGE "; + $rrd_options .= " DEF:mempool" . $iter . "free=$rrd:free: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 .= " LINE1:mempool" . $iter . "total#" . $colour . ":'" . $mempool['descr_fixed'] . "' "; - $rrd_options .= " GPRINT:mempool" . $iter . "total:LAST:%3.0lf"; - $rrd_options .= " GPRINT:mempool" . $iter . "total:MAX:%3.0lf\\\l "; + $rrd_options .= " GPRINT:mempool" . $iter . "used:LAST:%6.2lf%s"; + $rrd_options .= " GPRINT:mempool" . $iter . "total:LAST:%3.0lf%%"; + $rrd_options .= " GPRINT:mempool" . $iter . "total:MAX:%3.0lf%%\\\\n"; $iter++; } diff --git a/html/includes/graphs/device_uptime.inc.php b/html/includes/graphs/device_uptime.inc.php index 8e9ce90e4b..3b72792152 100644 --- a/html/includes/graphs/device_uptime.inc.php +++ b/html/includes/graphs/device_uptime.inc.php @@ -1,8 +1,14 @@ diff --git a/html/includes/graphs/unixfs.inc.php b/html/includes/graphs/hrstorage.inc.php similarity index 93% rename from html/includes/graphs/unixfs.inc.php rename to html/includes/graphs/hrstorage.inc.php index 84e79ac56f..8827b4e0e9 100644 --- a/html/includes/graphs/unixfs.inc.php +++ b/html/includes/graphs/hrstorage.inc.php @@ -17,7 +17,7 @@ $rrd_options .= " -b 1024"; $descr = str_pad($fs[hrStorageDescr], 12); $descr = substr($descr,0,12); $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]s=$rrd:size:AVERAGE"; $rrd_options .= " DEF:$fs[storage_id]p=$rrd:perc:AVERAGE"; diff --git a/html/pages/device/graphs.inc.php b/html/pages/device/graphs.inc.php index 0b3426c04b..342db7e964 100644 --- a/html/pages/device/graphs.inc.php +++ b/html/pages/device/graphs.inc.php @@ -84,18 +84,41 @@ while($device = mysql_fetch_array($device_query)) { break; case "Windows": + + echo("
CPU Usage
"); $graph_type = "device_cpu"; include ("includes/print-device-graph.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); + echo("
Memory Utilisation
"); + $graph_type = "device_memory"; include ("includes/print-device-graph.php"); + echo("
"); + + if(mysql_result(mysql_query("SELECT count(storage_id) FROM storage WHERE host_id = '" . $device['device_id'] . "'"),0)) { + echo("
Storage
"); + $graph_type = "device_hrstorage"; include ("includes/print-device-graph.php"); + echo("
"); + } + + if(mysql_result(mysql_query("SELECT count(*) FROM temperature WHERE temp_host = '" . $device['device_id'] . "'"),0)) { + echo("
Temperatures
"); + $graph_type = "device_temperatures"; include ("includes/print-device-graph.php"); + echo("
"); + } + + 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; case "FreeBSD": 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)) { echo("
Storage
"); - $graph_type = "device_unixfs"; include ("includes/print-device-graph.php"); + $graph_type = "device_hrstorage"; include ("includes/print-device-graph.php"); echo("
"); } @@ -141,10 +164,10 @@ while($device = mysql_fetch_array($device_query)) { $graph_type = "device_load"; include ("includes/print-device-graph.php"); echo("
"); echo("
Users Logged On
"); - $graph_type = "device_users"; include ("includes/print-device-graph.php"); + $graph_type = "device_hrusers"; include ("includes/print-device-graph.php"); echo("
"); echo("
Running Processes
"); - $graph_type = "device_processes"; include ("includes/print-device-graph.php"); + $graph_type = "device_hrprocesses"; include ("includes/print-device-graph.php"); echo("
"); break; diff --git a/html/pages/device/graphs/netstats.inc.php b/html/pages/device/graphs/netstats.inc.php index c73392ddce..564ff88de6 100644 --- a/html/pages/device/graphs/netstats.inc.php +++ b/html/pages/device/graphs/netstats.inc.php @@ -3,6 +3,9 @@ echo("
IP Statistics
"); $graph_type = "device_ip"; include ("includes/print-device-graph.php"); echo("
"); + echo("
IP Fragmented Statistics
"); + $graph_type = "device_ip_fragmented"; include ("includes/print-device-graph.php"); + echo("
"); echo("
TCP Statistics
"); $graph_type = "device_tcp"; include ("includes/print-device-graph.php"); echo("
"); @@ -12,6 +15,9 @@ echo("
ICMP Statistics
"); $graph_type = "device_icmp"; include ("includes/print-device-graph.php"); echo("
"); + echo("
ICMP Informational Statistics
"); + $graph_type = "device_icmp_informational"; include ("includes/print-device-graph.php"); + echo("
"); ?> diff --git a/html/pages/device/graphs/os-unix.inc.php b/html/pages/device/graphs/os-unix.inc.php index 2fb76b0344..6eff33c4ec 100644 --- a/html/pages/device/graphs/os-unix.inc.php +++ b/html/pages/device/graphs/os-unix.inc.php @@ -1,5 +1,4 @@ diff --git a/html/pages/device/health/storage.inc.php b/html/pages/device/health/storage.inc.php index 3b2b675987..a6dae830a0 100644 --- a/html/pages/device/health/storage.inc.php +++ b/html/pages/device/health/storage.inc.php @@ -29,7 +29,7 @@ while($drive = mysql_fetch_array($query)) { $fs_url = "?page=device&id=".$device['device_id']."§ion=dev-storage"; $fs_popup = "onmouseover=\"return overlib('
".$device['hostname']." - ".$drive['hrStorageDescr']; - $fs_popup .= "
"; + $fs_popup .= ""; $fs_popup .= "', RIGHT, FGCOLOR, '#e5e5e5');\" onmouseout=\"return nd();\""; $drv_colour = percent_colour($perc); @@ -39,7 +39,7 @@ while($drive = mysql_fetch_array($query)) { " . $perc . "%" . $total . "" . $used . ""); - $graph_type = "unixfs"; + $graph_type = "hrstorage"; // start temperature graphs @@ -73,7 +73,6 @@ while($drive = mysql_fetch_array($query)) { } -echo(""); - + echo(""); ?> diff --git a/html/pages/front/demo.php b/html/pages/front/demo.php index 405cb2589d..8e23dc00cf 100644 --- a/html/pages/front/demo.php +++ b/html/pages/front/demo.php @@ -118,10 +118,10 @@ echo(""); -echo("', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 250);\" onmouseout=\"return nd();\" >". "
Alpha Storage
". - "
"); #} diff --git a/html/pages/storage.php b/html/pages/storage.php index 7486433a2f..5968b5c9ec 100644 --- a/html/pages/storage.php +++ b/html/pages/storage.php @@ -1,4 +1,4 @@ -= '5') { $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); $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('', LEFT);\" onmouseout=\"return nd();\""; $drv_colour = percent_colour($perc); diff --git a/includes/discovery/storage.php b/includes/discovery/storage.php index 483f73635b..89180c161a 100755 --- a/includes/discovery/storage.php +++ b/includes/discovery/storage.php @@ -2,7 +2,7 @@ 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 = trim(str_replace("hrStorageIndex.","",$oids)); @@ -17,14 +17,11 @@ $allow = 1; foreach($config['ignore_mount'] as $bi) { -# echo("$descr == $bi\n"); if($descr == $bi) { $allow = 0; } } -# echo("$fstype\n"); - 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') { $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); while ($store = mysql_fetch_array($query)) { - unset($exists); - $i = 0; while ($i < count($storage_exists) && !$exists) { $thisstore = $store['host_id'] . " " . $store['hrStorageIndex']; if ($storage_exists[$i] == $thisstore) { $exists = 1; } $i++; } - if(!$exists) { echo("-"); mysql_query("DELETE FROM storage WHERE storage_id = '" . $store['storage_id'] . "'"); } - - } echo("\n"); diff --git a/includes/functions.php b/includes/functions.php index 3b6b782359..2a378feec8 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -91,9 +91,16 @@ function shorthost($hostname, $len=16) { function rrdtool_update($rrdfile, $rrdupdate) { global $config; + echo($config['rrdtool'] . " update $rrdfile $rrdupdate \n"); 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) { global $config; @@ -155,8 +162,7 @@ function devicepermitted($device_id) } -function formatRates($rate) -{ +function formatRates($rate) { $rate = format_si($rate) . "bps"; return $rate; } @@ -331,7 +337,6 @@ $data = mysql_fetch_array(mysql_query($sql)); $type = strtolower($data['os']); if(file_exists($config['html_dir'] . "/images/os/$type" . ".png")){ $image = ""; } elseif(file_exists($config['html_dir'] . "/images/os/$type" . ".gif")){ $image = ""; } - if($device['monowall']) {$image = "";} if($type == "linux") { $features = strtolower(trim($data[features])); list($distro) = split(" ", $features); @@ -342,8 +347,7 @@ $type = strtolower($data['os']); } -function renamehost($id, $new) -{ +function renamehost($id, $new) { global $config; $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"); @@ -517,8 +521,7 @@ function isSNMPable($hostname, $community, $snmpver, $port) return $status; } -function isPingable($hostname) -{ +function isPingable($hostname) { global $config; $status = shell_exec($config['fping'] . " $hostname"); if(strstr($status, "alive")) { @@ -529,13 +532,11 @@ function isPingable($hostname) } -function is_odd($number) -{ - return $number & 1; // 0 = even, 1 = odd +function is_odd($number) { + return $number & 1; // 0 = even, 1 = odd } -function isValidInterface($if) -{ +function isValidInterface($if) { global $config; $if = strtolower($if); $nullintf = 0; @@ -561,8 +562,7 @@ function ifclass($ifOperStatus, $ifAdminStatus) return $ifclass; } -function utime() -{ +function utime() { $time = explode( " ", microtime()); $usec = (double)$time[0]; $sec = (double)$time[1]; diff --git a/includes/polling/device-ios.inc.php b/includes/polling/device-ios.inc.php index 2702e1d0f2..90b1a3e20e 100755 --- a/includes/polling/device-ios.inc.php +++ b/includes/polling/device-ios.inc.php @@ -28,7 +28,7 @@ echo("$hostname\n"); 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:LOAD5M:GAUGE:600:-1:100 \ RRA:AVERAGE:0.5:1:2000 \ @@ -38,10 +38,10 @@ RRA:MAX:0.5:1:2000 \ RRA:MAX:0.5:6: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/cisco-processors.inc.php"); diff --git a/includes/polling/device-unix.inc.php b/includes/polling/device-unix.inc.php index b1121cd014..f18d1ca98e 100755 --- a/includes/polling/device-unix.inc.php +++ b/includes/polling/device-unix.inc.php @@ -3,7 +3,6 @@ $loadrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/load.rrd"; $cpurrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/cpu.rrd"; $memrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/mem.rrd"; -$sysrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/sys.rrd"; if ($device['os'] == "FreeBSD") { $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 $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_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_ssCpuSystem = ".1.3.6.1.4.1.2021.11.10.0"; - -$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_hrSystemProcesses"; -$cpu_cmd .= " $oid_hrSystemNumUsers $oid_ssCpuUser $oid_ssCpuSystem"; +$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, $procs, $users, $UsageUser, $UsageSystem) = explode("\n", $cpu); +list ($cpuUser, $cpuSystem, $cpuNice, $cpuIdle, $UsageUser, $UsageSystem) = explode("\n", $cpu); $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($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)) { shell_exec($config['rrdtool'] . " create $memrrd \ --step 300 \ @@ -199,8 +131,8 @@ if($device[os] != "m0n0wall" && $device[os] != "Voswall" && $device[os] != "pfSe $load_raw = `$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"); } // end Non-m0n0wall + diff --git a/includes/polling/device-windows.inc.php b/includes/polling/device-windows.inc.php index d0824dd89a..077202d28c 100755 --- a/includes/polling/device-windows.inc.php +++ b/includes/polling/device-windows.inc.php @@ -1,19 +1,16 @@ 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 -n Poll as instance of \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"); $i = 0; $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) { $status = '1'; - if($device['os'] == "FreeBSD" || $device['os'] == "OpenBSD" || $device['os'] == "Linux" || $device['os'] == "Windows" || $device['os'] == "Voswall") { - $uptimeoid = ".1.3.6.1.2.1.25.1.1.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 = $config['snmpget'] . " -m SNMPv2-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; + $snmp_cmd .= " sysUptime.0 sysLocation.0 sysContact.0 sysName.0"; #$snmp_cmd .= " | grep -v 'Cisco Internetwork Operating System Software'"; 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']; @@ -85,7 +90,6 @@ while ($device = mysql_fetch_array($device_query)) { $sysUptime = str_replace(")", "", $sysUptime); list($days, $hours, $mins, $secs) = explode(":", $sysUptime); list($secs, $microsecs) = explode(".", $secs); - $timeticks = mktime(0, $secs, $mins, $hours, $days, 0); $hours = $hours + ($days * 24); $mins = $mins + ($hours * 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/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'"); 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())"); } - - - } else { $status = '0'; } @@ -292,4 +291,5 @@ $string = $argv[0] . " $doing " . date("F j, Y, G:i") . " - $i devices polled i echo("$string\n"); shell_exec("echo '".$string."' >> /opt/observer/observer.log"); + ?>