From bc6ad69724a5fb2ee90ab90e01aed8e4e13ba4aa Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Thu, 23 Apr 2009 21:13:56 +0000 Subject: [PATCH] a million fixes. half way to 0.6.0! :D git-svn-id: http://www.observium.org/svn/observer/trunk@407 61d68cd4-352d-0410-923a-c4978735b2b8 --- alerts.php | 2 +- cron-minute.sh | 20 +- cron.sh | 9 +- discover-macaccounting.php | 2 +- discovery.php | 1 + html/graph.php | 24 +- html/includes/print-device-graph.php | 10 +- html/includes/print-interface.inc | 53 +-- html/pages/device.php | 61 ++- html/pages/device/graphs.inc.php | 21 +- includes/functions.php | 29 +- includes/graphing.php | 143 +++++- includes/polling/cisco-processors.inc.php | 3 +- includes/polling/device-ios.inc.php | 1 + includes/polling/device-netstats.inc.php | 8 +- includes/polling/device-unix.inc.php | 35 +- includes/polling/interfaces.inc.php | 8 +- includes/static-config.php | 16 +- includes/syslog.php | 6 +- mysql-schema.sql | 515 ++++++++++++---------- poll-device.php | 15 +- poll-ifstatus.php | 10 +- poll-mac_accounting.php | 9 +- poll-reachability.php | 6 +- process-syslog.php | 3 +- update-interface.php | 12 +- 26 files changed, 616 insertions(+), 406 deletions(-) diff --git a/alerts.php b/alerts.php index 48224278e1..62aca44bce 100755 --- a/alerts.php +++ b/alerts.php @@ -18,7 +18,7 @@ while ($alert = mysql_fetch_array($alert_query)) { if($alert_text) { echo("$alert_text"); -# `echo '$alert_text' | gnokii --sendsms 07885729982`; +# `echo '$alert_text' | gnokii --sendsms `; } diff --git a/cron-minute.sh b/cron-minute.sh index a80ac2040f..5c89de2a04 100755 --- a/cron-minute.sh +++ b/cron-minute.sh @@ -1,14 +1,14 @@ #!/bin/bash ./process-syslog.php -sleep 10 -./process-syslog.php & -sleep 10 -./process-syslog.php & -sleep 10 -./process-syslog.php & -sleep 10 -./process-syslog.php & -sleep 10 -./process-syslog.php & +#sleep 10 +#./process-syslog.php & +#sleep 10 +#./process-syslog.php & +#sleep 10 +#./process-syslog.php & +#sleep 10 +#./process-syslog.php & +#sleep 10 +#./process-syslog.php & diff --git a/cron.sh b/cron.sh index 6518b0484c..4ccf89bef2 100755 --- a/cron.sh +++ b/cron.sh @@ -1,10 +1,15 @@ #!/bin/bash #./discovery.php --forced >> /var/log/observer.log -./poll-mac_accounting.php >> /var/log/observer.log & -./discover-bgp_peers.php >> /var/log/observer.log & + ./poll-device.php --odd >> /var/log/observer.log & ./poll-device.php --even >> /var/log/observer.log & + +#./poll-device.php --odd3 >> /var/log/observer.log & +#./poll-device.php --even3 >> /var/log/observer.log & +#./poll-device.php --other3 >> /var/log/observer.log & + +./poll-mac_accounting.php >> /var/log/observer.log ./check-services.php #./alerts.php ./poll-billing.php diff --git a/discover-macaccounting.php b/discover-macaccounting.php index 915f63511b..399503660b 100755 --- a/discover-macaccounting.php +++ b/discover-macaccounting.php @@ -23,7 +23,7 @@ $data = trim(`cat mac-accounting.txt`); foreach( explode("\n", $data) as $peer_entry) { list($interface_ip, $peer_ip, $peer_desc, $peer_asn, $peer_mac, $in_oid, $out_oid) = explode(",", $peer_entry); - $interface_id = mysql_result(mysql_query("SELECT interface_id FROM ipaddr WHERE addr = '$interface_ip'"),0); + $interface_id = mysql_result(mysql_query("SELECT interface_id FROM ipv4_addresses WHERE ipv4_address = '$interface_ip'"),0); $device_id = mysql_result(mysql_query("SELECT device_id FROM interfaces WHERE interface_id = '$interface_id'"),0); echo("PEER : $peer_ip AS$peer_asn ($peer_mac) int: $interface_id host: $device_id \n"); diff --git a/discovery.php b/discovery.php index 007717af02..0d8e57f93c 100755 --- a/discovery.php +++ b/discovery.php @@ -70,6 +70,7 @@ while ($device = mysql_fetch_array($device_query)) { include("includes/discovery/cisco-pw.php"); include("includes/discovery/cisco-vrf.php"); include("includes/discovery/cisco-processors.php"); + include("includes/discovery/cisco-mempool.php"); } echo("\n"); $devices_discovered++; diff --git a/html/graph.php b/html/graph.php index 113ba31423..7fc9ccb448 100644 --- a/html/graph.php +++ b/html/graph.php @@ -1,10 +1,12 @@ ', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> "); diff --git a/html/includes/print-interface.inc b/html/includes/print-interface.inc index ac6c813f91..802cc136d2 100644 --- a/html/includes/print-interface.inc +++ b/html/includes/print-interface.inc @@ -5,41 +5,31 @@ $interface['device_id'] = $device['device_id']; $interface['hostname'] = $device['hostname']; - if(!$graph_type) { $graph_type = "bits"; } - $if_id = $interface['interface_id']; - $ifDescr = fixifName($interface['ifDescr']); - $ifIndex = $interface['ifIndex']; - $ifAlias = $interface['ifAlias']; - $ifSpeed = humanspeed($interface['ifSpeed']); - $ifPhysAddress = $interface['ifPhysAddress']; - $ifType = fixiftype($interface['ifType']); - $ifHardType = $interface['ifHardType']; +# $ifType = fixiftype($interface['ifType']); +# $ifHardType = $interface['ifHardType']; -# if($ifAlias) {$ifAlias = $ifAlias . ;} - #if($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg="#ffffff"; } if($bg == "#e5e5e5") { $bg = "#ffffff"; } else { $bg="#e5e5e5"; } if($interface['in_errors'] > 0 || $interface['out_errors'] > 0) { $error_img = generateiflink($interface,"Interface Errors",errors); } else { $error_img = ""; } -# $graph_url = "graph.php?if=$if_id&from=$twoday&to=$now&width=400&height=120&type=bits"; echo(" "); echo(" - " . generateiflink($interface, "$i. $ifDescr") . " $error_img + " . generateiflink($interface, "$i. ".fixifName($interface['ifDescr'])) . " $error_img -
$ifAlias"); +
".$interface['ifAlias'].""); - if($ifAlias) { echo("
"); } + if($interface['ifAlias']) { echo("
"); } unset ($break); - if(!$dographs) { + if($port_details) { $ipdata = mysql_query("SELECT * FROM `ipv4_addresses` WHERE `interface_id` = '" . $interface['interface_id'] . "'"); while($ip = mysql_fetch_Array($ipdata)) { echo("$break $ip[ipv4_address]/$ip[ipv4_prefixlen]"); @@ -50,7 +40,8 @@ echo("$break ".Net_IPv6::compress($ip6['ipv6_address'])."/".$ip6['ipv6_prefixlen'].""); $break = "
"; } - + } + echo(""); echo(""); @@ -61,23 +52,21 @@ echo(""); if($interface['ifOperStatus'] == "up") { - $in_perc = @round($interface['in_rate']/$interface['ifSpeed']*100); $out_perc = @round($interface['in_rate']/$interface['ifSpeed']*100); - echo(" " . formatRates($interface['in_rate']) . "
"); echo(" " . - formatRates($interface['out_rate']) . ""); - + formatRates($interface['out_rate']) . ""); } - echo(""); - if($ifSpeed && $ifSpeed != "") { echo("$ifSpeed"); } + + echo(""); + if($interface['ifSpeed'] && $interface['ifAlias'] != "") { echo("".humanspeed($interface['ifSpeed']).""); } echo("
"); + # if($interface[ifDuplex] != unknown) { echo("Duplex " . $interface['ifDuplex'] . ""); } else { echo("-"); } if($device['os'] == "IOS" || $device['os'] == "IOS XE") { - if($interface['ifTrunk']) { echo("" . $interface['ifTrunk'] . ""); } elseif ($interface['ifVlan']) { @@ -86,22 +75,22 @@ $vrf = mysql_fetch_array(mysql_query("SELECT * FROM vrfs WHERE vrf_id = '".$interface['ifVrf']."'")); echo("" . $vrf['vrf_name'] . ""); } - } echo(""); - if($ifType && $ifType != "") { echo("" . $ifType . ""); } else { echo("-"); } + if($interface['ifType'] && $interface['ifType'] != "") { echo("" . fixiftype($interface['ifType']) . ""); } else { echo("-"); } echo("
"); if($ifHardType && $ifHardType != "") { echo("" . $ifHardType . ""); } else { echo("-"); } echo(""); if($interface['ifPhysAddress'] && $interface['ifPhysAddress'] != "") { echo("" . $interface['ifPhysAddress'] . ""); } else { echo("-"); } echo("
"); if($interface['ifMtu'] && $interface['ifMtu'] != "") { echo("MTU " . $interface['ifMtu'] . ""); } else { echo("-"); } -} + +#} echo(""); echo(""); - if ( strpos($ifDescr, "oopback") === false && !$dographs) { + if ( strpos($interface['ifDescr'], "oopback") === false && !$graph_type) { $link_query = mysql_query("select * from links AS L, interfaces AS I, devices AS D WHERE L.src_if = '$if_id' AND L.dst_if = I.interface_id AND I.device_id = D.device_id"); while($link = mysql_fetch_array($link_query)) { # echo("Directly Connected " . generateiflink($link, makeshortif($link['ifDescr'])) . " on " . generatedevicelink($link, shorthost($link['hostname'])) . "
"); @@ -112,6 +101,8 @@ echo(""); unset($br); + if($port_details) { ## Show which other devices are on the same subnet as this interface + $sql = "SELECT `ipv4_network_id` FROM `ipv4_addresses` WHERE `interface_id` = '".$interface['interface_id']."' AND `ipv4_address` NOT LIKE '127.%'"; $nets_query = mysql_query($sql); while($net = mysql_fetch_array($nets_query)) { @@ -129,7 +120,6 @@ echo(""); $this_ifname = fixifName($new['ifDescr']); $int_links[$this_ifid] = $this_ifid; $int_links_v4[$this_ifid] = 1; - } } @@ -152,6 +142,7 @@ echo(""); $int_links_v6[$this_ifid] = 1; } } + } foreach($int_links as $int_link) { @@ -187,7 +178,7 @@ echo(""); echo(""); // If we're showing graphs, generate the graph and print the img tags - if($dographs && is_file($config['rrd_dir'] . "/" . $hostname . "/". $ifIndex . ".rrd")) { + if($graph_type && is_file($config['rrd_dir'] . "/" . $hostname . "/". $interface['ifIndex'] . ".rrd")) { $type = $graph_type; @@ -203,7 +194,7 @@ echo(""); $yearly_traffic = "graph.php?if=$if_id&type=" . $graph_type . "&from=$year&to=$now&width=210&height=100"; $yearly_url = "graph.php?if=$if_id&type=" . $graph_type . "&from=$year&to=$now&width=500&height=150"; - echo(""); + echo(""); echo("', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> "); diff --git a/html/pages/device.php b/html/pages/device.php index 86393860b5..66d5719cbc 100644 --- a/html/pages/device.php +++ b/html/pages/device.php @@ -37,6 +37,40 @@ echo("
  • "); +$health = mysql_result(mysql_query("select count(temp_id) from temperature WHERE temp_host = '" . $device['device_id'] . "'"), 0) + + mysql_result(mysql_query("select count(*) from cempMemPool WHERE device_id = '" . $device['device_id'] . "'"), 0) + + mysql_result(mysql_query("select count(*) from cpmCPU WHERE device_id = '" . $device['device_id'] . "'"), 0); + +if($health) { + echo(" +
  • + + Health + +
  • +"); +} + +if(is_dir($config['collectd_dir'] . "/" . $device['hostname'] ."/")) { + echo(" +
  • + + CollectD + +
  • +"); +} + + +if(@mysql_result(mysql_query("select count(interface_id) from interfaces WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') { + echo(" +
  • + + Ports + +
  • "); +} + if(@mysql_result(mysql_query("select count(vlan_id) from vlans WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') { echo("
  • @@ -65,22 +99,17 @@ if($config['enable_bgp'] && $device['bgpLocalAs']) {
  • "); } -if(@mysql_result(mysql_query("select count(interface_id) from interfaces WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') { +if(@mysql_result(mysql_query("SELECT count(*) FROM nagios_hosts WHERE address = '".$device['hostname']."'", $nagios_link), 0) > '0') { echo(" -
  • - - Ports +
  • + + Nagios
  • "); - -#
  • -# -# Port Graphs -# -#
  • "); } -if($_SESSION[userlevel] >= "5") { + +if($_SESSION[userlevel] >= "5" && mysql_result(mysql_query("SELECT count(*) FROM links AS L, interfaces AS I WHERE I.device_id = '".$device['device_id']."' AND I.interface_id = L.src_if"),0)) { echo("
  • @@ -102,16 +131,6 @@ if($config['enable_inventory'] && @mysql_result(mysql_query("SELECT * FROM `entP } -if(mysql_result(mysql_query("select count(temp_id) from temperature WHERE temp_host = '" . $device['device_id'] . "'"), 0) > '0') { - echo(" -
  • - - Temps - -
  • -"); -} - if(mysql_result(mysql_query("select count(storage_id) from storage WHERE host_id = '" . $device['device_id'] . "'"), 0) > '0') { echo("
  • diff --git a/html/pages/device/graphs.inc.php b/html/pages/device/graphs.inc.php index 9d15f281a3..2707486ef6 100644 --- a/html/pages/device/graphs.inc.php +++ b/html/pages/device/graphs.inc.php @@ -7,6 +7,11 @@ while($device = mysql_fetch_array($device_query)) { echo("
    "); + $os = strtolower(str_replace(" ", "_", $device['os'])); + if(is_file($config['install_dir'] . "/html/pages/device/graphs/os-$os.inc.php")) { + include($config['install_dir'] . "/html/pages/device/graphs/os-$os.inc.php"); + } + switch ($device['os']) { case "JunOS": echo("
    Processor Utilisation
    "); @@ -165,22 +170,8 @@ while($device = mysql_fetch_array($device_query)) { break; case "IOS": case "IOS XE": - echo("
    CPU Usage
    "); - $graph_type = "cpu"; include ("includes/print-device-graph.php"); - echo("
    "); - echo("
    Memory Usage
    "); - $graph_type = "mem"; 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 = "dev_temp"; include ("includes/print-device-graph.php"); - echo("
    "); - } - - include("graphs/netstats.inc.php"); - include("graphs/uptime.inc.php"); break; - case "Snom": + case "Snom": echo("
    Calls
    "); $graph_type = "calls"; include ("includes/print-device-graph.php"); } diff --git a/includes/functions.php b/includes/functions.php index 75dd257d9e..02b9bfbdcf 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -16,6 +16,11 @@ include_once($config['install_dir'] . "/includes/cisco-entities.php"); include_once($config['install_dir'] . "/includes/syslog.php"); include_once($config['install_dir'] . "/includes/rewrites.php"); +function only_alphanumeric( $string ) +{ + return preg_replace('/[^a-zA-Z0-9]/', '', $string); +} + function mres($string) { // short function wrapper because the real one is stupidly long and ugly. aestetics. return mysql_real_escape_string($string); @@ -142,9 +147,9 @@ function formatRates($rate) return $rate; } -function formatstorage($rate) +function formatstorage($rate, $round = '2') { - $rate = format_bi($rate) . "B"; + $rate = format_bi($rate, $round) . "B"; return $rate; } @@ -157,12 +162,12 @@ function format_si($rate) return round($rate, $round[$i]).$ext; } -function format_bi($size) +function format_bi($size, $round = '2') { - $sizes = Array('', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei'); + $sizes = Array('', 'K', 'M', 'G', 'T', 'P', 'E'); $ext = $sizes[0]; for ($i=1; (($i < count($sizes)) && ($size >= 1024)); $i++) { $size = $size / 1024; $ext = $sizes[$i]; } - return round($size, 2).$ext; + return round($size, $round).$ext; } function arguments($argv) @@ -203,11 +208,11 @@ function truncate($substring, $max = 50, $rep = '...') if(strlen($string) > $max){ return substr_replace($string, $rep, $leave); } else { return $string; } } -function interface_rates ($interface) // Returns the last in/out value in RRD +function interface_rates ($rrd_file) // Returns the last in/out value in RRD { global $config; - $rrdfile = $config['rrd_dir'] . "/" . $interface['hostname'] . "/" . $interface['ifIndex'] . ".rrd"; - $cmd = $config['rrdtool']." fetch -s -600s -e now ".$rrdfile." AVERAGE | grep : | cut -d\" \" -f 2,3 | grep e"; + #$rrdfile = $config['rrd_dir'] . "/" . $interface['hostname'] . "/" . $interface['ifIndex'] . ".rrd"; + $cmd = $config['rrdtool']." fetch -s -600s -e now $rrd_file AVERAGE | grep : | cut -d\" \" -f 2,3 | grep e"; $data = trim(`$cmd`); foreach( explode("\n", $data) as $entry) { list($in, $out) = split(" ", $entry); @@ -217,12 +222,12 @@ function interface_rates ($interface) // Returns the last in/out value in RRD return $rate; } -function interface_errors ($interface) // Returns the last in/out errors value in RRD +function interface_errors ($rrd_file) // Returns the last in/out errors value in RRD { global $config; - $rrdfile = $config['rrd_dir'] . "/" . $interface['hostname'] . "/" . $interface['ifIndex'] . ".rrd"; - $cmd = $config['rrdtool']." fetch -s -1d -e -300s $rrdfile AVERAGE | grep : | cut -d\" \" -f 4,5"; - $data = trim(`$cmd`); + #$rrdfile = $config['rrd_dir'] . "/" . $interface['hostname'] . "/" . $interface['ifIndex'] . ".rrd"; + $cmd = $config['rrdtool']." fetch -s -1d -e -300s $rrd_file AVERAGE | grep : | cut -d\" \" -f 4,5"; + $data = trim(shell_exec($cmd)); foreach( explode("\n", $data) as $entry) { list($in, $out) = explode(" ", $entry); $in_errors += ($in * 300); diff --git a/includes/graphing.php b/includes/graphing.php index d90038655e..e53213b80e 100644 --- a/includes/graphing.php +++ b/includes/graphing.php @@ -4,8 +4,9 @@ include("graphing/screenos.php"); include("graphing/fortigate.php"); include("graphing/windows.php"); include("graphing/unix.php"); +include("graphing/collectd.inc.php"); -function graph_multi_bits ($interfaces, $graph, $from, $to, $width, $height, $title, $vertical, $inverse, $legend = '0') { +function graph_multi_bits ($interfaces, $graph, $from, $to, $width, $height, $title, $vertical, $inverse, $legend = '1') { global $config, $installdir; $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; $options = "--alt-autoscale-max -E --start $from --end " . ($to - 150) . " --width $width --height $height"; @@ -25,17 +26,19 @@ function graph_multi_bits ($interfaces, $graph, $from, $to, $width, $height, $ti $i++; } } - if($inverse) { $in = 'out'; $out = 'in'; } else { $in = 'in'; $out = 'out'; } - $options .= " CDEF:".$in."octets=" . $in_thing . $pluses; $options .= " CDEF:".$out."octets=" . $out_thing . $pluses; $options .= " CDEF:doutoctets=outoctets,-1,*"; $options .= " CDEF:inbits=inoctets,8,*"; $options .= " CDEF:outbits=outoctets,8,*"; $options .= " CDEF:doutbits=doutoctets,8,*"; - - if($legend) { + if($legend == "no") { + $options .= " AREA:inbits#CDEB8B:"; + $options .= " LINE1.25:inbits#006600:"; + $options .= " AREA:doutbits#C3D9FF:"; + $options .= " LINE1.25:doutbits#000099:"; + } else { $options .= " AREA:inbits#CDEB8B:"; $options .= " COMMENT:BPS\ \ \ \ Current\ \ \ Average\ \ \ \ \ \ Max\\\\n"; $options .= " LINE1.25:inbits#006600:In\ "; @@ -47,11 +50,6 @@ function graph_multi_bits ($interfaces, $graph, $from, $to, $width, $height, $ti $options .= " GPRINT:outbits:LAST:%6.2lf%s"; $options .= " GPRINT:outbits:AVERAGE:%6.2lf%s"; $options .= " GPRINT:outbits:MAX:%6.2lf%s"; - } else { - $options .= " AREA:inbits#CDEB8B:"; - $options .= " LINE1.25:inbits#006600:"; - $options .= " AREA:doutbits#C3D9FF:"; - $options .= " LINE1.25:doutbits#000099:"; } if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal"; } $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); @@ -94,6 +92,35 @@ function temp_graph ($temp, $graph, $from, $to, $width, $height, $title, $vertic return $imgfile; } +function graph_cpmCPU ($id, $graph, $from, $to, $width, $height, $title, $vertical) { + global $config, $installdir; + $options = "--start $from --end $to --width $width --height $height --vertical-label '$vertical' --alt-autoscale-max "; + $options .= " -l 0 -E -b 1024 --title '$title' "; + if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } + $hostname = gethostbyid($device); + $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; + $iter = "1"; + $sql = mysql_query("SELECT * FROM `cpmCPU` AS C, `devices` AS D where C.`cpmCPU_id` = '$id' AND C.device_id = D.device_id"); + $options .= "COMMENT:\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Cur\ \ \ \ Max\\\\n"; + while($proc = mysql_fetch_array($sql)) { + if($iter=="1") {$colour="CC0000";} elseif($iter=="2") {$colour="008C00";} elseif($iter=="3") {$colour="4096EE"; + } elseif($iter=="4") {$colour="73880A";} elseif($iter=="5") {$colour="D01F3C";} elseif($iter=="6") {$colour="36393D"; + } elseif($iter=="7") {$colour="FF0084"; unset($iter); } + $proc['descr_fixed'] = str_pad($proc['entPhysicalDescr'], 28); + $proc['descr_fixed'] = substr($proc['descr_fixed'],0,28); + $rrd = $config['rrd_dir'] . "/".$proc['hostname']."/cpmCPU-" . $proc['cpmCPU_oid'] . ".rrd"; + $options .= " DEF:proc" . $proc['cpmCPU_oid'] . "=$rrd:usage:AVERAGE "; + $options .= " LINE1:proc" . $proc['cpmCPU_oid'] . "#" . $colour . ":'" . $proc['descr_fixed'] . "' "; + $options .= " GPRINT:proc" . $proc['cpmCPU_oid'] . ":LAST:%3.0lf"; + $options .= " GPRINT:proc" . $proc['cpmCPU_oid'] . ":MAX:%3.0lf\\\l "; + $iter++; + } + $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); + return $imgfile; +} + + + function graph_device_cpmCPU ($device, $graph, $from, $to, $width, $height, $title, $vertical) { global $config, $installdir; $options = "--start $from --end $to --width $width --height $height --vertical-label '$vertical' --alt-autoscale-max "; @@ -121,6 +148,81 @@ function graph_device_cpmCPU ($device, $graph, $from, $to, $width, $height, $tit return $imgfile; } +function graph_device_cempMemPool ($device, $graph, $from, $to, $width, $height, $title, $vertical) { + global $config, $installdir; + $options = "--start $from --end $to --width $width --height $height --vertical-label '$vertical' --alt-autoscale-max "; + $options .= " -l 0 -E -b 1024 --title '$title' "; + if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } + $hostname = gethostbyid($device); + $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; + $iter = "1"; + $sql = mysql_query("SELECT * FROM `cempMemPool` where `device_id` = '$device'"); + $options .= "COMMENT:\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Cur\ \ \ \ Max\\\\n"; + while($mempool = mysql_fetch_array($sql)) { + $entPhysicalName = mysql_result(mysql_query("SELECT entPhysicalName from entPhysical WHERE device_id = '".$device."' + AND entPhysicalIndex = '".$mempool['entPhysicalIndex']."'"),0); + if($iter=="1") {$colour="CC0000";} elseif($iter=="2") {$colour="008C00";} elseif($iter=="3") {$colour="4096EE"; + } elseif($iter=="4") {$colour="73880A";} elseif($iter=="5") {$colour="D01F3C";} elseif($iter=="6") {$colour="36393D"; + } elseif($iter=="7") {$colour="FF0084"; unset($iter); } + $mempool['descr_fixed'] = $entPhysicalName . " " . $mempool['cempMemPoolName']; + $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); + $oid = $mempool['entPhysicalIndex'] . "." . $mempool['Index']; + $rrd = $config['rrd_dir'] . "/$hostname/cempMemPool-$oid.rrd"; + $id = $mempool['entPhysicalIndex'] . "-" . $mempool['Index']; + $options .= " DEF:mempool" . $id . "free=$rrd:free:AVERAGE "; + $options .= " DEF:mempool" . $id . "used=$rrd:used:AVERAGE "; + $options .= " CDEF:mempool" . $id . "total=mempool" . $id . "used,mempool" . $id . "used,mempool" . $id . "free,+,/,100,* "; + $options .= " LINE1:mempool" . $id . "total#" . $colour . ":'" . $mempool['descr_fixed'] . "' "; + $options .= " GPRINT:mempool" . $id . "total:LAST:%3.0lf"; + $options .= " GPRINT:mempool" . $id . "total:MAX:%3.0lf\\\l "; + $iter++; + } + $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); + return $imgfile; +} + +function graph_cempMemPool ($id, $graph, $from, $to, $width, $height, $title, $vertical) { + global $config, $installdir; + $options = "--start $from --end $to --width $width --height $height --vertical-label '$vertical' --alt-autoscale-max "; + $options .= " -l 0 -E -b 1024 --title '$title' "; + if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } + $hostname = gethostbyid($device); + $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; + $iter = "1"; + $sql = mysql_query("SELECT * FROM `cempMemPool` AS C, `devices` AS D where C.`cempMemPool_id` = '$id' AND C.device_id = D.device_id"); + $options .= "COMMENT:\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Cur\ \ \ \ Max\\\\n"; + while($mempool = mysql_fetch_array($sql)) { + $entPhysicalName = mysql_result(mysql_query("SELECT entPhysicalName from entPhysical WHERE device_id = '".$mempool['device_id']."' + AND entPhysicalIndex = '".$mempool['entPhysicalIndex']."'"),0); + if($iter=="1") {$colour="CC0000";} elseif($iter=="2") {$colour="008C00";} elseif($iter=="3") {$colour="4096EE"; + } elseif($iter=="4") {$colour="73880A";} elseif($iter=="5") {$colour="D01F3C";} elseif($iter=="6") {$colour="36393D"; + } elseif($iter=="7") {$colour="FF0084"; unset($iter); } + $mempool['descr_fixed'] = $entPhysicalName . " " . $mempool['cempMemPoolName']; + $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); + $oid = $mempool['entPhysicalIndex'] . "." . $mempool['Index']; + $rrd = $config['rrd_dir'] . "/".$mempool['hostname']."/cempMemPool-$oid.rrd"; + $id = $mempool['entPhysicalIndex'] . "-" . $mempool['Index']; + $options .= " DEF:mempool" . $id . "free=$rrd:free:AVERAGE "; + $options .= " DEF:mempool" . $id . "used=$rrd:used:AVERAGE "; + $options .= " CDEF:mempool" . $id . "total=mempool" . $id . "used,mempool" . $id . "used,mempool" . $id . "free,+,/,100,* "; + $options .= " LINE1:mempool" . $id . "total#" . $colour . ":'" . $mempool['descr_fixed'] . "' "; + $options .= " GPRINT:mempool" . $id . "total:LAST:%3.0lf"; + $options .= " GPRINT:mempool" . $id . "total:MAX:%3.0lf\\\l "; + $iter++; + } + + $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); + return $imgfile; +} + function temp_graph_dev ($device, $graph, $from, $to, $width, $height, $title, $vertical) { global $config, $installdir; @@ -179,6 +281,7 @@ function graph_mac_acc ($id, $graph, $from, $to, $width, $height) { $options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height "; if($height < "33") { $options .= " --only-graph"; } if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } + $options .= " DEF:inoctets=$database:IN:AVERAGE"; $options .= " DEF:outoctets=$database:OUT:AVERAGE"; $options .= " CDEF:octets=inoctets,outoctets,+"; @@ -390,22 +493,22 @@ function graph_cbgp_prefixes ($rrd, $graph, $from, $to, $width, $height) { $options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height "; if($width <= "300") {$options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } $options .= " DEF:Accepted=$database:AcceptedPrefixes:AVERAGE"; - $options .= " DEF:Denied=$database:DeniedPrefixes:AVERAGE"; - $options .= " DEF:Advertised=$database:AdvertisedPrefixes:AVERAGE"; - $options .= " DEF:Suppressed=$database:SuppressedPrefixes:AVERAGE"; - $options .= " DEF:Withdrawn=$database:WithdrawnPrefixes:AVERAGE"; - $options .= " CDEF:dAdvertised=Advertised,-1,*"; + #$options .= " DEF:Denied=$database:DeniedPrefixes:AVERAGE"; + #$options .= " DEF:Advertised=$database:AdvertisedPrefixes:AVERAGE"; + #$options .= " DEF:Suppressed=$database:SuppressedPrefixes:AVERAGE"; + #$options .= " DEF:Withdrawn=$database:WithdrawnPrefixes:AVERAGE"; + #$options .= " CDEF:dAdvertised=Advertised,-1,*"; $options .= " COMMENT:Prefixes\ \ \ \ \ \ Current\ \ Minimum\ \ Maximum\\\\n"; $options .= " AREA:Accepted#eeaaaa:"; $options .= " LINE2:Accepted#cc0000:Accepted\ \ "; $options .= " GPRINT:Accepted:LAST:%6.2lf%s"; $options .= " GPRINT:Accepted:MIN:%6.2lf%s"; $options .= " GPRINT:Accepted:MAX:%6.2lf%s\\\\l"; - $options .= " AREA:dAdvertised#aaeeaa:"; - $options .= " LINE2:dAdvertised#00cc00:Advertised"; - $options .= " GPRINT:Advertised:LAST:%6.2lf%s"; - $options .= " GPRINT:Advertised:MIN:%6.2lf%s"; - $options .= " GPRINT:Advertised:MAX:%6.2lf%s\\\\l"; + #$options .= " AREA:dAdvertised#aaeeaa:"; + #$options .= " LINE2:dAdvertised#00cc00:Advertised"; + #$options .= " GPRINT:Advertised:LAST:%6.2lf%s"; + #$options .= " GPRINT:Advertised:MIN:%6.2lf%s"; + #$options .= " GPRINT:Advertised:MAX:%6.2lf%s\\\\l"; $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); # echo($config['rrdtool'] . " graph $imgfile $options"); return $imgfile; diff --git a/includes/polling/cisco-processors.inc.php b/includes/polling/cisco-processors.inc.php index f574dd08f8..a435cb7cb6 100755 --- a/includes/polling/cisco-processors.inc.php +++ b/includes/polling/cisco-processors.inc.php @@ -4,7 +4,7 @@ $query = "SELECT * FROM cpmCPU WHERE device_id = '" . $device['device_id'] . "'" $proc_data = mysql_query($query); while($processor = mysql_fetch_array($proc_data)) { - $proc_cmd = "snmpget -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " cpmCPUTotal5minRev." . $processor['cpmCPU_oid']; + $proc_cmd = "snmpget -m CISCO-PROCESS-MIB -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " cpmCPUTotal5minRev." . $processor['cpmCPU_oid']; $proc = shell_exec($proc_cmd); echo("Checking CPU " . $processor['entPhysicalDescr'] . "... "); @@ -27,7 +27,6 @@ while($processor = mysql_fetch_array($proc_data)) { echo($proc . "%\n"); $updatecmd = $config['rrdtool'] ." update $procrrd N:$proc"; - echo("$updatecmd"); shell_exec($updatecmd); mysql_query("UPDATE `cpmCPU` SET `cpmCPUTotal5minRev` = '$proc' WHERE `cpmCPU_id` = '".$processor['cpmCPU_id']."'"); diff --git a/includes/polling/device-ios.inc.php b/includes/polling/device-ios.inc.php index 4368c66c7c..a8c79f36a6 100755 --- a/includes/polling/device-ios.inc.php +++ b/includes/polling/device-ios.inc.php @@ -107,5 +107,6 @@ include("includes/polling/bgpPeer.inc.php"); include("includes/polling/cisco-processors.inc.php"); + include("includes/polling/cisco-mempool.inc.php"); ?> diff --git a/includes/polling/device-netstats.inc.php b/includes/polling/device-netstats.inc.php index a60d8ba190..f2f48e98d7 100755 --- a/includes/polling/device-netstats.inc.php +++ b/includes/polling/device-netstats.inc.php @@ -14,7 +14,7 @@ if($device[os] != "Snom") { $rrdfile = $config['rrd_dir'] . "/" . $device['hostname'] . "/netinfo.rrd"; - $rrd_create = "rrdtool create $rrdfile "; + $rrd_create = $config['rrdtool'] . " create $rrdfile "; $rrd_create .= "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 \ RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797"; @@ -23,8 +23,10 @@ if($device[os] != "Snom") { $snmpstring .= " $oid.0"; } - if(!file_exists($rrdfile)) { `$rrd_create`; } - $snmpdata_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " $snmpstring"; + if(!file_exists($rrdfile)) { + shell_exec($rrd_create); + } + $snmpdata_cmd = "snmpget -m IP-MIB:SNMPv2-MIB:UDP-MIB:TCP-MIB:IP-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " $snmpstring"; $snmpdata = trim(`$snmpdata_cmd`); $rrdupdate = "N"; foreach(explode("\n", $snmpdata) as $data) { diff --git a/includes/polling/device-unix.inc.php b/includes/polling/device-unix.inc.php index 75012743ea..21f3319a79 100755 --- a/includes/polling/device-unix.inc.php +++ b/includes/polling/device-unix.inc.php @@ -48,7 +48,7 @@ while ($dr = mysql_fetch_array($dq)) { $hrStorageAllocationUnits = $dr['hrStorageAllocationUnits']; $hrStorageSize = $dr['hrStorageAllocationUnits'] * $dr['hrStorageSize']; $hrStorageDescr = $dr['hrStorageDescr']; - $cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " hrStorageUsed.$hrStorageIndex"; + $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); @@ -78,14 +78,10 @@ while ($dr = mysql_fetch_array($dq)) { 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"); - } @@ -104,11 +100,11 @@ $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 = "snmpget -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_hrSystemProcesses"; -$cpu_cmd .= " $oid_hrSystemNumUsers $oid_ssCpuUser $oid_ssCpuSystem .1.3.6.1.4.1.2021.1.101.1"; +$cpu_cmd .= " $oid_hrSystemNumUsers $oid_ssCpuUser $oid_ssCpuSystem"; $cpu = `$cpu_cmd`; -list ($cpuUser, $cpuSystem, $cpuNice, $cpuIdle, $procs, $users, $UsageUser, $UsageSystem, $cputemp) = explode("\n", $cpu); +list ($cpuUser, $cpuSystem, $cpuNice, $cpuIdle, $procs, $users, $UsageUser, $UsageSystem) = explode("\n", $cpu); $cpuUsage = $UsageUser + $UsageSystem; @@ -192,13 +188,14 @@ if($device[os] != "m0n0wall" && $device[os] != "Voswall" && $device[os] != "pfSe RRA:MAX:0.5:288:800"); } // end create load rrd - $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_raw = `$mem_cmd`; - list($memTotalSwap, $memAvailSwap, $memTotalReal, $memAvailReal, $memTotalFree, $memShared, $memBuffer, $memCached) = explode("\n", $mem_raw); + $mem_cmd = $config['snmpget'] . " -m UCD-SNMP-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; + $mem_cmd .= " memTotalSwap.0 memAvailSwap.0 memTotalReal.0 memAvailReal.0 memTotalFree.0 memShared.0 memBuffer.0 memCached.0"; + + $mem_raw = shell_exec($mem_cmd); + list($memTotalSwap, $memAvailSwap, $memTotalReal, $memAvailReal, $memTotalFree, $memShared, $memBuffer, $memCached) = explode("\n", str_replace(" kB", "", $mem_raw)); $load_get = "laLoadInt.1 laLoadInt.2 laLoadInt.3"; - $load_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $load_get; + $load_cmd = "snmpget -m UCD-SNMP-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $load_get; $load_raw = `$load_cmd`; list ($load1, $load5, $load10) = explode ("\n", $load_raw); @@ -206,16 +203,4 @@ if($device[os] != "m0n0wall" && $device[os] != "Voswall" && $device[os] != "pfSe rrdtool_update($loadrrd, "N:$load1:$load5:$load10"); rrdtool_update($memrrd, "N:$memTotalSwap:$memAvailSwap:$memTotalReal:$memAvailReal:$memTotalFree:$memShared:$memBuffer:$memCached"); - if($device['courier']) { - include("includes/polling/courierstats.inc.php"); - } - - if($device['postfix']) { - include("includes/polling/mailstats.inc.php"); - } - - if($device['apache']) { - include("includes/polling/apachestats.inc.php"); - } - } // end Non-m0n0wall diff --git a/includes/polling/interfaces.inc.php b/includes/polling/interfaces.inc.php index d32a84f1d6..7b230ac61a 100644 --- a/includes/polling/interfaces.inc.php +++ b/includes/polling/interfaces.inc.php @@ -18,7 +18,7 @@ while ($interface = mysql_fetch_array($interface_query)) { echo("Looking at " . $interface['ifDescr'] . " on " . $device['hostname'] . "\n"); - $snmp_cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; + $snmp_cmd = $config['snmpget'] . " -m IF-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; $snmp_cmd .= " ifAdminStatus." . $interface['ifIndex'] . " ifOperStatus." . $interface['ifIndex'] . " ifAlias." . $interface['ifIndex']; $snmp_output = trim(`$snmp_cmd`); @@ -93,8 +93,8 @@ while ($interface = mysql_fetch_array($interface_query)) { if($ifOperStatus == "up") { - $snmp_data_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; - $snmp_data_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; +# $snmp_data_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; + $snmp_data_cmd = "snmpget -m IF-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; $snmp_data_cmd .= " ifHCInOctets." . $interface['ifIndex'] . " ifHCOutOctets." . $interface['ifIndex'] . " ifInErrors." . $interface['ifIndex']; $snmp_data_cmd .= " ifOutErrors." . $interface['ifIndex'] . " ifInUcastPkts." . $interface['ifIndex'] . " ifOutUcastPkts." . $interface['ifIndex']; $snmp_data_cmd .= " ifInNUcastPkts." . $interface['ifIndex'] . " ifOutNUcastPkts." . $interface['ifIndex']; @@ -119,7 +119,7 @@ while ($interface = mysql_fetch_array($interface_query)) { } } - $rates = interface_rates ($interface); + $rates = interface_rates ($rrdfile); mysql_query("UPDATE `interfaces` SET in_rate = '" . $rates['in'] . "', out_rate = '" . $rates['out'] . "' WHERE interface_id= '" . $interface['interface_id'] . "'"); } diff --git a/includes/static-config.php b/includes/static-config.php index 4769184347..7890d9b14b 100644 --- a/includes/static-config.php +++ b/includes/static-config.php @@ -19,12 +19,20 @@ $config['afi']['ipv6']['multicast'] = "IPv6 Multicast"; $config['version'] = "0.5.1"; -### Connect to database -if (!@mysql_connect($config['db_host'], $config['db_user'], $config['db_pass'])) { - echo "

    MySQL Error

    "; +$nagios_link = mysql_connect($config['nagios_db_host'], $config['nagios_db_user'], $config['nagios_db_pass']); +if (!$nagios_link) { + echo "

    Nagios MySQL Error

    "; die; } -mysql_select_db($config['db_name']); +$nagios_db = mysql_select_db($config['nagios_db_name'], $nagios_link); + +### Connect to database +$observer_link = mysql_connect($config['db_host'], $config['db_user'], $config['db_pass']); +if (!$observer_link) { + echo "

    Observer MySQL Error

    "; + die; +} +$observer_db = mysql_select_db($config['db_name'], $observer_link); # Set some times needed by loads of scripts (it's dynamic, so we do it here!) diff --git a/includes/syslog.php b/includes/syslog.php index cfc13d48fd..988d28eccb 100755 --- a/includes/syslog.php +++ b/includes/syslog.php @@ -15,7 +15,7 @@ function process_syslog ($entry, $update) { if($device_id_host) { $device_id = $device_id_host; } else { - $device_id_ip = @mysql_result(mysql_query("SELECT D.device_id as device_id FROM ipaddr AS A, interfaces AS I, devices AS D WHERE A.addr = '" . $entry['host']."' AND I.interface_id = A.interface_id AND D.device_id = I.device_id"),0); + $device_id_ip = @mysql_result(mysql_query("SELECT D.device_id as device_id FROM ipv4_addresses AS A, interfaces AS I, devices AS D WHERE A.ipv4_address = '" . $entry['host']."' AND I.interface_id = A.interface_id AND D.device_id = I.device_id"),0); if($device_id_ip) { $device_id = $device_id_ip; } @@ -23,8 +23,10 @@ function process_syslog ($entry, $update) { if($device_id && !$delete) { $entry['device_id'] = $device_id; - if(mysql_result(mysql_query("SELECT `os` FROM `devices` WHERE `device_id` = '$device_id'"),0) == "IOS") { + $os = mysql_result(mysql_query("SELECT `os` FROM `devices` WHERE `device_id` = '$device_id'"),0); + if($os == "IOS" || $os == "IOS XE") { if(strstr($entry[msg], "%")) { + $entry['msg'] = preg_replace("/^%(.+?):\ /", "\\1||", $entry['msg']); list(,$entry[msg]) = split(": %", $entry['msg']); $entry['msg'] = "%" . $entry['msg']; $entry['msg'] = preg_replace("/^%(.+?):\ /", "\\1||", $entry['msg']); diff --git a/mysql-schema.sql b/mysql-schema.sql index 69e83ba374..f523cdfd79 100644 --- a/mysql-schema.sql +++ b/mysql-schema.sql @@ -1,70 +1,56 @@ --- phpMyAdmin SQL Dump --- version 2.11.3deb1ubuntu1.1 --- http://www.phpmyadmin.net +-- MySQL dump 10.11 -- --- Host: localhost --- Generation Time: Mar 23, 2009 at 05:29 PM --- Server version: 5.0.51 --- PHP Version: 5.2.4-2ubuntu5.5 - -SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; - --- --- Database: `observer` --- - --- -------------------------------------------------------- - --- --- Table structure for table `adjacencies` --- - -CREATE TABLE IF NOT EXISTS `adjacencies` ( - `adj_id` int(11) NOT NULL auto_increment, - `network_id` int(11) NOT NULL default '0', - `interface_id` int(11) NOT NULL default '0', - PRIMARY KEY (`adj_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +-- Host: localhost Database: observer +-- ------------------------------------------------------ +-- Server version 5.0.67-0ubuntu6-log +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -- -- Table structure for table `alerts` -- -CREATE TABLE IF NOT EXISTS `alerts` ( - `id` int(11) NOT NULL auto_increment, +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `alerts` ( + `id` int(11) NOT NULL, `importance` int(11) NOT NULL default '0', `device_id` int(11) NOT NULL, `message` text NOT NULL, `time_logged` timestamp NOT NULL default CURRENT_TIMESTAMP, `alerted` smallint(6) NOT NULL default '0', KEY `id` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +); +SET character_set_client = @saved_cs_client; -- -- Table structure for table `authlog` -- -CREATE TABLE IF NOT EXISTS `authlog` ( - `id` int(11) NOT NULL auto_increment, +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `authlog` ( + `id` int(11) NOT NULL, `datetime` timestamp NOT NULL default CURRENT_TIMESTAMP, `user` text NOT NULL, `address` text NOT NULL, `result` text NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +); +SET character_set_client = @saved_cs_client; -- -- Table structure for table `bgpPeers` -- -CREATE TABLE IF NOT EXISTS `bgpPeers` ( - `bgpPeer_id` int(11) NOT NULL auto_increment, +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `bgpPeers` ( + `bgpPeer_id` int(11) NOT NULL, `device_id` int(11) NOT NULL, `astext` varchar(64) NOT NULL, `bgpPeerIdentifier` text NOT NULL, @@ -81,31 +67,31 @@ CREATE TABLE IF NOT EXISTS `bgpPeers` ( `bgpPeerInUpdateElapsedTime` int(11) NOT NULL, PRIMARY KEY (`bgpPeer_id`), KEY `device_id` (`device_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +); +SET character_set_client = @saved_cs_client; -- --- Table structure for table `bills` +-- Table structure for table `bgpPeers_cbgp` -- -CREATE TABLE IF NOT EXISTS `bills` ( - `bill_id` int(11) NOT NULL auto_increment, - `bill_name` text NOT NULL, - `bill_type` text NOT NULL, - `bill_cdr` int(11) default NULL, - `bill_day` int(11) NOT NULL default '1', - `bill_gb` int(11) default NULL, - UNIQUE KEY `bill_id` (`bill_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `bgpPeers_cbgp` ( + `device_id` int(11) NOT NULL, + `bgpPeerIdentifier` varchar(64) NOT NULL, + `afi` varchar(8) NOT NULL, + `safi` varchar(8) NOT NULL, + KEY `device_id` (`device_id`,`bgpPeerIdentifier`) +); +SET character_set_client = @saved_cs_client; -- -- Table structure for table `bill_data` -- -CREATE TABLE IF NOT EXISTS `bill_data` ( +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `bill_data` ( `bill_id` int(11) NOT NULL, `timestamp` datetime NOT NULL, `period` int(11) NOT NULL, @@ -113,54 +99,116 @@ CREATE TABLE IF NOT EXISTS `bill_data` ( `in_delta` bigint(11) NOT NULL, `out_delta` bigint(11) NOT NULL, KEY `bill_id` (`bill_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +); +SET character_set_client = @saved_cs_client; -- -- Table structure for table `bill_perms` -- -CREATE TABLE IF NOT EXISTS `bill_perms` ( +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `bill_perms` ( `user_id` int(11) NOT NULL, `bill_id` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +); +SET character_set_client = @saved_cs_client; -- -- Table structure for table `bill_ports` -- -CREATE TABLE IF NOT EXISTS `bill_ports` ( +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `bill_ports` ( `bill_id` int(11) NOT NULL, `port_id` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=latin1; +); +SET character_set_client = @saved_cs_client; --- -------------------------------------------------------- +-- +-- Table structure for table `bills` +-- + +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `bills` ( + `bill_id` int(11) NOT NULL, + `bill_name` text NOT NULL, + `bill_type` text NOT NULL, + `bill_cdr` int(11) default NULL, + `bill_day` int(11) NOT NULL default '1', + `bill_gb` int(11) default NULL, + UNIQUE KEY `bill_id` (`bill_id`) +); +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `cempMemPool` +-- + +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `cempMemPool` ( + `cempMemPool_id` int(11) NOT NULL, + `Index` varchar(8) NOT NULL, + `entPhysicalIndex` int(11) NOT NULL, + `cempMemPoolType` varchar(32) NOT NULL, + `cempMemPoolName` varchar(32) NOT NULL, + `cempMemPoolValid` tinyint(4) NOT NULL, + `device_id` int(11) NOT NULL, + `cempMemPoolUsed` int(11) NOT NULL, + `cempMemPoolFree` int(11) NOT NULL, + `cempMemPoolLargestFree` int(11) NOT NULL, + `cempMemPoolLowestFree` int(11) NOT NULL, + PRIMARY KEY (`cempMemPool_id`), + KEY `device_id` (`device_id`) +); +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `cpmCPU` +-- + +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `cpmCPU` ( + `cpmCPU_id` int(11) NOT NULL, + `entPhysicalIndex` int(11) NOT NULL, + `device_id` int(11) NOT NULL, + `cpmCPU_oid` int(11) NOT NULL, + `cpmCPUTotal5minRev` int(11) NOT NULL, + `entPhysicalDescr` varchar(64) NOT NULL, + PRIMARY KEY (`cpmCPU_id`), + KEY `cpuCPU_id` (`cpmCPU_id`,`device_id`) +); +SET character_set_client = @saved_cs_client; -- -- Table structure for table `customers` -- -CREATE TABLE IF NOT EXISTS `customers` ( - `customer_id` int(11) NOT NULL auto_increment, +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `customers` ( + `customer_id` int(11) NOT NULL, `username` char(64) NOT NULL, `password` char(32) NOT NULL, `string` char(64) NOT NULL, `level` tinyint(4) NOT NULL default '0', PRIMARY KEY (`customer_id`), UNIQUE KEY `username` (`username`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +); +SET character_set_client = @saved_cs_client; -- -- Table structure for table `devices` -- -CREATE TABLE IF NOT EXISTS `devices` ( - `device_id` int(11) NOT NULL auto_increment, +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `devices` ( + `device_id` int(11) NOT NULL, `hostname` varchar(128) NOT NULL, `sysName` varchar(128) default NULL, `community` varchar(32) NOT NULL, @@ -177,7 +225,8 @@ CREATE TABLE IF NOT EXISTS `devices` ( `status` tinyint(4) NOT NULL default '0', `ignore` tinyint(4) NOT NULL default '0', `disabled` tinyint(1) NOT NULL default '0', - `lastchange` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + `lastchange` timestamp NOT NULL default CURRENT_TIMESTAMP, + `last_polled` timestamp NOT NULL default '0000-00-00 00:00:00', `purpose` varchar(64) default NULL, `type` varchar(8) NOT NULL default 'other', PRIMARY KEY (`device_id`), @@ -185,44 +234,47 @@ CREATE TABLE IF NOT EXISTS `devices` ( KEY `hostname` (`hostname`), KEY `sysName` (`sysName`), KEY `os` (`os`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +); +SET character_set_client = @saved_cs_client; -- -- Table structure for table `devices_attribs` -- -CREATE TABLE IF NOT EXISTS `devices_attribs` ( - `attrib_id` int(11) NOT NULL auto_increment, +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `devices_attribs` ( + `attrib_id` int(11) NOT NULL, `device_id` int(11) NOT NULL, `attrib_type` varchar(32) NOT NULL, `attrib_value` text NOT NULL, - `updated` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + `updated` timestamp NOT NULL default CURRENT_TIMESTAMP, PRIMARY KEY (`attrib_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +); +SET character_set_client = @saved_cs_client; -- -- Table structure for table `devices_perms` -- -CREATE TABLE IF NOT EXISTS `devices_perms` ( +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `devices_perms` ( `user_id` int(11) NOT NULL, `device_id` int(11) NOT NULL, `access_level` int(4) NOT NULL default '0', KEY `user_id` (`user_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +); +SET character_set_client = @saved_cs_client; -- -- Table structure for table `entPhysical` -- -CREATE TABLE IF NOT EXISTS `entPhysical` ( - `entPhysical_id` int(11) NOT NULL auto_increment, +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `entPhysical` ( + `entPhysical_id` int(11) NOT NULL, `device_id` int(11) NOT NULL, `entPhysicalIndex` int(11) NOT NULL, `entPhysicalDescr` text NOT NULL, @@ -237,15 +289,16 @@ CREATE TABLE IF NOT EXISTS `entPhysical` ( `ifIndex` int(11) default NULL, PRIMARY KEY (`entPhysical_id`), KEY `device_id` (`device_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +); +SET character_set_client = @saved_cs_client; -- -- Table structure for table `eventlog` -- -CREATE TABLE IF NOT EXISTS `eventlog` ( +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `eventlog` ( `id` int(11) NOT NULL default '0', `host` int(11) NOT NULL default '0', `interface` int(11) default NULL, @@ -253,16 +306,17 @@ CREATE TABLE IF NOT EXISTS `eventlog` ( `message` text NOT NULL, `type` int(11) NOT NULL, KEY `host` (`host`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +); +SET character_set_client = @saved_cs_client; -- -- Table structure for table `interfaces` -- -CREATE TABLE IF NOT EXISTS `interfaces` ( - `interface_id` int(11) NOT NULL auto_increment, +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `interfaces` ( + `interface_id` int(11) NOT NULL, `device_id` int(11) NOT NULL default '0', `ifDescr` varchar(128) NOT NULL, `ifIndex` int(11) default '0', @@ -275,7 +329,7 @@ CREATE TABLE IF NOT EXISTS `interfaces` ( `ifAlias` text, `ifPhysAddress` text, `ifHardType` varchar(64) default NULL, - `ifLastChange` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + `ifLastChange` timestamp NOT NULL default CURRENT_TIMESTAMP, `ifVlan` varchar(8) NOT NULL default '', `ifTrunk` varchar(8) default '', `ifVrf` int(11) NOT NULL, @@ -292,88 +346,90 @@ CREATE TABLE IF NOT EXISTS `interfaces` ( KEY `host` (`device_id`), KEY `snmpid` (`ifIndex`), KEY `if_2` (`ifDescr`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +); +SET character_set_client = @saved_cs_client; -- -- Table structure for table `interfaces_perms` -- -CREATE TABLE IF NOT EXISTS `interfaces_perms` ( +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `interfaces_perms` ( `user_id` int(11) NOT NULL, `interface_id` int(11) NOT NULL, `access_level` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +); +SET character_set_client = @saved_cs_client; -- --- Table structure for table `ip6addr` +-- Table structure for table `ipv4_addresses` -- -CREATE TABLE IF NOT EXISTS `ip6addr` ( - `id` int(11) NOT NULL auto_increment, - `addr` varchar(128) NOT NULL, - `comp_addr` text NOT NULL, - `cidr` smallint(6) NOT NULL default '0', - `origin` text NOT NULL, - `network` varchar(64) NOT NULL default '', - `interface_id` int(11) NOT NULL default '0', - PRIMARY KEY (`id`), - KEY `addr` (`addr`,`cidr`,`interface_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `ipv4_addresses` ( + `ipv4_address_id` int(11) NOT NULL, + `ipv4_address` varchar(32) NOT NULL, + `ipv4_prefixlen` int(11) NOT NULL, + `ipv4_network_id` varchar(32) NOT NULL, + `interface_id` int(11) NOT NULL, + PRIMARY KEY (`ipv4_address_id`) +); +SET character_set_client = @saved_cs_client; -- --- Table structure for table `ip6adjacencies` +-- Table structure for table `ipv4_networks` -- -CREATE TABLE IF NOT EXISTS `ip6adjacencies` ( - `adj_id` int(11) NOT NULL auto_increment, - `network_id` int(11) NOT NULL default '0', - `interface_id` int(11) NOT NULL default '0', - PRIMARY KEY (`adj_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `ipv4_networks` ( + `ipv4_network_id` int(11) NOT NULL, + `ipv4_network` varchar(64) NOT NULL, + PRIMARY KEY (`ipv4_network_id`) +); +SET character_set_client = @saved_cs_client; -- --- Table structure for table `ip6networks` +-- Table structure for table `ipv6_addresses` -- -CREATE TABLE IF NOT EXISTS `ip6networks` ( - `id` int(11) NOT NULL auto_increment, - `cidr` varchar(32) NOT NULL default '', - PRIMARY KEY (`id`), - UNIQUE KEY `cidr` (`cidr`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `ipv6_addresses` ( + `ipv6_address_id` int(11) NOT NULL, + `ipv6_address` varchar(128) NOT NULL, + `ipv6_compressed` varchar(128) NOT NULL, + `ipv6_prefixlen` int(11) NOT NULL, + `ipv6_origin` varchar(16) NOT NULL, + `ipv6_network_id` varchar(128) NOT NULL, + `interface_id` int(11) NOT NULL, + PRIMARY KEY (`ipv6_address_id`) +); +SET character_set_client = @saved_cs_client; -- --- Table structure for table `ipaddr` +-- Table structure for table `ipv6_networks` -- -CREATE TABLE IF NOT EXISTS `ipaddr` ( - `id` int(11) NOT NULL auto_increment, - `addr` varchar(32) NOT NULL default '', - `cidr` smallint(6) NOT NULL default '0', - `network` varchar(64) NOT NULL default '', - `interface_id` int(11) NOT NULL default '0', - PRIMARY KEY (`id`), - KEY `addr` (`addr`,`cidr`,`interface_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `ipv6_networks` ( + `ipv6_network_id` int(11) NOT NULL, + `ipv6_network` varchar(64) NOT NULL, + PRIMARY KEY (`ipv6_network_id`) +); +SET character_set_client = @saved_cs_client; -- -- Table structure for table `links` -- -CREATE TABLE IF NOT EXISTS `links` ( - `id` int(11) NOT NULL auto_increment, +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `links` ( + `id` int(11) NOT NULL, `src_if` int(11) default NULL, `dst_if` int(11) default NULL, `active` tinyint(4) NOT NULL default '1', @@ -381,16 +437,17 @@ CREATE TABLE IF NOT EXISTS `links` ( PRIMARY KEY (`id`), KEY `src_if` (`src_if`), KEY `dst_if` (`dst_if`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +); +SET character_set_client = @saved_cs_client; -- -- Table structure for table `mac_accounting` -- -CREATE TABLE IF NOT EXISTS `mac_accounting` ( - `ma_id` int(11) NOT NULL auto_increment, +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `mac_accounting` ( + `ma_id` int(11) NOT NULL, `interface_id` int(11) NOT NULL, `peer_ip` varchar(32) NOT NULL, `peer_desc` varchar(64) NOT NULL, @@ -398,74 +455,67 @@ CREATE TABLE IF NOT EXISTS `mac_accounting` ( `peer_mac` varchar(32) NOT NULL, `in_oid` varchar(128) NOT NULL, `out_oid` varchar(128) NOT NULL, + `bps_out` int(11) NOT NULL, + `bps_in` int(11) NOT NULL, PRIMARY KEY (`ma_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- - --- --- Table structure for table `networks` --- - -CREATE TABLE IF NOT EXISTS `networks` ( - `id` int(11) NOT NULL auto_increment, - `cidr` varchar(32) NOT NULL default '', - PRIMARY KEY (`id`), - UNIQUE KEY `cidr` (`cidr`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +); +SET character_set_client = @saved_cs_client; -- -- Table structure for table `port_in_measurements` -- -CREATE TABLE IF NOT EXISTS `port_in_measurements` ( +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `port_in_measurements` ( `port_id` int(11) NOT NULL, - `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP, `counter` bigint(11) NOT NULL, `delta` bigint(11) NOT NULL, KEY `port_id` (`port_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +); +SET character_set_client = @saved_cs_client; -- -- Table structure for table `port_out_measurements` -- -CREATE TABLE IF NOT EXISTS `port_out_measurements` ( +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `port_out_measurements` ( `port_id` int(11) NOT NULL, - `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP, `counter` bigint(11) NOT NULL, `delta` bigint(11) NOT NULL, KEY `port_id` (`port_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +); +SET character_set_client = @saved_cs_client; -- -- Table structure for table `pseudowires` -- -CREATE TABLE IF NOT EXISTS `pseudowires` ( - `pseudowire_id` int(11) NOT NULL auto_increment, +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `pseudowires` ( + `pseudowire_id` int(11) NOT NULL, `interface_id` int(11) NOT NULL, `peer_device_id` int(11) NOT NULL, `peer_ldp_id` int(11) NOT NULL, `cpwVcID` int(11) NOT NULL, `cpwOid` int(11) NOT NULL, PRIMARY KEY (`pseudowire_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +); +SET character_set_client = @saved_cs_client; -- -- Table structure for table `services` -- -CREATE TABLE IF NOT EXISTS `services` ( - `service_id` int(11) NOT NULL auto_increment, +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `services` ( + `service_id` int(11) NOT NULL, `service_host` int(11) NOT NULL, `service_ip` text NOT NULL, `service_type` varchar(16) NOT NULL, @@ -479,16 +529,17 @@ CREATE TABLE IF NOT EXISTS `services` ( `service_disabled` tinyint(1) NOT NULL default '0', PRIMARY KEY (`service_id`), KEY `service_host` (`service_host`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +); +SET character_set_client = @saved_cs_client; -- -- Table structure for table `storage` -- -CREATE TABLE IF NOT EXISTS `storage` ( - `storage_id` int(11) NOT NULL auto_increment, +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `storage` ( + `storage_id` int(11) NOT NULL, `host_id` int(11) NOT NULL, `hrStorageIndex` int(11) NOT NULL, `hrStorageDescr` text NOT NULL, @@ -497,15 +548,16 @@ CREATE TABLE IF NOT EXISTS `storage` ( `hrStorageUsed` int(11) NOT NULL, `storage_perc` text NOT NULL, PRIMARY KEY (`storage_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +); +SET character_set_client = @saved_cs_client; -- -- Table structure for table `syslog` -- -CREATE TABLE IF NOT EXISTS `syslog` ( +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `syslog` ( `host` varchar(64) NOT NULL, `device_id` int(11) default NULL, `facility` varchar(10) default NULL, @@ -515,22 +567,23 @@ CREATE TABLE IF NOT EXISTS `syslog` ( `datetime` datetime default NULL, `program` varchar(32) default NULL, `msg` text, - `seq` bigint(20) unsigned NOT NULL auto_increment, + `seq` bigint(20) unsigned NOT NULL, `processed` tinyint(1) NOT NULL default '0', PRIMARY KEY (`seq`), KEY `datetime` (`datetime`), KEY `device_id` (`device_id`), KEY `processed` (`processed`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +); +SET character_set_client = @saved_cs_client; -- -- Table structure for table `temperature` -- -CREATE TABLE IF NOT EXISTS `temperature` ( - `temp_id` int(11) NOT NULL auto_increment, +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `temperature` ( + `temp_id` int(11) NOT NULL, `temp_host` int(11) NOT NULL default '0', `temp_oid` varchar(64) NOT NULL, `temp_descr` varchar(32) NOT NULL default '', @@ -539,16 +592,17 @@ CREATE TABLE IF NOT EXISTS `temperature` ( `temp_limit` tinyint(4) NOT NULL default '60', PRIMARY KEY (`temp_id`), KEY `temp_host` (`temp_host`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +); +SET character_set_client = @saved_cs_client; -- -- Table structure for table `users` -- -CREATE TABLE IF NOT EXISTS `users` ( - `user_id` int(11) NOT NULL auto_increment, +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `users` ( + `user_id` int(11) NOT NULL, `username` char(30) NOT NULL, `password` char(32) NOT NULL, `realname` text NOT NULL, @@ -557,47 +611,50 @@ CREATE TABLE IF NOT EXISTS `users` ( `level` tinyint(4) NOT NULL default '0', PRIMARY KEY (`user_id`), UNIQUE KEY `username` (`username`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +); +SET character_set_client = @saved_cs_client; -- -- Table structure for table `users_prefs` -- -CREATE TABLE IF NOT EXISTS `users_prefs` ( +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `users_prefs` ( `user_id` int(16) NOT NULL, `pref` varchar(32) NOT NULL, `value` varchar(128) NOT NULL, PRIMARY KEY (`user_id`), UNIQUE KEY `user_id.pref` (`user_id`,`pref`), KEY `pref` (`pref`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +); +SET character_set_client = @saved_cs_client; -- -- Table structure for table `vlans` -- -CREATE TABLE IF NOT EXISTS `vlans` ( - `vlan_id` int(11) NOT NULL auto_increment, +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `vlans` ( + `vlan_id` int(11) NOT NULL, `device_id` int(11) default NULL, `vlan_vlan` int(11) default NULL, `vlan_domain` text, `vlan_descr` text, PRIMARY KEY (`vlan_id`), KEY `device_id` (`device_id`,`vlan_vlan`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- -------------------------------------------------------- +); +SET character_set_client = @saved_cs_client; -- -- Table structure for table `vrfs` -- -CREATE TABLE IF NOT EXISTS `vrfs` ( - `vrf_id` int(11) NOT NULL auto_increment, +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `vrfs` ( + `vrf_id` int(11) NOT NULL, `vrf_oid` varchar(64) NOT NULL, `vrf_name` varchar(32) NOT NULL, `mplsVpnVrfRouteDistinguisher` varchar(16) NOT NULL, @@ -605,5 +662,13 @@ CREATE TABLE IF NOT EXISTS `vrfs` ( `device_id` int(11) NOT NULL, PRIMARY KEY (`vrf_id`), KEY `device_id` (`device_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; +); +SET character_set_client = @saved_cs_client; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2009-04-23 21:06:10 diff --git a/poll-device.php b/poll-device.php index f5b4953776..b15b68fdd9 100755 --- a/poll-device.php +++ b/poll-device.php @@ -12,8 +12,15 @@ if($argv[1] == "--device" && $argv[2]) { $where = "AND MOD(device_id,2) = 1"; } elseif ($argv[1] == "--even") { $where = "AND MOD(device_id,2) = 0"; +} elseif ($argv[1] == "--odd3") { + $where = "AND MOD(device_id,2) = 1 AND device_id NOT LIKE '%1'"; +} elseif ($argv[1] == "--even3") { + $where = "AND MOD(device_id,2) = 0 AND device_id NOT LIKE '%2'"; +} elseif ($argv[1] == "--other3") { + $where = "AND (device_id LIKE '%1' OR device_id LIKE '%2')"; + } elseif ($argv[1] == "--all") { - $where = ""; + } else { echo("--device Poll single device\n"); echo("--all Poll all devices\n\n"); @@ -56,11 +63,11 @@ while ($device = mysql_fetch_array($device_query)) { } else { $uptimeoid = "1.3.6.1.2.1.1.3.0"; } - $snmp_cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; + $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'"; if($device['os'] == "IOS" || $device['os'] == "IOS XE") { - $snmp_cmdb = $config['snmpget'] . " -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']; $snmp_cmdb .= " .1.3.6.1.2.1.47.1.1.1.1.13.1"; $snmp_cmdb .= " | grep -v 'Cisco Internetwork Operating System Software'"; $ciscomodel = str_replace("\"", "", trim(`$snmp_cmdb`)); @@ -71,7 +78,7 @@ while ($device = mysql_fetch_array($device_query)) { $snmpdata = trim($snmpdata); $snmpdata = str_replace("\"", "", $snmpdata); list($sysUptime, $sysLocation, $sysContact, $sysName) = explode("\n", $snmpdata); - $sysDescr = trim(shell_exec($config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " sysDescr.0")); + $sysDescr = trim(shell_exec($config['snmpget'] . " -m SNMPv2-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " sysDescr.0")); $sysUptime = str_replace("(", "", $sysUptime); $sysUptime = str_replace(")", "", $sysUptime); list($days, $hours, $mins, $secs) = explode(":", $sysUptime); diff --git a/poll-ifstatus.php b/poll-ifstatus.php index be7a06c405..ab3530a6d6 100755 --- a/poll-ifstatus.php +++ b/poll-ifstatus.php @@ -1,5 +1,6 @@ #!/usr/bin/php diff --git a/poll-reachability.php b/poll-reachability.php index 30ead5d006..c2f2ac76b1 100755 --- a/poll-reachability.php +++ b/poll-reachability.php @@ -23,13 +23,9 @@ while ($device = mysql_fetch_array($device_query)) { $status = trim($status); if(strstr($status, "alive")) { - $pos = shell_exec($config['snmpget'] . " -$snmpver -c $community -t 1 $hostname:$port sysDescr.0"); + $pos = shell_exec($config['snmpget'] . " -m SNMPv2-MIB -$snmpver -c $community -t 1 $hostname:$port sysDescr.0"); if($pos == '') { $status='0'; - $posb = shell_exec($config['snmpget'] . " -$snmpver -c $community -t 1 $hostname:$port 1.3.6.1.2.1.7526.2.4"); - if($posb == '') { } else { - $status='1'; - } } else { $status='1'; } diff --git a/process-syslog.php b/process-syslog.php index e44ff41cfb..ec9b86db41 100755 --- a/process-syslog.php +++ b/process-syslog.php @@ -6,7 +6,8 @@ include("includes/functions.php"); mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%last message repeated%'"); mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%Connection from UDP: [%]:%'"); -mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `program` LIKE 'Traceback%'"); +mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%Traceback%'"); +mysql_query("DELETE FROM `syslog` WHERE `processed` = '0' AND `msg` LIKE '%PM-3-INVALID_BRIDGE_PORT%'"); diff --git a/update-interface.php b/update-interface.php index 92ab7531cf..0f466de5cd 100755 --- a/update-interface.php +++ b/update-interface.php @@ -20,9 +20,9 @@ while ($interface = mysql_fetch_array($interface_query)) { echo("Looking at " . $interface['ifDescr'] . " on " . $device['hostname'] . "\n"); - $snmp_cmd = $config['snmpget'] . " -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ifName." . $interface['ifIndex']; + $snmp_cmd = $config['snmpget'] . " -m IF-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " ifName." . $interface['ifIndex']; $snmp_cmd .= " ifDescr." . $interface['ifIndex'] . " ifAdminStatus." . $interface['ifIndex'] . " ifOperStatus." . $interface['ifIndex'] . " "; - $snmp_cmd .= "ifAlias." . $interface['ifIndex'] . " ifSpeed." . $interface['ifIndex'] . " 1.3.6.1.2.1.10.7.2.1." . $interface['ifIndex']; + $snmp_cmd .= "ifAlias." . $interface['ifIndex'] . " ifSpeed." . $interface['ifIndex']; $snmp_cmd .= " ifType." . $interface['ifIndex'] . " ifMtu." . $interface['ifIndex'] . " ifPhysAddress." . $interface['ifIndex']; $snmp_output = trim(`$snmp_cmd`); @@ -32,7 +32,7 @@ while ($interface = mysql_fetch_array($interface_query)) { if($device['os'] == "IOS") { - $snmp_cmdb = $config['snmpget'] . " -m +CISCO-VLAN-MEMBERSHIP-MIB:CISCO-VTP-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; + $snmp_cmdb = $config['snmpget'] . " -m CISCO-SMI:CISCO-VLAN-MEMBERSHIP-MIB:CISCO-VTP-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; $snmp_cmdb .= " .1.3.6.1.4.1.9.2.2.1.1.1." . $interface['ifIndex']; $snmp_cmdb .= " .1.3.6.1.4.1.9.9.68.1.2.2.1.2." . $interface['ifIndex']; $snmp_cmdb .= " .1.3.6.1.4.1.9.9.46.1.6.1.1.16." . $interface['ifIndex']; @@ -55,7 +55,7 @@ while ($interface = mysql_fetch_array($interface_query)) { if ( $interface['ifVlan'] != $this['ifVlan']) { $update .= $seperator . "`ifVlan` = '" . $this['ifVlan'] . "'"; - echo($update); + #echo($update); $seperator = ", "; mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $interface['device_id'] . "', '" . $interface['interface_id'] . "', NOW(), 'VLAN Vlan -> " . $this['ifVlan'] . "')"); } @@ -65,7 +65,7 @@ while ($interface = mysql_fetch_array($interface_query)) { } - list($ifName, $ifDescr, $ifAdminStatus, $ifOperStatus, $ifAlias, $ifSpeed, $ifDuplex, $ifType, $ifMtu, $ifPhysAddress) = explode("\n", $snmp_output); + list($ifName, $ifDescr, $ifAdminStatus, $ifOperStatus, $ifAlias, $ifSpeed, $ifType, $ifMtu, $ifPhysAddress) = explode("\n", $snmp_output); $ifDescr = trim(str_replace("\"", "", $ifDescr)); if ($ifDuplex == 3) { $ifDuplex = "half"; } elseif ($ifDuplex == 2) { $ifDuplex = "full"; } else { $ifDuplex = "unknown"; } $ifDescr = strtolower($ifDescr); @@ -73,7 +73,7 @@ while ($interface = mysql_fetch_array($interface_query)) { $ifAlias = trim(str_replace("\"", "", $ifAlias)); $ifAlias = trim($ifAlias); - echo("\n$ifName\n"); + #echo("\n$ifName\n"); $ifDescr = fixifname($ifDescr); $ifPhysAddress = strtolower(str_replace("\"", "", $ifPhysAddress));