diff --git a/060-to-current.sql b/060-to-current.sql new file mode 100644 index 000000000..f6e79a785 --- /dev/null +++ b/060-to-current.sql @@ -0,0 +1,77 @@ +ALTER TABLE `interfaces` ADD `pagpOperationMode` VARCHAR( 32 ) NULL; +ALTER TABLE `interfaces` ADD `pagpPortState` VARCHAR( 16 ) NULL; +ALTER TABLE `interfaces` ADD `pagpPartnerDeviceId` VARCHAR( 48 ) NULL; +ALTER TABLE `interfaces` ADD `pagpPartnerLearnMethod` VARCHAR( 16 ) NULL; +ALTER TABLE `interfaces` ADD `pagpPartnerIfIndex` INT NULL; +ALTER TABLE `interfaces` ADD `pagpPartnerGroupIfIndex` INT NULL; +ALTER TABLE `interfaces` ADD `pagpPartnerDeviceName` VARCHAR( 128 ) NULL; +ALTER TABLE `interfaces` ADD `pagpEthcOperationMode` VARCHAR( 16 ) NULL; +ALTER TABLE `interfaces` ADD `pagpDeviceId` VARCHAR( 48 ) NULL; +ALTER TABLE `interfaces` ADD `pagpGroupIfIndex` INT NULL; +ALTER TABLE `interfaces` ADD `portName` VARCHAR( 128 ) NULL DEFAULT NULL AFTER `ifName`; +ALTER TABLE `interfaces` ADD `ifHighSpeed` INT ( 11 ) NULL DEFAULT NULL AFTER `ifSpeed`; +ALTER TABLE `mac_accounting` ADD `cipMacHCSwitchedBytes_input` bigint(20) default NULL; +ALTER TABLE `mac_accounting` ADD `cipMacHCSwitchedBytes_input_prev` bigint(20) default NULL; +ALTER TABLE `mac_accounting` ADD `cipMacHCSwitchedBytes_input_delta` bigint(20) default NULL; +ALTER TABLE `mac_accounting` ADD `cipMacHCSwitchedBytes_input_rate` int(11) default NULL; +ALTER TABLE `mac_accounting` ADD `cipMacHCSwitchedBytes_output` bigint(20) default NULL; +ALTER TABLE `mac_accounting` ADD `cipMacHCSwitchedBytes_output_prev` bigint(20) default NULL; +ALTER TABLE `mac_accounting` ADD `cipMacHCSwitchedBytes_output_delta` bigint(20) default NULL; +ALTER TABLE `mac_accounting` ADD `cipMacHCSwitchedBytes_output_rate` int(11) default NULL; +ALTER TABLE `mac_accounting` ADD `cipMacHCSwitchedPkts_input` bigint(20) default NULL; +ALTER TABLE `mac_accounting` ADD `cipMacHCSwitchedPkts_input_prev` bigint(20) default NULL; +ALTER TABLE `mac_accounting` ADD `cipMacHCSwitchedPkts_input_delta` bigint(20) default NULL; +ALTER TABLE `mac_accounting` ADD `cipMacHCSwitchedPkts_input_rate` int(11) default NULL; +ALTER TABLE `mac_accounting` ADD `cipMacHCSwitchedPkts_output` bigint(20) default NULL; +ALTER TABLE `mac_accounting` ADD `cipMacHCSwitchedPkts_output_prev` bigint(20) default NULL; +ALTER TABLE `mac_accounting` ADD `cipMacHCSwitchedPkts_output_delta` bigint(20) default NULL; +ALTER TABLE `mac_accounting` ADD `cipMacHCSwitchedPkts_output_rate` int(11) default NULL; +ALTER TABLE `mac_accounting` ADD `poll_time` int(11) default NULL; +ALTER TABLE `mac_accounting` ADD `poll_prev` int(11) default NULL; +ALTER TABLE `mac_accounting` ADD `poll_period` int(11) default NULL; +ALTER TABLE `interfaces` ADD `ifInUcastPkts` bigint(20) default NULL; +ALTER TABLE `interfaces` ADD `ifInUcastPkts_prev` bigint(20) default NULL; +ALTER TABLE `interfaces` ADD `ifInUcastPkts_delta` bigint(20) default NULL; +ALTER TABLE `interfaces` ADD `ifInUcastPkts_rate` int(11) default NULL; +ALTER TABLE `interfaces` ADD `ifOutUcastPkts` bigint(20) default NULL; +ALTER TABLE `interfaces` ADD `ifOutUcastPkts_prev` bigint(20) default NULL; +ALTER TABLE `interfaces` ADD `ifOutUcastPkts_delta` bigint(20) default NULL; +ALTER TABLE `interfaces` ADD `ifOutUcastPkts_rate` int(11) default NULL; +ALTER TABLE `interfaces` ADD `ifInErrors` bigint(20) default NULL; +ALTER TABLE `interfaces` ADD `ifInErrors_prev` bigint(20) default NULL; +ALTER TABLE `interfaces` ADD `ifInErrors_delta` bigint(20) default NULL; +ALTER TABLE `interfaces` ADD `ifInErrors_rate` int(11) default NULL; +ALTER TABLE `interfaces` ADD `ifOutErrors` bigint(20) default NULL; +ALTER TABLE `interfaces` ADD `ifOutErrors_prev` bigint(20) default NULL; +ALTER TABLE `interfaces` ADD `ifOutErrors_delta` bigint(20) default NULL; +ALTER TABLE `interfaces` ADD `ifOutErrors_rate` int(11) default NULL; +ALTER TABLE `interfaces` ADD `ifInOctets` bigint(20) default NULL; +ALTER TABLE `interfaces` ADD `ifInOctets_prev` bigint(20) default NULL; +ALTER TABLE `interfaces` ADD `ifInOctets_delta` bigint(20) default NULL; +ALTER TABLE `interfaces` ADD `ifInOctets_rate` int(11) default NULL; +ALTER TABLE `interfaces` ADD `ifOutOctets` bigint(20) default NULL; +ALTER TABLE `interfaces` ADD `ifOutOctets_prev` bigint(20) default NULL; +ALTER TABLE `interfaces` ADD `ifOutOctets_delta` bigint(20) default NULL; +ALTER TABLE `interfaces` ADD `ifOutOctets_rate` int(11) default NULL; +ALTER TABLE `interfaces` ADD `poll_time` int(11) default NULL; +ALTER TABLE `interfaces` ADD `poll_prev` int(11) default NULL; +ALTER TABLE `interfaces` ADD `poll_period` int(11) default NULL; +ALTER TABLE `interfaces` ADD `pagpOperationMode` VARCHAR( 32 ) NULL ; +ALTER TABLE `interfaces` ADD `pagpPortState` VARCHAR( 16 ) NULL ; +ALTER TABLE `interfaces` ADD `pagpPartnerDeviceId` VARCHAR( 48 ) NULL ; +ALTER TABLE `interfaces` ADD `pagpPartnerLearnMethod` VARCHAR( 16 ) NULL ; +ALTER TABLE `interfaces` ADD `pagpPartnerIfIndex` INT NULL ; +ALTER TABLE `interfaces` ADD `pagpPartnerGroupIfIndex` INT NULL ; +ALTER TABLE `interfaces` ADD `pagpPartnerDeviceName` VARCHAR( 128 ) NULL ; +ALTER TABLE `interfaces` ADD `pagpEthcOperationMode` VARCHAR( 16 ) NULL ; +ALTER TABLE `interfaces` ADD `pagpDeviceId` VARCHAR( 48 ) NULL ; +ALTER TABLE `interfaces` ADD `pagpGroupIfIndex` INT NULL ; +ALTER TABLE `interfaces` ADD `ifPromiscuousMode` VARCHAR( 12 ) NULL DEFAULT NULL AFTER `ifSpeed`; +ALTER TABLE `interfaces` ADD `ifConnectorPresent` VARCHAR( 12 ) NULL DEFAULT NULL AFTER `ifSpeed`; +ALTER TABLE `interfaces` ADD `ifName` VARCHAR( 64 ) NULL DEFAULT NULL AFTER `ifDescr`; +ALTER TABLE `interfaces` ADD `portName` VARCHAR( 128 ) NULL DEFAULT NULL AFTER `ifName`; +ALTER TABLE `interfaces` ADD `ifHighSpeed` INT ( 11 ) NULL DEFAULT NULL AFTER `ifSpeed`; +ALTER TABLE `interfaces` DROP `in_rate`; +ALTER TABLE `interfaces` DROP `out_rate`; +ALTER TABLE `interfaces` DROP `in_errors`; +ALTER TABLE `interfaces` DROP `out_errors`; diff --git a/CHANGELOG b/CHANGELOG index e865506f3..f0475428d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -Release 0.6.0 ( ) +Release 0.6.0 ( 28th August 2009 ) Changed IPv6 database structure and discovery *** DATABASE CHANGE *** Added CollectD integration code diff --git a/README b/README index 963cc5c8f..ff3c33189 100644 --- a/README +++ b/README @@ -1,71 +1,48 @@ -README FOR JPGRAPH 3.0.x -======================== +Copyright (C) 2006-2009 Adam Armstrong -This package contains JpGraph, an Object Oriented PHP5 Graph Plotting library. + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. -The library is Copyright (C) 2001-2009 Aditus Consulting and -released under dual license QPL 1.0 for open source and educational -use and JpGraph Professional License for commercial use. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -Please see full license details at http://www.aditus.nu/jpgraph/ + You should have received a copy of the GNU General Public License + along with this program. If not, see . -* -------------------------------------------------------------------- -* PHP4 IS NOT SUPPORTED in the 2.x or 3.x series -* -------------------------------------------------------------------- - -Requirements: -------------- -Miminum: -* PHP 5.1.0 or higher -* GD 2.0.28 or higher -Note: Earlier versions might work but is unsupported. +Please see COPYING for usage requirements and restrictions. -Recommended: -* PHP >= 5.2.0 -* PHP Built-in GD library +Introduction +------------ + +Observer is an auto-discovering network monitoring system. + +It's designed to be an easily-navigable interface to the health of your network. + + + +Planned Features +---------------- + +* CollectD Integration * In Progress +* Full IPv6 capabilities * In Progress +* Pseudowire (MPLS/L2TP) tracking * In Progress +* MPLS IP-VPN tracking * In Progress +* 95th and metered usage tracking * In Progress +* Nagios Integration * Too scary for contempation Installation ------------ -0. Make sure that the PHP version is compatible with the stated requirements - and that the PHP installation has support for the GD library. - Please run phpinfo() to check if GD library - is supported in the installation. - If the GD library doesn't seem to be installed - please consult the PHP manual under section "Image" for - instructions on where to find this library. Please refer to - the manual section "Verifying your PHP installation" - -1. Unzip and copy the files to a directory of your choice where Your - httpd sever can access them. - For a global site installation you should copy the files to - somewhere in the PHP search path. -2. Check that the default directory paths in jpg-config.inc - for cache directory and TTF directory suits your installation. - Note1: The default directories are different depending on if - the library is running on Windows or UNIX. - Note2: Apache/PHP must have write permission to your cache - directory if you enable the cache feature. By default the cache - is disabled. +Installation of Observer is currently not for the faint of heart! There is no automated +install script, so it'll probably take quite a bit of fiddling! -3. Check that all rest of the DEFINE in jpg-config.inc - is setup to your preference. The default should be fine - for most users. +Please see http://www.observernms.org. -4. Read the chapters on installation in the manual. +Please email adama@memetic.org with any feature requests, bug reports or just to tell me +that you're using observer! -Documentation -------------- -The installation includes HTML documentation and reference guide for the -library. The portal page for all the documentation is -/docs/index.html - - -Bug reports and suggestions ---------------------------- -Should be reported using the the issue tracker at - -http://www.aditus.nu/bugtraq - - diff --git a/check-errors.php b/check-errors.php index 7dcd45c47..2e0af9baf 100755 --- a/check-errors.php +++ b/check-errors.php @@ -12,11 +12,9 @@ $i = '0'; $interface_query = mysql_query("SELECT * FROM `interfaces` AS I, `devices` AS D WHERE I.device_id = D.device_id $where"); while ($interface = mysql_fetch_array($interface_query)) { - $rrdfile = $config['rrd_dir'] . "/" . $interface['hostname'] . "/" . $interface['ifIndex'] . ".rrd"; - $errors = interface_errors($rrdfile); - mysql_query("UPDATE `interfaces` SET in_errors = '" . $errors['in'] . "', out_errors = '" . $errors['out'] . "' WHERE interface_id = '" . $interface['interface_id'] . "'"); - if($errors['in'] > '100' || $errors['out'] > '100') { - $errored[] = $interface['hostname'] . " - " . $interface['ifDescr'] . " - " . $interface['ifAlias'] . " - " . $errors['in'] . " - " . $errors['out']; + $errors = $interface['ifInErrors_delta'] + $interface['ifOutErrors_delta']; + if($errors > '1') { + $errored[] = $interface['hostname'] . " - " . $interface['ifDescr'] . " - " . $interface['ifAlias'] . " - " . $interface['ifInErrors_delta'] . " - " . $interface['ifOutErrors_delta']; } $i++; } diff --git a/discover-cdp.php b/discover-cdp.php index db0a22535..6ca754b0e 100755 --- a/discover-cdp.php +++ b/discover-cdp.php @@ -25,19 +25,23 @@ while ($device = mysql_fetch_array($device_query)) { $host = $id; echo("\nDetecting CDP neighbours on $device[1]...\n"); - $snmp = new snmpCDP($hostname, $community); - $ports = $snmp->getports(); - $cdp = $snmp->explore_cdp($ports); +# $snmp = new snmpCDP($hostname, $community); +# $ports = $snmp->getports(); +# $cdp = $snmp->explore_cdp($ports); - $cdp_links = ""; +# $cdp_links = ""; - foreach (array_keys($cdp) as $key) { - $port = $ports[$key]; - $link = $cdp[$key]; - $cdp_links .= $hostname . "," . $port['desc'] . "," . $link['host'] . "," . $link['port'] . "\n"; - } +# foreach (array_keys($cdp) as $key) { +# $port = $ports[$key]; +# $link = $cdp[$key]; +# $cdp_links .= $hostname . "," . $port['desc'] . "," . $link['host'] . "," . $link['port'] . "\n"; +# } - $cdp_links = trim($cdp_links); +# $cdp_links = trim($cdp_links); + + + + foreach ( explode("\n" ,$cdp_links) as $link ) { if ($link == "") { break; } diff --git a/html/graph.php b/html/graph.php index 9f5f72006..1178ae1f7 100644 --- a/html/graph.php +++ b/html/graph.php @@ -1,5 +1,6 @@ ".$config['rrdtool'] . " graph $graphfile $rrd_options"); + $thing = shell_exec($config['rrdtool'] . " graph $graphfile $rrd_options"); + if(is_file($graphfile)) { + header('Content-type: image/png'); + echo(`cat $graphfile`); + } else { + header('Content-type: image/png'); + $string = "Graph Generation Error"; + $im = imagecreate($width, $height); + $orange = imagecolorallocate($im, 255, 255, 255); + $px = (imagesx($im) - 7.5 * strlen($string)) / 2; + imagestring($im, 3, $px, $height / 2 - 8, $string, imagecolorallocate($im, 128, 0, 0)); + imagepng($im); + imagedestroy($im); + } + } else { + switch ($type) { case 'cisco_entity_sensor': $graph = graph_entity_sensor ($_GET['a'], $graphfile, $from, $to, $width, $height, $title, $vertical); @@ -79,7 +96,6 @@ if($_GET['debug']) { $groups = array($_GET['interfaces'], $_GET['interfaces_b'], $_GET['interfaces_c']); $graph = graph_multi_bits_trio ($groups, $graphfile, $from, $to, $width, $height, $title, $vertical, $inverse, $legend); break; - case 'adsl_rate': $graph = graph_adsl_rate ($hostname. "/adsl-4.rrd", $graphfile, $from, $to, $width, $height); break; @@ -102,21 +118,6 @@ if($_GET['debug']) { case 'mac_acc_bits': $graph = graph_mac_acc ($_GET['id'], $graphfile, $from, $to, $width, $height, $title, $vertical); break; - case 'bits': - $graph = graph_bits ($hostname . "/". $ifIndex . ".rrd", $graphfile, $from, $to, $width, $height, $title, $vertical, $inverse, $legend); - break; - case 'pkts': - $graph = pktsgraph ($hostname . "/". $ifIndex . ".rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); - break; - case 'errors': - $graph = errorgraph ($hostname . "/". $ifIndex . ".rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); - break; - case 'nupkts': - $graph = nucastgraph ($hostname . "/". $ifIndex . ".rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); - break; - case 'uptime': - $graph = uptimegraph ($hostname . "/uptime.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); - break; case 'unixfs_dev': $graph = unixfsgraph_dev ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical); break; @@ -134,39 +135,6 @@ if($_GET['debug']) { case 'calls': $graph = callsgraphSNOM ($hostname . "/data.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); break; - case 'ip_graph': - $graph = ip_graph ($hostname . "/netinfo.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); - break; - case 'icmp_graph': - $graph = icmp_graph ($hostname . "/netinfo.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); - break; - case 'tcp_graph': - $graph = tcp_graph ($hostname . "/netinfo.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); - break; - case 'udp_graph': - $graph = udp_graph ($hostname . "/netinfo.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); - break; - case 'cpu': - if($os == "Linux" || $os == "NetBSD" || $os == "FreeBSD" || $os == "DragonFly" || $os == "OpenBSD" || $os == "Windows" || $os == "m0n0wall" || $os == "Voswall" || $os == "pfSense" || $os == "DragonFly" || $os == "OpenBSD") { - $graph = cpugraphUnix ($hostname . "/cpu.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); - } elseif($os == "IOS" || $os == "IOS XE") { - $graph = graph_device_cpmCPU ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical); - } elseif($os == "CatOS") { - $graph = cpugraph ($hostname . "/cpu.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); - } elseif($os == "Windows") { - $graph = cpugraphwin ($hostname . "/cpu.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); - } elseif($os == "ProCurve") { - $graph = cpugraphHP ($hostname . "/cpu.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); - } elseif($os == "Snom") { - $graph = callsgraphSNOM ($hostname . "/data.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); - } elseif($os == "ScreenOS") { - $graph = graph_netscreen_cpu ($hostname . "/netscreen-cpu.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); - } elseif($os == "Fortigate") { - $graph = graph_fortigate_cpu ($hostname . "/fortigate-cpu.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); - } elseif($os == "JunOS") { - $graph = graph_cpu_generic_single($hostname . "/junos-cpu.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); - } - break; case 'dev_cpmCPU': $graph = graph_device_cpmCPU ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical); break; @@ -250,18 +218,12 @@ if($_GET['debug']) { } break; default: - if(is_file($config['install_dir'] . "/html/includes/graphs/$type.inc.php")) { - include($config['install_dir'] . "/html/includes/graphs/$type.inc.php"); - } else { - echo("INCORRECT GRAPH TYPE"); - exit; - } break; - } + } // End SWITCH if($graph) { header('Content-type: image/png'); - echo(`cat graphs/$graphfile`); + echo(`cat $graphfile`); } else { header('Content-type: image/png'); $string = "Graph Generation Error"; @@ -273,6 +235,9 @@ if($_GET['debug']) { imagedestroy($im); } - $delete = `rm graphs/$graphfile`; + $delete = `rm $graphfile`; + + } // End IF + ?> diff --git a/html/includes/.confirm_login.php.swp b/html/includes/.confirm_login.php.swp deleted file mode 100644 index e542b0385..000000000 Binary files a/html/includes/.confirm_login.php.swp and /dev/null differ diff --git a/html/includes/.login.inc.php.swo b/html/includes/.login.inc.php.swo deleted file mode 100644 index e4331bcd5..000000000 Binary files a/html/includes/.login.inc.php.swo and /dev/null differ diff --git a/html/includes/.login.inc.php.swp b/html/includes/.login.inc.php.swp deleted file mode 100644 index f8e57a0a5..000000000 Binary files a/html/includes/.login.inc.php.swp and /dev/null differ diff --git a/html/includes/graphs/cisco_entity_sensor.inc.php b/html/includes/graphs/cisco_entity_sensor.inc.php index b1ef33784..2e226ebb1 100644 --- a/html/includes/graphs/cisco_entity_sensor.inc.php +++ b/html/includes/graphs/cisco_entity_sensor.inc.php @@ -1,25 +1,34 @@ diff --git a/html/includes/graphs/common.inc.php b/html/includes/graphs/common.inc.php index 68b2d7ea7..a386a65ee 100644 --- a/html/includes/graphs/common.inc.php +++ b/html/includes/graphs/common.inc.php @@ -14,8 +14,8 @@ if($_GET['legend'] == "no") { $rrd_options = " -g"; } if(!$scale_min && !$scale_max) { $rrd_options .= " --alt-autoscale-max"; } -if($scale_min) { $rrd_options .= " -l $scale_min"; } -if($scale_max) { $rrd_options .= " -u $scale_max"; } +if(isset($scale_min)) { $rrd_options .= " -l $scale_min"; } +if(isset($scale_max)) { $rrd_options .= " -u $scale_max"; } $rrd_options .= " -E --start ".$from." --end " . ($to - 150) . " --width ".$width." --height ".$height." "; diff --git a/html/includes/graphs/device_cpu.inc.php b/html/includes/graphs/device_cpu.inc.php index ca509d4ca..35c1c64f9 100644 --- a/html/includes/graphs/device_cpu.inc.php +++ b/html/includes/graphs/device_cpu.inc.php @@ -1,6 +1,8 @@ diff --git a/html/includes/graphs/temperature.inc.php b/html/includes/graphs/temperature.inc.php index 6fb6895dd..7ec488eac 100644 --- a/html/includes/graphs/temperature.inc.php +++ b/html/includes/graphs/temperature.inc.php @@ -1,7 +1,12 @@ diff --git a/html/includes/print-device-graph.php b/html/includes/print-device-graph.php index be6aaef48..f6c2fb421 100644 --- a/html/includes/print-device-graph.php +++ b/html/includes/print-device-graph.php @@ -1,23 +1,23 @@ ', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> diff --git a/html/includes/print-interface-graphs.php b/html/includes/print-interface-graphs.inc.php similarity index 53% rename from html/includes/print-interface-graphs.php rename to html/includes/print-interface-graphs.inc.php index 8990089bc..94b20b982 100644 --- a/html/includes/print-interface-graphs.php +++ b/html/includes/print-interface-graphs.inc.php @@ -6,17 +6,17 @@ if(!$device) { $device['device_id'] = getifhost($interface['interface_id']); } - $daily_traffic = $config['base_url'] . "/graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$day&to=$now&width=215&height=100"; - $daily_url = $config['base_url'] . "/graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$day&to=$now&width=500&height=150"; + $daily_traffic = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&type=$graph_type&from=$day&to=$now&width=215&height=100"; + $daily_url = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&type=$graph_type&from=$day&to=$now&width=500&height=150"; - $weekly_traffic = $config['base_url'] . "/graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$week&to=$now&width=215&height=100"; - $weekly_url = $config['base_url'] . "/graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$week&to=$now&width=500&height=150"; + $weekly_traffic = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&type=$graph_type&from=$week&to=$now&width=215&height=100"; + $weekly_url = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&type=$graph_type&from=$week&to=$now&width=500&height=150"; - $monthly_traffic = $config['base_url'] . "/graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$month&to=$now&width=215&height=100"; - $monthly_url = $config['base_url'] . "/graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$month&to=$now&width=500&height=150"; + $monthly_traffic = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&type=$graph_type&from=$month&to=$now&width=215&height=100"; + $monthly_url = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&type=$graph_type&from=$month&to=$now&width=500&height=150"; - $yearly_traffic = $config['base_url'] . "/graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$year&to=$now&width=215&height=100"; - $yearly_url = $config['base_url'] . "/graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$year&to=$now&width=500&height=150"; + $yearly_traffic = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&type=$graph_type&from=$year&to=$now&width=215&height=100"; + $yearly_url = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&type=$graph_type&from=$year&to=$now&width=500&height=150"; echo("', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\"> "); diff --git a/html/includes/print-interface.inc b/html/includes/print-interface.inc.php similarity index 83% rename from html/includes/print-interface.inc rename to html/includes/print-interface.inc.php index 1be30d859..abaa17185 100644 --- a/html/includes/print-interface.inc +++ b/html/includes/print-interface.inc.php @@ -1,5 +1,9 @@ "); +#print_r($interface); +#echo(""); + # This file prints a table row for each interface $interface['device_id'] = $device['device_id']; @@ -11,8 +15,8 @@ if(!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } - if($interface['in_errors'] > 0 || $interface['out_errors'] > 0) { - $error_img = generateiflink($interface,"Interface Errors",errors); + if($interface['ifInErrors_delta'] > 0 || $interface['ifOutErrors_delta'] > 0) { + $error_img = generateiflink($interface,"Interface Errors","port_errors"); } else { $error_img = ""; } if(mysql_result(mysql_query("SELECT count(*) FROM mac_accounting WHERE interface_id = '".$interface['interface_id']."'"),0)){ @@ -48,22 +52,24 @@ echo(""); if($port_details) { - $interface['graph_type'] = "bits"; - echo(generateiflink($interface, "")); - $interface['graph_type'] = "pkts"; - echo(generateiflink($interface, "")); - $interface['graph_type'] = "errors"; - echo(generateiflink($interface, "")); + $interface['graph_type'] = "port_bits"; + echo(generateiflink($interface, "")); + $interface['graph_type'] = "port_upkts"; + echo(generateiflink($interface, "")); + $interface['graph_type'] = "port_errors"; + echo(generateiflink($interface, "")); } echo(""); if($interface['ifOperStatus'] == "up") { + $interface['in_rate'] = $interface['ifInOctets_rate'] * 8; + $interface['out_rate'] = $interface['ifOutOctets_rate'] * 8; $in_perc = @round($interface['in_rate']/$interface['ifSpeed']*100); $out_perc = @round($interface['in_rate']/$interface['ifSpeed']*100); echo(" " . - formatRates($interface['in_rate']) . "
"); + formatRates($interface['in_rate']) . "
".format_bi($interface['ifInUcastPkts_rate'])."pps
"); echo(" " . - formatRates($interface['out_rate']) . ""); + formatRates($interface['out_rate']) . "
".format_bi($interface['ifOutUcastPkts_rate'])."pps"); } echo(""); @@ -198,7 +204,6 @@ echo(""); unset($int_links, $int_links_v6, $int_links_v4, $int_links_phys, $br); - echo(""); // If we're showing graphs, generate the graph and print the img tags @@ -206,17 +211,17 @@ echo(""); $type = $graph_type; - $daily_traffic = "graph.php?if=$if_id&type=" . $graph_type . "&from=$day&to=$now&width=210&height=100"; - $daily_url = "graph.php?if=$if_id&type=" . $graph_type . "&from=$day&to=$now&width=500&height=150"; + $daily_traffic = "graph.php?port=$if_id&type=" . $graph_type . "&from=$day&to=$now&width=210&height=100"; + $daily_url = "graph.php?port=$if_id&type=" . $graph_type . "&from=$day&to=$now&width=500&height=150"; - $weekly_traffic = "graph.php?if=$if_id&type=" . $graph_type . "&from=$week&to=$now&width=210&height=100"; - $weekly_url = "graph.php?if=$if_id&type=" . $graph_type . "&from=$week&to=$now&width=500&height=150"; + $weekly_traffic = "graph.php?port=$if_id&type=" . $graph_type . "&from=$week&to=$now&width=210&height=100"; + $weekly_url = "graph.php?port=$if_id&type=" . $graph_type . "&from=$week&to=$now&width=500&height=150"; - $monthly_traffic = "graph.php?if=$if_id&type=" . $graph_type . "&from=$month&to=$now&width=210&height=100"; - $monthly_url = "graph.php?if=$if_id&type=" . $graph_type . "&from=$month&to=$now&width=500&height=150"; + $monthly_traffic = "graph.php?port=$if_id&type=" . $graph_type . "&from=$month&to=$now&width=210&height=100"; + $monthly_url = "graph.php?port=$if_id&type=" . $graph_type . "&from=$month&to=$now&width=500&height=150"; - $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"; + $yearly_traffic = "graph.php?port=$if_id&type=" . $graph_type . "&from=$year&to=$now&width=210&height=100"; + $yearly_url = "graph.php?port=$if_id&type=" . $graph_type . "&from=$year&to=$now&width=500&height=150"; echo(""); diff --git a/html/includes/topnav.inc b/html/includes/topnav.inc index 6b0463478..f7f65e7f7 100644 --- a/html/includes/topnav.inc +++ b/html/includes/topnav.inc @@ -13,7 +13,7 @@ $interfaces['up'] = mysql_result(mysql_query("SELECT count(*) FROM interfaces AS $interfaces['down'] = mysql_result(mysql_query("SELECT count(*) FROM interfaces AS I, devices AS D WHERE I.ifOperStatus = 'down' AND I.ifAdminStatus = 'up' AND I.ignore = '0' AND D.device_id = I.device_id AND D.ignore = '0'"),0); $interfaces['shutdown'] = mysql_result(mysql_query("SELECT count(*) FROM interfaces AS I, devices AS D WHERE I.ifAdminStatus = 'down' AND I.ignore = '0' AND D.device_id = I.device_id AND D.ignore = '0'"),0); $interfaces['ignored'] = mysql_result(mysql_query("SELECT count(*) FROM interfaces AS I, devices AS D WHERE D.device_id = I.device_id AND ( I.ignore = '1' OR D.ignore = '1')"),0); -$interfaces['errored'] = mysql_result(mysql_query("SELECT count(*) FROM interfaces AS I, devices AS D WHERE D.device_id = I.device_id AND ( I.ignore = '0' OR D.ignore = '0') AND (I.in_errors > '0' OR I.out_errors > '0')"),0); +$interfaces['errored'] = mysql_result(mysql_query("SELECT count(*) FROM interfaces AS I, devices AS D WHERE D.device_id = I.device_id AND ( I.ignore = '0' OR D.ignore = '0') AND (I.ifInErrors_delta > '0' OR I.ifOutErrors_delta > '0')"),0); $services['count'] = mysql_result(mysql_query("SELECT count(service_id) FROM services"),0); diff --git a/html/pages/customers.php b/html/pages/customers.php index 30985d393..be676011b 100644 --- a/html/pages/customers.php +++ b/html/pages/customers.php @@ -35,11 +35,20 @@ list(,$circuit) = preg_split("/[\{\}]/", $interface['ifAlias']); list(,$notes) = preg_split("/[\(\)]/", $interface['ifAlias']); list(,$speed) = preg_split("/[\[\]]/", $interface['ifAlias']); - + $customer = trim($customer); if ($customer == $prev_customer) { unset($customer); } else { + if(isset($prev_customer)) { + echo(" + + + + + "); + } + if(is_integer($customers/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } $customers++; $prev_customer = $customer; diff --git a/html/pages/device/graphs.inc.php b/html/pages/device/graphs.inc.php index fbc446bab..9acf0cc5b 100644 --- a/html/pages/device/graphs.inc.php +++ b/html/pages/device/graphs.inc.php @@ -15,10 +15,10 @@ while($device = mysql_fetch_array($device_query)) { switch ($device['os']) { case "JunOS": echo("
Processor Utilisation
"); - $graph_type = "cpu"; include ("includes/print-device-graph.php"); + $graph_type = "device_cpu"; include ("includes/print-device-graph.php"); 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"); + $graph_type = "dev_temperatures"; include ("includes/print-device-graph.php"); echo("
"); } @@ -73,18 +73,18 @@ while($device = mysql_fetch_array($device_query)) { case "ProCurve": echo("
Processor Utilisation
"); - $graph_type = "cpu"; include ("includes/print-device-graph.php"); + $graph_type = "device_cpu"; include ("includes/print-device-graph.php"); echo("
"); echo("
Memory Usage
"); - $graph_type = "mem"; include ("includes/print-device-graph.php"); + $graph_type = "device_memory"; include ("includes/print-device-graph.php"); echo("
"); echo("
Device Uptime
"); - $graph_type = "uptime"; include ("includes/print-device-graph.php"); break; + $graph_type = "device_uptime"; include ("includes/print-device-graph.php"); break; echo("
"); break; case "Windows": - $graph_type = "cpu"; + $graph_type = "device_cpu"; include ("includes/print-device-graph.php"); $memgraph = memgraphWin ($device[hostname] . "-mem.rrd", $device[hostname] . "-mem.png", $day, $now, 335, 100); @@ -106,31 +106,31 @@ while($device = mysql_fetch_array($device_query)) { case "OpenBSD": case "pfSense": echo("
Processor Utilisation
"); - $graph_type = "cpu"; include ("includes/print-device-graph.php"); + $graph_type = "device_cpu"; include ("includes/print-device-graph.php"); echo("
"); if($device[os] == "m0n0wall" || $device[os] == "pfSense" || $device[os] == "Voswall" || $device[monowall]) { echo("
IP Statistics
"); - $graph_type = "ip_graph"; include ("includes/print-device-graph.php"); + $graph_type = "device_ip"; include ("includes/print-device-graph.php"); echo("
"); echo("
Device Uptime
"); - $graph_type = "uptime"; include ("includes/print-device-graph.php"); + $graph_type = "device_uptime"; include ("includes/print-device-graph.php"); break; } if($device['os'] != "NetBSD") { echo("
Memory Utilisation
"); - $graph_type = "mem"; include ("includes/print-device-graph.php"); + $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 = "unixfs_dev"; include ("includes/print-device-graph.php"); + $graph_type = "device_unixfs"; 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"); + $graph_type = "device_temperatures"; include ("includes/print-device-graph.php"); echo("
"); } @@ -138,35 +138,14 @@ while($device = mysql_fetch_array($device_query)) { include("graphs/uptime.inc.php"); echo("
System Load
"); - $graph_type = "load"; include ("includes/print-device-graph.php"); + $graph_type = "device_load"; include ("includes/print-device-graph.php"); echo("
"); echo("
Users Logged On
"); - $graph_type = "users"; include ("includes/print-device-graph.php"); - echo("
"); + $graph_type = "device_users"; include ("includes/print-device-graph.php"); + echo("
"); echo("
Running Processes
"); - $graph_type = "procs"; include ("includes/print-device-graph.php"); - echo("
"); - if($device[postfix] == '1') { - echo("
Postfix Messages
"); - $graph_type = "postfix"; include ("includes/print-device-graph.php"); - echo("
"); - echo("
Postfix Errors
"); - $graph_type = "postfixerrors"; include ("includes/print-device-graph.php"); - echo("
"); - } - if($device[courier] == '1') { - echo("
Courier IMAP/POP3
"); - $graph_type = "courier"; include ("includes/print-device-graph.php"); - echo("
"); - } - if($device[apache] == '1') { - echo("
Apache Hits
"); - $graph_type = "apachehits"; include ("includes/print-device-graph.php"); - echo("
"); - echo("
Apache Traffic
"); - $graph_type = "apachebits"; include ("includes/print-device-graph.php"); - echo("
"); - } + $graph_type = "device_procs"; include ("includes/print-device-graph.php"); + echo("
"); break; case "CatOS": @@ -177,7 +156,7 @@ while($device = mysql_fetch_array($device_query)) { break; case "Snom": echo("
Calls
"); - $graph_type = "calls"; include ("includes/print-device-graph.php"); + $graph_type = "snom_calls"; include ("includes/print-device-graph.php"); } if($memgraph) { diff --git a/html/pages/device/graphs/netstats.inc.php b/html/pages/device/graphs/netstats.inc.php index 633d179a7..c73392ddc 100644 --- a/html/pages/device/graphs/netstats.inc.php +++ b/html/pages/device/graphs/netstats.inc.php @@ -1,16 +1,16 @@ IP Statistics"); - $graph_type = "ip_graph"; include ("includes/print-device-graph.php"); + $graph_type = "device_ip"; include ("includes/print-device-graph.php"); echo("
"); echo("
TCP Statistics
"); - $graph_type = "tcp_graph"; include ("includes/print-device-graph.php"); + $graph_type = "device_tcp"; include ("includes/print-device-graph.php"); echo("
"); echo("
UDP Statistics
"); - $graph_type = "udp_graph"; include ("includes/print-device-graph.php"); + $graph_type = "device_udp"; include ("includes/print-device-graph.php"); echo("
"); echo("
ICMP Statistics
"); - $graph_type = "icmp_graph"; include ("includes/print-device-graph.php"); + $graph_type = "device_icmp"; include ("includes/print-device-graph.php"); echo("
"); diff --git a/html/pages/device/graphs/os-ios.inc.php b/html/pages/device/graphs/os-ios.inc.php index dfd705925..a406a3c71 100644 --- a/html/pages/device/graphs/os-ios.inc.php +++ b/html/pages/device/graphs/os-ios.inc.php @@ -1,14 +1,14 @@ CPU Usage"); -$graph_type = "cpu"; include ("includes/print-device-graph.php"); +$graph_type = "device_cpu"; include ("includes/print-device-graph.php"); echo("
"); echo("
Memory Usage
"); -$graph_type = "mem"; include ("includes/print-device-graph.php"); +$graph_type = "device_memory"; 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"); + $graph_type = "device_temperatures"; include ("includes/print-device-graph.php"); echo("
"); } diff --git a/html/pages/device/graphs/uptime.inc.php b/html/pages/device/graphs/uptime.inc.php index db16d4757..d9564a1c0 100644 --- a/html/pages/device/graphs/uptime.inc.php +++ b/html/pages/device/graphs/uptime.inc.php @@ -1,7 +1,7 @@ Device Uptime"); - $graph_type = "uptime"; include ("includes/print-device-graph.php"); + $graph_type = "device_uptime"; include ("includes/print-device-graph.php"); echo("
"); diff --git a/html/pages/device/health/temp.inc.php b/html/pages/device/health/temp.inc.php index af3758e5d..4a8f24f85 100644 --- a/html/pages/device/health/temp.inc.php +++ b/html/pages/device/health/temp.inc.php @@ -19,7 +19,7 @@ while($temp = mysql_fetch_array($query)) { \n"); echo(""); - $graph_type = "temp"; + $graph_type = "temperature"; // start temperature graphs diff --git a/html/pages/device/interface.inc.php b/html/pages/device/interface.inc.php index 0219c3dc9..d333b0890 100644 --- a/html/pages/device/interface.inc.php +++ b/html/pages/device/interface.inc.php @@ -29,7 +29,7 @@ $interface = mysql_fetch_array($interface_query); echo("
"); - include("includes/print-interface.inc"); + include("includes/print-interface.inc.php"); echo("
"); @@ -89,26 +89,30 @@ if($_GET['optb']) { include("pages/device/port/".mres($_GET['optb']).".inc.php"); } else { - - if(file_exists("rrd/" . $hostname . "/". $ifIndex . ".rrd")) { + if(file_exists($config['rrd_dir'] . "/" . $hostname . "/". $ifIndex . ".rrd")) { $iid = $id; echo("
Interface Traffic
"); - $graph_type = "bits"; - include("includes/print-interface-graphs.php"); + $graph_type = "port_bits"; + include("includes/print-interface-graphs.inc.php"); echo("
Interface Packets
"); - $graph_type = "pkts"; - include("includes/print-interface-graphs.php"); + $graph_type = "port_upkts"; + include("includes/print-interface-graphs.inc.php"); echo("
Interface Non Unicast
"); - $graph_type = "nupkts"; - include("includes/print-interface-graphs.php"); + $graph_type = "port_nupkts"; + include("includes/print-interface-graphs.inc.php"); echo("
Interface Errors
"); - $graph_type = "errors"; - include("includes/print-interface-graphs.php"); + $graph_type = "port_errors"; + include("includes/print-interface-graphs.inc.php"); + if(is_file($config['rrd_dir'] . "/" . $device['hostname'] . "/etherlike-" . $interface['ifIndex'] . ".rrd")) { + echo("
Ethernet Errors
"); + $graph_type = "port_etherlike"; + include("includes/print-interface-graphs.inc.php"); + } } } diff --git a/html/pages/device/port/macaccounting.inc.php b/html/pages/device/port/macaccounting.inc.php index 91ad5d69f..61a278e57 100644 --- a/html/pages/device/port/macaccounting.inc.php +++ b/html/pages/device/port/macaccounting.inc.php @@ -17,7 +17,7 @@ $i = 1; $inf = fixifName($ifname); - $query = mysql_query("SELECT *, (M.bps_in + M.bps_out) as bps FROM `mac_accounting` AS M, `interfaces` AS I, `devices` AS D WHERE M.interface_id = '".$interface['interface_id']."' AND I.interface_id = M.interface_id AND I.device_id = D.device_id ORDER BY bps DESC"); + echo("
"); if($_GET['optd'] == "top10") { @@ -28,61 +28,103 @@ if($_GET['optc']) { $stat = $_GET['optc']; } else { $stat = "bits"; } + if($_GET['optf']) { + $sort = $_GET['optf']; + } else { $sort = "in"; } + echo("
-
+ -
+
+ Two Day
+ + + +
+
Week
- - + +
-
+
Month
- - + +
-
+
Year
- - + +
- +
-
+
Traffic
- - + +
-
+
Packets
- - + +
+
+ Top Input
+ + + +
+
+ Top Output
+ + + +
+
+ Top Aggregate
+ + + +
+
"); unset($query); - } + } else { + $query = mysql_query("SELECT *, (M.cipMacHCSwitchedBytes_input_rate + M.cipMacHCSwitchedBytes_output_rate) as bps FROM `mac_accounting` AS M, + `interfaces` AS I, `devices` AS D WHERE M.interface_id = '".$interface['interface_id']."' AND I.interface_id = M.interface_id + AND I.device_id = D.device_id ORDER BY bps DESC"); while($acc = mysql_fetch_array($query)) { if(!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } $addy = mysql_fetch_array(mysql_query("SELECT * FROM ipv4_mac where mac_address = '".$acc['mac']."'")); - $name = gethostbyaddr($addy['ipv4_address']); - if($name == $addy['ipv4_address']) { unset ($name); } + #$name = gethostbyaddr($addy['ipv4_address']); + #if($name == $addy['ipv4_address']) { unset ($name); } if(mysql_result(mysql_query("SELECT count(*) FROM bgpPeers WHERE device_id = '".$acc['device_id']."' AND bgpPeerIdentifier = '".$addy['ipv4_address']."'"),0)) { $peer_query = mysql_query("SELECT * FROM bgpPeers WHERE device_id = '".$acc['device_id']."' AND bgpPeerIdentifier = '".$addy['ipv4_address']."'"); $peer_info = mysql_fetch_array($peer_query); @@ -122,8 +164,8 @@ ".mac_clean_to_readable($acc['mac'])." ".$addy['ipv4_address']." ".$name." - ".formatRates($acc['bps_in'])." - ".formatRates($acc['bps_out'])." + ".formatRates($acc['cipMacHCSwitchedBytes_input_rate'] / 8)." + ".formatRates($acc['cipMacHCSwitchedBytes_output_rate'] / 8)." "); @@ -154,4 +196,6 @@ } +} + ?> diff --git a/html/pages/device/ports.inc.php b/html/pages/device/ports.inc.php index 0cabd0b45..7cb232e67 100644 --- a/html/pages/device/ports.inc.php +++ b/html/pages/device/ports.inc.php @@ -7,8 +7,8 @@ echo("ARP Table | Graphs: Bits (Mini) | -Packets -(Mini) | +Packets +(Mini) | NU Packets (Mini) | Errors @@ -17,7 +17,7 @@ echo("
"); diff --git a/html/pages/front/jt.php b/html/pages/front/jt.php index a64355513..4a2046ac5 100644 --- a/html/pages/front/jt.php +++ b/html/pages/front/jt.php @@ -221,11 +221,11 @@ if($_SESSION['userlevel'] >= '5') if($interfaces['wave_broadband']) { echo(""); + "
"); } echo("
"); diff --git a/html/pages/iftype.php b/html/pages/iftype.php index d1493c881..0c378b846 100644 --- a/html/pages/iftype.php +++ b/html/pages/iftype.php @@ -25,7 +25,7 @@ echo(""); echo(""); @@ -52,7 +52,7 @@ echo("
"); $graph_type = "multi_bits"; $interface['interface_id'] = $if_list; - include("includes/print-interface-graphs.php"); + include("includes/print-interface-graphs.inc.php"); echo("
"); if(file_exists($config['rrd_dir'] . "/" . $interface['hostname'] . "/" . $interface['ifIndex'] . ".rrd")) { $graph_type = "bits"; - include("includes/print-interface-graphs.php"); + include("includes/print-interface-graphs.inc.php"); } echo(""); diff --git a/html/pages/interfaces.php b/html/pages/interfaces.php index 1654817eb..f24ffe992 100644 --- a/html/pages/interfaces.php +++ b/html/pages/interfaces.php @@ -102,7 +102,7 @@ if($_GET['type'] == "down" || $_POST['state'] == "down") { } elseif ($_GET['type'] == "admindown" || $_POST['state'] == "admindown") { $where .= "AND I.ifAdminStatus = 'down'"; } elseif ($_GET['type'] == "errors" || $_POST['state'] == "errors") { - $where .= "AND ( I.`out_errors` > '0' OR I.`in_errors` > '0' )"; + $where .= "AND ( I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0' )"; } elseif ($_GET['type'] == "up" || $_POST['state'] == "up") { $where .= "AND I.ifOperStatus = 'up'"; } elseif ($_GET['type'] == "l2vlan" || $_POST['state'] == "l2vlan") { diff --git a/html/pages/vrf.php b/html/pages/vrf.php index 7a3e4117f..36612f791 100644 --- a/html/pages/vrf.php +++ b/html/pages/vrf.php @@ -51,7 +51,7 @@ if($_GET['opta'] == "details" ) { } else { if(is_integer($i/2)) { $int_colour = $list_colour_b_b; } else { $int_colour = $list_colour_b_a; } } - include("includes/print-interface.inc"); + include("includes/print-interface.inc.php"); $i++; } $x++; diff --git a/includes/common.php b/includes/common.php index 9e3a9f8dc..4c7145015 100644 --- a/includes/common.php +++ b/includes/common.php @@ -2,6 +2,12 @@ ## Common Functions +function truncate($substring, $max = 50, $rep = '...'){ + if(strlen($substring) < 1){ $string = $rep; } else { $string = $substring; } + $leave = $max - strlen ($rep); + if(strlen($string) > $max){ return substr_replace($string, $rep, $leave); } else { return $string; } +} + function mres($string) { // short function wrapper because the real one is stupidly long and ugly. aestetics. return mysql_real_escape_string($string); } diff --git a/includes/functions-poller.inc.php b/includes/functions-poller.inc.php new file mode 100644 index 000000000..66fe0c807 --- /dev/null +++ b/includes/functions-poller.inc.php @@ -0,0 +1,128 @@ + diff --git a/includes/functions.php b/includes/functions.php index 06effcceb..3b6b78235 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -215,13 +215,6 @@ function print_message($text) echo("
$text
"); } -function truncate($substring, $max = 50, $rep = '...') -{ - if(strlen($substring) < 1){ $string = $rep; } else { $string = $substring; } - $leave = $max - strlen ($rep); - if(strlen($string) > $max){ return substr_replace($string, $rep, $leave); } else { return $string; } -} - function interface_rates ($rrd_file) // Returns the last in/out value in RRD { global $config; @@ -283,10 +276,10 @@ function generateiflink($interface, $text=0,$type) $interface = ifNameDescr($interface); if(!$text) { $text = fixIfName($interface['label']); } if($type) { $interface['graph_type'] = $type; } - if(!$interface['graph_type']) { $interface['graph_type'] = 'bits'; } + if(!$interface['graph_type']) { $interface['graph_type'] = 'port_bits'; } $class = ifclass($interface['ifOperStatus'], $interface['ifAdminStatus']); - $graph_url = $config['base_url'] . "/graph.php?if=" . $interface['interface_id'] . "&from=$day&to=$now&width=400&height=100&type=" . $interface['graph_type']; - $graph_url_month = $config['base_url'] . "/graph.php?if=" . $interface['interface_id'] . "&from=$month&to=$now&width=400&height=100&type=" . $interface['graph_type']; + $graph_url = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&from=$day&to=$now&width=400&height=100&type=" . $interface['graph_type']; + $graph_url_month = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&from=$month&to=$now&width=400&height=100&type=" . $interface['graph_type']; $device_id = getifhost($interface['interface_id']); $link = "".$device['hostname']." - CPU Load
"; - $link .= "'".$config['overlib_defaults'].", LEFT);\" onmouseout=\"return nd();\">$text"; + $link .= "onmouseover=\"return overlib('
".$device['hostname']." - CPU & Memory Usage
"; + $link .= "
'".$config['overlib_defaults'].", LEFT);\" onmouseout=\"return nd();\">$text"; return $link; } diff --git a/includes/graphing.php b/includes/graphing.php index 5c7026f7f..dfe9273ec 100644 --- a/includes/graphing.php +++ b/includes/graphing.php @@ -7,7 +7,6 @@ include("graphing/unix.php"); function graph_multi_bits_trio ($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 "; $options .= $config['rrdgraph_def_text']; if($height < "99") { $options .= " --only-graph"; } @@ -164,15 +163,14 @@ function graph_multi_bits_trio ($interfaces, $graph, $from, $to, $width, $height } if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal"; } -# echo($config['rrdtool'] . " graph $imgfile $options"); - $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; +# echo($config['rrdtool'] . " graph $graph $options"); + $thing = shell_exec($config['rrdtool'] . " graph $graph $options"); + return $graph; } function graph_multi_bits_duo ($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"; $options .= $config['rrdgraph_def_text']; if($height < "99") { $options .= " --only-graph"; } @@ -282,422 +280,13 @@ function graph_multi_bits_duo ($interfaces, $graph, $from, $to, $width, $height, } 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"); - return $imgfile; -} - -function temp_graph ($temp, $graph, $from, $to, $width, $height, $title, $vertical) { - global $config, $installdir; - $options = " -l 0 -E --start $from --end $to --width $width --height $height "; - $options .= $config['rrdgraph_def_text']; - 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 temperature where temp_id = '$temp'"); - $opts[] = "COMMENT: Cur Max"; - $temperature = mysql_fetch_array(mysql_query("SELECT * FROM temperature where temp_id = '$temp'")); - $hostname = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '" . $temperature['temp_host'] . "'"),0); - - $temperature['temp_descr_fixed'] = str_pad($temperature['temp_descr'], 28); - $temperature['temp_descr_fixed'] = substr($temperature['temp_descr_fixed'],0,28); - - $filename = str_replace(")", "_", str_replace("(", "_", str_replace("/", "_", str_replace(" ", "_",$temperature['temp_descr'])))); - - $temprrd = $config['rrd_dir'] . "/$hostname/temp-" . $filename . ".rrd"; - $opts[] = "DEF:temp=$temprrd:temp:AVERAGE"; - $opts[] = "CDEF:tempwarm=temp,".$temperature[temp_limit].",GT,temp,UNKN,IF"; - $opts[] = "LINE1.5:temp#006600:" . quotemeta($temperature[temp_descr_fixed]); - $opts[] = "LINE1.5:tempwarm#cc0000"; - $opts[] = "GPRINT:temp:LAST:%3.0lf°C"; - $opts[] = "GPRINT:temp:MAX:%3.0lf°C\\\l"; - - foreach($opts as $opt) { - $opt = str_replace(" ","\ ", $opt); - $options .= " $opt"; - } -# echo($config['rrdtool'] . " graph $imgfile $options"); - $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); - 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' "; - $options .= $config['rrdgraph_def_text']; - if($height < "99") { $options .= " --only-graph -u 100 -l 0 -r "; unset ($legend); } - 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 "; - $options .= " -l 0 -E -b 1024 --title '$title' "; - $options .= $config['rrdgraph_def_text']; - if($height < "99") { $options .= " --only-graph -u 100 -l 0 -r "; unset ($legend); } - 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` where `device_id` = '$device'"); - $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'] . "/$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_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' "; - $options .= $config['rrdgraph_def_text']; - if($height < "99") { $options .= " --only-graph -u 100 -l 0 -r "; unset ($legend); } - 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' "; - $options .= $config['rrdgraph_def_text']; - 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; - $options = "--start $from --end $to --width $width --height $height --vertical-label '$vertical' --alt-autoscale-max "; - $options .= " -l 0 -E -b 1024 --title '$title' "; - $options .= $config['rrdgraph_def_text']; - if($height < "99") { $options .= " --only-graph -u 100 -l 0 -r "; unset ($legend); } - 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 temperature where temp_host = '$device'"); - $options .= "COMMENT:\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Cur\ \ \ \ Max\\\\n"; - while($temperature = 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); } - $temperature['temp_descr_fixed'] = str_pad($temperature['temp_descr'], 28); - $temperature['temp_descr_fixed'] = substr($temperature['temp_descr_fixed'],0,28); - $temprrd = addslashes("rrd/$hostname/temp-" . str_replace("/", "_", str_replace(" ", "_",$temperature['temp_descr'])) . ".rrd"); - $temprrd = str_replace(")", "_", $temprrd); - $temprrd = str_replace("(", "_", $temprrd); - $options .= " DEF:temp" . $temperature[temp_id] . "=$temprrd:temp:AVERAGE "; - $options .= " LINE1:temp" . $temperature[temp_id] . "#" . $colour . ":'" . $temperature[temp_descr_fixed] . "' "; - $options .= " GPRINT:temp" . $temperature[temp_id] . ":LAST:%3.0lf\°C "; - $options .= " GPRINT:temp" . $temperature[temp_id] . ":MAX:%3.0lf\°C\\\l "; - $iter++; - } - $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; -} - -function graph_mac_acc ($id, $graph, $from, $to, $width, $height) { - global $config; - $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; - $query = mysql_query("SELECT * FROM `mac_accounting` AS M, `interfaces` AS I, `devices` AS D WHERE M.ma_id = '".$id."' AND I.interface_id = M.interface_id AND I.device_id = D.device_id"); - $acc = mysql_fetch_array($query); - $database = $acc['hostname'] . "/mac-accounting/" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"; - return graph_bits ($database, $graph, $from, $to, $width, $height, $title, $vertical); - -} - -function graph_bits ($rrd, $graph, $from, $to, $width, $height, $title, $vertical, $inverse = '0', $legend = '1') { - global $config; - $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; - $period = $to - $from; - $options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height "; - $options .= $config['rrdgraph_def_text']; - if($height < "99") { $options .= " --only-graph"; unset ($legend); } - if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } - global $_GET; - if($_GET['bg']) { $options .= " -c CANVAS#" . $_GET['bg'] . " "; } - if($inverse) { - $in = 'out'; - $out = 'in'; - } else { - $in = 'in'; - $out = 'out'; - } - if(strstr($database, "mac-accounting")) { - $options .= " DEF:".$out."octets=$database:OUT:AVERAGE"; - $options .= " DEF:".$in."octets=$database:IN:AVERAGE"; - $options .= " DEF:".$out."octets_max=$database:OUT:MAX"; - $options .= " DEF:".$in."octets_max=$database:IN:MAX"; - } else { - $options .= " DEF:".$out."octets=$database:OUTOCTETS:AVERAGE"; - $options .= " DEF:".$in."octets=$database:INOCTETS:AVERAGE"; - $options .= " DEF:".$out."octets_max=$database:OUTOCTETS:MAX"; - $options .= " DEF:".$in."octets_max=$database:INOCTETS:MAX"; - } - - $options .= " CDEF:octets=inoctets,outoctets,+"; - $options .= " CDEF:doutoctets=outoctets,-1,*"; - $options .= " CDEF:inbits=inoctets,8,*"; - $options .= " CDEF:inbits_max=inoctets_max,8,*"; - $options .= " CDEF:outbits_max=outoctets_max,8,*"; - $options .= " CDEF:doutoctets_max=outoctets_max,-1,*"; - $options .= " CDEF:doutbits_max=doutoctets_max,8,*"; - $options .= " CDEF:outbits=outoctets,8,*"; - $options .= " CDEF:doutbits=doutoctets,8,*"; - $options .= " VDEF:totin=inoctets,TOTAL"; - $options .= " VDEF:totout=outoctets,TOTAL"; - $options .= " VDEF:tot=octets,TOTAL"; - $options .= " VDEF:95thin=inbits,95,PERCENT"; - $options .= " VDEF:95thout=outbits,95,PERCENT"; - $options .= " VDEF:d95thout=doutbits,5,PERCENT"; - if ($legend == "no") { - $options .= " AREA:inbits#CDEB8B"; - $options .= " LINE1.25:inbits#006600"; - $options .= " AREA:doutbits#C3D9FF"; - $options .= " LINE1.25:doutbits#000099"; - $options .= " LINE1:95thin#aa0000"; - $options .= " LINE1:d95thout#aa0000"; - } else { - $options .= " AREA:inbits_max#aDEB7B:"; - $options .= " AREA:inbits#CDEB8B:"; - $options .= " COMMENT:BPS\ \ \ \ Current\ \ \ Average\ \ \ \ \ \ Max\ \ \ 95th\ %\\\\n"; - $options .= " LINE1.25:inbits#006600:In\ "; - $options .= " GPRINT:inbits:LAST:%6.2lf%s"; - $options .= " GPRINT:inbits:AVERAGE:%6.2lf%s"; - $options .= " GPRINT:inbits_max:MAX:%6.2lf%s"; - $options .= " GPRINT:95thin:%6.2lf%s\\\\n"; - $options .= " AREA:doutbits_max#a3b9FF:"; - $options .= " AREA:doutbits#C3D9FF:"; - $options .= " LINE1.25:doutbits#000099:Out"; - $options .= " GPRINT:outbits:LAST:%6.2lf%s"; - $options .= " GPRINT:outbits:AVERAGE:%6.2lf%s"; - $options .= " GPRINT:outbits_max:MAX:%6.2lf%s"; - $options .= " GPRINT:95thout:%6.2lf%s\\\\n"; - $options .= " GPRINT:tot:Total\ %6.2lf%s"; - $options .= " GPRINT:totin:\(In\ %6.2lf%s"; - $options .= " GPRINT:totout:Out\ %6.2lf%s\)\\\\l"; - $options .= " LINE1:95thin#aa0000"; - $options .= " LINE1:d95thout#aa0000"; - } - $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; -} - -function pktsgraph ($rrd, $graph, $from, $to, $width, $height) { - global $config, $installdir; - $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; - $options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height "; - $options .= $config['rrdgraph_def_text']; - if($height < "99") { $options .= " --only-graph"; unset ($legend); } - if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } - global $_GET; - if($_GET['bg']) { $options .= " -c CANVAS#" . $_GET['bg'] . " "; } - $options .= " DEF:in=$database:INUCASTPKTS:AVERAGE"; - $options .= " DEF:out=$database:OUTUCASTPKTS:AVERAGE"; - $options .= " CDEF:dout=out,-1,*"; - $options .= " AREA:in#aa66aa:"; - $options .= " COMMENT:Packets\ \ \ \ Current\ \ \ \ \ Average\ \ \ \ \ \ Maximum\\\\n"; - $options .= " LINE1.25:in#330033:In\ \ "; - $options .= " GPRINT:in:LAST:%6.2lf%spps"; - $options .= " GPRINT:in:AVERAGE:%6.2lf%spps"; - $options .= " GPRINT:in:MAX:%6.2lf%spps\\\\n"; - $options .= " AREA:dout#FFDD88:"; - $options .= " LINE1.25:dout#FF6600:Out\ "; - $options .= " GPRINT:out:LAST:%6.2lf%spps"; - $options .= " GPRINT:out:AVERAGE:%6.2lf%spps"; - $options .= " GPRINT:out:MAX:%6.2lf%spps\\\\n"; - $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; -} - -function graph_mac_pkts ($id, $graph, $from, $to, $width, $height) { - global $config, $installdir; - $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; - $query = mysql_query("SELECT * FROM `mac_accounting` AS M, `interfaces` AS I, `devices` AS D WHERE M.ma_id = '".$id."' AND I.interface_id = M.interface_id AND I.device_id = D.device_id"); - $acc = mysql_fetch_array($query); - $database = $config['rrd_dir'] ."/". $acc['hostname'] . "/mac-accounting/" . $acc['ifIndex'] . "-" . $acc['mac'] . "-pkts.rrd"; - $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; - $options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height "; - $options .= $config['rrdgraph_def_text']; - if($height < "99") { $options .= " --only-graph"; unset ($legend); } - if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } - $options .= " DEF:in=$database:IN:AVERAGE"; - $options .= " DEF:out=$database:OUT:AVERAGE"; - $options .= " CDEF:dout=out,-1,*"; - $options .= " AREA:in#aa66aa:"; - $options .= " COMMENT:Packets\ \ \ \ Current\ \ \ \ \ Average\ \ \ \ \ \ Maximum\\\\n"; - $options .= " LINE1.25:in#330033:In\ \ "; - $options .= " GPRINT:in:LAST:%6.2lf%spps"; - $options .= " GPRINT:in:AVERAGE:%6.2lf%spps"; - $options .= " GPRINT:in:MAX:%6.2lf%spps\\\\n"; - $options .= " AREA:dout#FFDD88:"; - $options .= " LINE1.25:dout#FF6600:Out\ "; - $options .= " GPRINT:out:LAST:%6.2lf%spps"; - $options .= " GPRINT:out:AVERAGE:%6.2lf%spps"; - $options .= " GPRINT:out:MAX:%6.2lf%spps\\\\n"; - $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; -} - -function errorgraph ($rrd, $graph, $from, $to, $width, $height) { - global $config, $installdir; - $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; - $options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height "; - $options .= $config['rrdgraph_def_text']; - if($height < "99") { $options .= " --only-graph"; unset ($legend); } - if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } - global $_GET; - if($_GET['bg']) { $options .= " -c CANVAS#" . $_GET['bg'] . " "; } - $options .= " DEF:in=$database:INERRORS:AVERAGE"; - $options .= " DEF:out=$database:OUTERRORS:AVERAGE"; - $options .= " CDEF:dout=out,-1,*"; - $options .= " AREA:in#ff3300:"; - $options .= " COMMENT:Errors\ \ \ \ Current\ \ \ \ \ Average\ \ \ \ \ \ Maximum\\\\n"; - $options .= " LINE1.25:in#ff0000:In\ \ "; - $options .= " GPRINT:in:LAST:%6.2lf%spps"; - $options .= " GPRINT:in:AVERAGE:%6.2lf%spps"; - $options .= " GPRINT:in:MAX:%6.2lf%spps\\\\n"; - $options .= " AREA:dout#FF6633:"; - $options .= " LINE1.25:dout#cc3300:Out\ "; - $options .= " GPRINT:out:LAST:%6.2lf%spps"; - $options .= " GPRINT:out:AVERAGE:%6.2lf%spps"; - $options .= " GPRINT:out:MAX:%6.2lf%spps\\\\n"; - $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; -} - -function nucastgraph ($rrd, $graph, $from, $to, $width, $height) { - global $config, $installdir; - $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; - $options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height "; - $options .= $config['rrdgraph_def_text']; - if($height < "99") { $options .= " --only-graph"; unset ($legend); } - if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } - global $_GET; - if($_GET['bg']) { $options .= " -c CANVAS#" . $_GET['bg'] . " "; } - $options .= " DEF:in=$database:INNUCASTPKTS:AVERAGE"; - $options .= " DEF:out=$database:OUTNUCASTPKTS:AVERAGE"; - $options .= " CDEF:dout=out,-1,*"; - $options .= " AREA:in#aa66aa:"; - $options .= " COMMENT:Packets\ \ \ \ Current\ \ \ \ \ Average\ \ \ \ \ \ Maximum\\\\n"; - $options .= " LINE1.25:in#330033:In\ \ "; - $options .= " GPRINT:in:LAST:%6.2lf%spps"; - $options .= " GPRINT:in:AVERAGE:%6.2lf%spps"; - $options .= " GPRINT:in:MAX:%6.2lf%spps\\\\n"; - $options .= " AREA:dout#FFDD88:"; - $options .= " LINE1.25:dout#FF6600:Out\ "; - $options .= " GPRINT:out:LAST:%6.2lf%spps"; - $options .= " GPRINT:out:AVERAGE:%6.2lf%spps"; - $options .= " GPRINT:out:MAX:%6.2lf%spps\\\\n"; - $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; + $thing = shell_exec($config['rrdtool'] . " graph $graph $options"); + return $graph; } function graph_cbgp_prefixes ($rrd, $graph, $from, $to, $width, $height) { global $config; $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; $options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height "; $options .= $config['rrdgraph_def_text']; if($width <= "300") {$options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } @@ -718,16 +307,15 @@ function graph_cbgp_prefixes ($rrd, $graph, $from, $to, $width, $height) { #$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; + $thing = shell_exec($config['rrdtool'] . " graph $graph $options"); +# echo($config['rrdtool'] . " graph $graph $options"); + return $graph; } function bgpupdatesgraph ($rrd, $graph , $from, $to, $width, $height) { global $config, $installdir; $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; $options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height "; $options .= $config['rrdgraph_def_text']; if($width <= "300") {$options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } @@ -745,44 +333,13 @@ function bgpupdatesgraph ($rrd, $graph , $from, $to, $width, $height) { $options .= " GPRINT:out:LAST:%6.2lf%sU/s"; $options .= " GPRINT:out:AVERAGE:%6.2lf%sU/s"; $options .= " GPRINT:out:MAX:%6.2lf%sU/s\\\\n"; - $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; + $thing = shell_exec($config['rrdtool'] . " graph $graph $options"); + return $graph; } -function graph_entity_sensor ($sensor, $graph , $from, $to, $width, $height, $title, $vertical) { - global $config; - $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; - $sensor = mysql_fetch_array(mysql_query("SELECT * FROM entPhysical as E, devices as D WHERE entPhysical_id = '$sensor' and D.device_id = E.device_id")); - $database = $config['rrd_dir'] . "/" . $sensor['hostname'] . "/ces-" . $sensor['entPhysicalIndex'] . ".rrd"; - $options = "--alt-autoscale-max -l 0 -E --start $from --end $to --width $width --height $height "; - $options .= $config['rrdgraph_def_text']; - if($height < "99") { $options .= " --only-graph -u 100 -l 0 -r "; unset ($legend); } - if($width <= "300") {$options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } - $type = str_pad($sensor['entSensorType'], 8); - $type = substr($type,0,8); - $options .= " DEF:avg=$database:value:AVERAGE"; - $options .= " DEF:min=$database:value:MIN"; - $options .= " DEF:max=$database:value:MAX"; - $options .= " COMMENT:' Last Min Max Ave\\n'"; - $options .= " AREA:max#a5a5a5"; - $options .= " AREA:min#ffffff"; - $options .= " LINE1.25:avg#aa2200:'".$type."'"; - - $options .= " GPRINT:avg:AVERAGE:%5.2lf%s"; - $options .= " GPRINT:max:MAX:%5.2lf%s"; - $options .= " GPRINT:max:MAX:%5.2lf%s"; - $options .= " GPRINT:avg:LAST:%5.2lf%s"; - - $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); - #echo($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; -} - - function graph_cpu_generic_single ($rrd, $graph , $from, $to, $width, $height) { global $config; $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; $options = "--alt-autoscale-max -l 0 -E --start $from --end $to --width $width --height $height "; $options .= $config['rrdgraph_def_text']; if($width <= "300") {$options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } @@ -791,15 +348,14 @@ function graph_cpu_generic_single ($rrd, $graph , $from, $to, $width, $height) { $options .= " AREA:cpu#ffee99: LINE1.25:cpu#aa2200:Load\ %"; $options .= " GPRINT:cpu:LAST:%6.2lf\ GPRINT:cpu:AVERAGE:%6.2lf\ "; $options .= " GPRINT:cpu:MAX:%6.2lf\ GPRINT:cpu:AVERAGE:%6.2lf\\\\n"; - $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; + $thing = shell_exec($config['rrdtool'] . " graph $graph $options"); + return $graph; } function graph_adsl_rate ($rrd, $graph, $from, $to, $width, $height) { global $config, $installdir; $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; $options = "--alt-autoscale-max -l 0 -E --start $from --end $to --width $width --height $height "; $options .= $config['rrdgraph_def_text']; if($width <= "300") {$options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } @@ -814,14 +370,13 @@ function graph_adsl_rate ($rrd, $graph, $from, $to, $width, $height) { $options .= " LINE1.25:adslAturCurrAtt#22aa00:Down\ \ "; $options .= " GPRINT:dslAturCurrAtt:LAST:%5.0lfk\ GPRINT:dslAturCurrAtt:AVERAGE:%5.0lfk\ "; $options .= " GPRINT:dslAturCurrAtt:MAX:%5.0lfk\ GPRINT:dslAturCurrAtt:AVERAGE:%5.0lfk\\\\n"; - $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; + $thing = shell_exec($config['rrdtool'] . " graph $graph $options"); + return $graph; } function graph_adsl_snr ($rrd, $graph, $from, $to, $width, $height) { global $config, $installdir; $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; $options = "--alt-autoscale-max -l 0 -E --start $from --end $to --width $width --height $height "; $options .= $config['rrdgraph_def_text']; if($width <= "300") {$options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } @@ -836,14 +391,13 @@ function graph_adsl_snr ($rrd, $graph, $from, $to, $width, $height) { $options .= " LINE1.25:dslAturCurrSnr#22aa00:SNR\ Down"; $options .= " GPRINT:dslAturCurrSnr:LAST:%3.1lfdB GPRINT:dslAturCurrSnr:AVERAGE:%3.1lfdB\ "; $options .= " GPRINT:dslAturCurrSnr:MAX:%3.1lfdB GPRINT:dslAturCurrSnr:AVERAGE:%3.1lfdB\\\\n"; - $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; + $thing = shell_exec($config['rrdtool'] . " graph $graph $options"); + return $graph; } function graph_adsl_atn ($rrd, $graph, $from, $to, $width, $height) { global $config, $installdir; $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; $options = "--alt-autoscale-max -l 0 -E --start $from --end $to --width $width --height $height "; $options .= $config['rrdgraph_def_text']; if($width <= "300") {$options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } @@ -858,14 +412,13 @@ function graph_adsl_atn ($rrd, $graph, $from, $to, $width, $height) { $options .= " LINE1.25:dslAturCurrAtn#22aa00:Atten\ Down"; $options .= " GPRINT:dslAturCurrAtn:LAST:%3.1lfdB GPRINT:dslAturCurrAtn:AVERAGE:%3.1lfdb"; $options .= " GPRINT:dslAturCurrAtn:MAX:%3.1lfdB GPRINT:dslAturCurrAtn:AVERAGE:%3.1lfdb\\\\n"; - $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; + $thing = shell_exec($config['rrdtool'] . " graph $graph $options"); + return $graph; } function cpugraph ($rrd, $graph , $from, $to, $width, $height) { global $config, $installdir; $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; $options = "--alt-autoscale-max -l 0 -E --start $from --end $to --width $width --height $height "; $options .= $config['rrdgraph_def_text']; if($width <= "300") {$options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } @@ -875,32 +428,13 @@ function cpugraph ($rrd, $graph , $from, $to, $width, $height) { $options .= " AREA:5m#ffee99: LINE1.25:5m#aa2200:Load\ %"; $options .= " GPRINT:5m:LAST:%6.2lf\ GPRINT:5m:AVERAGE:%6.2lf\ "; $options .= " GPRINT:5m:MAX:%6.2lf\ GPRINT:5m:AVERAGE:%6.2lf\\\\n"; - $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; -} - -function uptimegraph ($rrd, $graph , $from, $to, $width, $height, $title, $vertical) { - global $config, $installdir; - $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; - $options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height "; - $options .= $config['rrdgraph_def_text']; - if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } - $options .= " DEF:uptime=$database:uptime:AVERAGE"; - $options .= " CDEF:cuptime=uptime,86400,/"; - $options .= " COMMENT:Days\ \ \ \ \ \ Current\ \ Minimum\ \ Maximum\ \ Average\\\\n"; - $options .= " AREA:cuptime#EEEEEE:Uptime"; - $options .= " LINE1.25:cuptime#36393D:"; - $options .= " GPRINT:cuptime:LAST:%6.2lf\ GPRINT:cuptime:AVERAGE:%6.2lf\ "; - $options .= " GPRINT:cuptime:MAX:%6.2lf\ GPRINT:cuptime:AVERAGE:%6.2lf\\\\n"; - $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; + $thing = shell_exec($config['rrdtool'] . " graph $graph $options"); + return $graph; } function memgraph ($rrd, $graph , $from, $to, $width, $height, $title, $vertical) { global $config, $installdir; $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; $period = $to - $from; $options = "-l 0 --alt-autoscale-max -E --start $from --end $to --width $width --height $height "; $options .= $config['rrdgraph_def_text']; @@ -925,190 +459,8 @@ function memgraph ($rrd, $graph , $from, $to, $width, $height, $title, $vertical $options .= " GPRINT:FREE:MAX:%6.2lf%s"; $options .= " GPRINT:FREE:AVERAGE:%6.2lf%s\\\\l"; $options .= " LINE1:MEMTOTAL#000000:"; - $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; + $thing = shell_exec($config['rrdtool'] . " graph $graph $options"); + return $graph; } -function ip_graph ($rrd, $graph, $from, $to, $width, $height) { - global $config, $installdir; - $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; - $period = $to - $from; - $options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height "; - $options .= $config['rrdgraph_def_text']; - if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } - $options .= " DEF:ipForwDatagrams=$database:ipForwDatagrams:AVERAGE"; - $options .= " DEF:ipInDelivers=$database:ipInDelivers:AVERAGE"; - $options .= " DEF:ipInReceives=$database:ipInReceives:AVERAGE"; - $options .= " DEF:ipOutRequests=$database:ipOutRequests:AVERAGE"; - $options .= " DEF:ipInDiscards=$database:ipInDiscards:AVERAGE"; - $options .= " DEF:ipOutDiscards=$database:ipOutDiscards:AVERAGE"; - $options .= " DEF:ipOutNoRoutes=$database:ipInDiscards:AVERAGE"; - $options .= " COMMENT:Packets/sec\ \ \ \ Current\ \ \ Average\ \ \ Maximum\\\n"; - $options .= " LINE1.25:ipForwDatagrams#cc0000:ForwDgrams\ "; - $options .= " GPRINT:ipForwDatagrams:LAST:%6.2lf%s"; - $options .= " GPRINT:ipForwDatagrams:AVERAGE:\ %6.2lf%s"; - $options .= " GPRINT:ipForwDatagrams:MAX:\ %6.2lf%s\\\\n"; - $options .= " LINE1.25:ipInDelivers#00cc00:InDelivers\ "; - $options .= " GPRINT:ipInDelivers:LAST:%6.2lf%s"; - $options .= " GPRINT:ipInDelivers:AVERAGE:\ %6.2lf%s"; - $options .= " GPRINT:ipInDelivers:MAX:\ %6.2lf%s\\\\n"; - $options .= " LINE1.25:ipInReceives#006600:InReceives\ "; - $options .= " GPRINT:ipInReceives:LAST:%6.2lf%s"; - $options .= " GPRINT:ipInReceives:AVERAGE:\ %6.2lf%s"; - $options .= " GPRINT:ipInReceives:MAX:\ %6.2lf%s\\\\n"; - $options .= " LINE1.25:ipOutRequests#0000cc:OutRequests"; - $options .= " GPRINT:ipOutRequests:LAST:%6.2lf%s"; - $options .= " GPRINT:ipOutRequests:AVERAGE:\ %6.2lf%s"; - $options .= " GPRINT:ipOutRequests:MAX:\ %6.2lf%s\\\\n"; - $options .= " LINE1.25:ipInDiscards#cccc00:InDiscards\ "; - $options .= " GPRINT:ipInDiscards:LAST:%6.2lf%s"; - $options .= " GPRINT:ipInDiscards:AVERAGE:\ %6.2lf%s"; - $options .= " GPRINT:ipInDiscards:MAX:\ %6.2lf%s\\\\n"; - $options .= " LINE1.25:ipOutDiscards#330033:OutDiscards"; - $options .= " GPRINT:ipOutDiscards:LAST:%6.2lf%s"; - $options .= " GPRINT:ipOutDiscards:AVERAGE:\ %6.2lf%s"; - $options .= " GPRINT:ipOutDiscards:MAX:\ %6.2lf%s\\\\n"; - $options .= " LINE1.25:ipOutNoRoutes#660000:OutNoRoutes"; - $options .= " GPRINT:ipOutNoRoutes:LAST:%6.2lf%s"; - $options .= " GPRINT:ipOutNoRoutes:AVERAGE:\ %6.2lf%s"; - $options .= " GPRINT:ipOutNoRoutes:MAX:\ %6.2lf%s\\\\n"; - $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; -} - -function icmp_graph ($rrd, $graph, $from, $to, $width, $height) { - global $config, $installdir; - $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; - $period = $to - $from; - $options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height "; - $options .= $config['rrdgraph_def_text']; - if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } $options .= "DEF:icmpInMsgs=$database:icmpInMsgs:AVERAGE"; - $options .= " DEF:icmpOutMsgs=$database:icmpOutMsgs:AVERAGE"; - $options .= " DEF:icmpInErrors=$database:icmpInErrors:AVERAGE"; - $options .= " DEF:icmpOutErrors=$database:icmpOutErrors:AVERAGE"; - $options .= " DEF:icmpInEchos=$database:icmpInEchos:AVERAGE"; - $options .= " DEF:icmpOutEchos=$database:icmpOutEchos:AVERAGE"; - $options .= " DEF:icmpInEchoReps=$database:icmpInEchoReps:AVERAGE"; - $options .= " DEF:icmpOutEchoReps=$database:icmpOutEchoReps:AVERAGE"; - $options .= " COMMENT:Packets/sec\ \ \ \ Current\ \ \ \ Average\ \ \ Maximum\\\\n"; - $options .= " LINE1.25:icmpInMsgs#00cc00:InMsgs "; - $options .= " GPRINT:icmpInMsgs:LAST:\ \ \ \ \ %6.2lf%s"; - $options .= " GPRINT:icmpInMsgs:AVERAGE:\ \ %6.2lf%s"; - $options .= " GPRINT:icmpInMsgs:MAX:\ %6.2lf%s\\\\n"; - $options .= " LINE1.25:icmpOutMsgs#006600:OutMsgs "; - $options .= " GPRINT:icmpOutMsgs:LAST:\ \ \ \ %6.2lf%s"; - $options .= " GPRINT:icmpOutMsgs:AVERAGE:\ \ %6.2lf%s"; - $options .= " GPRINT:icmpOutMsgs:MAX:\ %6.2lf%s\\\\n"; - $options .= " LINE1.25:icmpInErrors#cc0000:InErrors "; - $options .= " GPRINT:icmpInErrors:LAST:\ \ \ %6.2lf%s"; - $options .= " GPRINT:icmpInErrors:AVERAGE:\ \ %6.2lf%s"; - $options .= " GPRINT:icmpInErrors:MAX:\ %6.2lf%s\\\\n"; - $options .= " LINE1.25:icmpOutErrors#660000:OutErrors "; - $options .= " GPRINT:icmpOutErrors:LAST:\ \ %6.2lf%s"; - $options .= " GPRINT:icmpOutErrors:AVERAGE:\ \ %6.2lf%s"; - $options .= " GPRINT:icmpOutErrors:MAX:\ %6.2lf%s\\\\n"; - $options .= " LINE1.25:icmpInEchos#0066cc:InEchos "; - $options .= " GPRINT:icmpInEchos:LAST:\ \ \ \ %6.2lf%s"; - $options .= " GPRINT:icmpInEchos:AVERAGE:\ \ %6.2lf%s"; - $options .= " GPRINT:icmpInEchos:MAX:\ %6.2lf%s\\\\n"; - $options .= " LINE1.25:icmpOutEchos#003399:OutEchos "; - $options .= " GPRINT:icmpOutEchos:LAST:\ \ \ %6.2lf%s"; - $options .= " GPRINT:icmpOutEchos:AVERAGE:\ \ %6.2lf%s"; - $options .= " GPRINT:icmpOutEchos:MAX:\ %6.2lf%s\\\\n"; - $options .= " LINE1.25:icmpInEchoReps#cc00cc:InEchoReps "; - $options .= " GPRINT:icmpInEchoReps:LAST:\ %6.2lf%s"; - $options .= " GPRINT:icmpInEchoReps:AVERAGE:\ \ %6.2lf%s"; - $options .= " GPRINT:icmpInEchoReps:MAX:\ %6.2lf%s\\\\n"; - $options .= " LINE1.25:icmpOutEchoReps#990099:OutEchoReps"; - $options .= " GPRINT:icmpOutEchoReps:LAST:%6.2lf%s"; - $options .= " GPRINT:icmpOutEchoReps:AVERAGE:\ %6.2lf%s"; - $options .= " GPRINT:icmpOutEchoReps:MAX:\ %6.2lf%s\\\\n"; - $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; -} - -function tcp_graph ($rrd, $graph, $from, $to, $width, $height) { - global $config, $installdir; - $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; - $period = $to - $from; - $options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height "; - $options .= $config['rrdgraph_def_text']; - if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } $options .= "DEF:icmpInMsgs=$database:icmpInMsgs:AVERAGE"; - $options .= " DEF:tcpActiveOpens=$database:tcpActiveOpens:AVERAGE"; - $options .= " DEF:tcpPassiveOpens=$database:tcpPassiveOpens:AVERAGE"; - $options .= " DEF:tcpAttemptFails=$database:tcpAttemptFails:AVERAGE"; - $options .= " DEF:tcpEstabResets=$database:tcpEstabResets:AVERAGE"; - $options .= " DEF:tcpInSegs=$database:tcpInSegs:AVERAGE"; - $options .= " DEF:tcpOutSegs=$database:tcpOutSegs:AVERAGE"; - $options .= " DEF:tcpRetransSegs=$database:tcpRetransSegs:AVERAGE"; - $options .= " COMMENT:Packets/sec\ \ \ \ Current\ \ \ \ Average\ \ \ Maximum\\\n"; - $options .= " LINE1.25:tcpActiveOpens#00cc00:ActiveOpens\ "; - $options .= " GPRINT:tcpActiveOpens:LAST:%6.2lf%s"; - $options .= " GPRINT:tcpActiveOpens:AVERAGE:\ %6.2lf%s"; - $options .= " GPRINT:tcpActiveOpens:MAX:\ %6.2lf%s\\\\n"; - $options .= " LINE1.25:tcpPassiveOpens#006600:PassiveOpens"; - $options .= " GPRINT:tcpPassiveOpens:LAST:%6.2lf%s"; - $options .= " GPRINT:tcpPassiveOpens:AVERAGE:\ %6.2lf%s"; - $options .= " GPRINT:tcpPassiveOpens:MAX:\ %6.2lf%s\\\\n"; - $options .= " LINE1.25:tcpAttemptFails#cc0000:AttemptFails"; - $options .= " GPRINT:tcpAttemptFails:LAST:%6.2lf%s"; - $options .= " GPRINT:tcpAttemptFails:AVERAGE:\ %6.2lf%s"; - $options .= " GPRINT:tcpAttemptFails:MAX:\ %6.2lf%s\\\\n"; - $options .= " LINE1.25:tcpEstabResets#660000:EstabResets\ "; - $options .= " GPRINT:tcpEstabResets:LAST:%6.2lf%s"; - $options .= " GPRINT:tcpEstabResets:AVERAGE:\ %6.2lf%s"; - $options .= " GPRINT:tcpEstabResets:MAX:\ %6.2lf%s\\\\n"; - $options .= " LINE1.25:tcpInSegs#0066cc:InSegs\ \ \ \ \ \ "; - $options .= " GPRINT:tcpInSegs:LAST:%6.2lf%s"; - $options .= " GPRINT:tcpInSegs:AVERAGE:\ %6.2lf%s"; - $options .= " GPRINT:tcpInSegs:MAX:\ %6.2lf%s\\\\n"; - $options .= " LINE1.25:tcpOutSegs#003399:OutSegs\ \ \ \ \ "; - $options .= " GPRINT:tcpOutSegs:LAST:%6.2lf%s"; - $options .= " GPRINT:tcpOutSegs:AVERAGE:\ %6.2lf%s"; - $options .= " GPRINT:tcpOutSegs:MAX:\ %6.2lf%s\\\\n"; - $options .= " LINE1.25:tcpRetransSegs#cc00cc:RetransSegs\ "; - $options .= " GPRINT:tcpRetransSegs:LAST:%6.2lf%s"; - $options .= " GPRINT:tcpRetransSegs:AVERAGE:\ %6.2lf%s"; - $options .= " GPRINT:tcpRetransSegs:MAX:\ %6.2lf%s\\\\n"; - $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; -} - -function udp_graph ($rrd, $graph, $from, $to, $width, $height) { - global $config, $installdir; - $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = $config['install_dir'] . "/graphs/" . "$graph"; - $period = $to - $from; - $options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height "; - $options .= $config['rrdgraph_def_text']; - if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } $options .= "DEF:icmpInMsgs=$database:icmpInMsgs:AVERAGE"; - $options .= " DEF:udpInDatagrams=$database:udpInDatagrams:AVERAGE"; - $options .= " DEF:udpOutDatagrams=$database:udpOutDatagrams:AVERAGE"; - $options .= " DEF:udpInErrors=$database:udpInErrors:AVERAGE"; - $options .= " DEF:udpNoPorts=$database:udpNoPorts:AVERAGE"; - $options .= " COMMENT:Packets/sec\ \ \ \ Current\ \ \ \ Average\ \ \ Maximum\\\\n"; - $options .= " LINE1.25:udpInDatagrams#00cc00:InDatagrams\ "; - $options .= " GPRINT:udpInDatagrams:LAST:%6.2lf%s"; - $options .= " GPRINT:udpInDatagrams:AVERAGE:\ %6.2lf%s"; - $options .= " GPRINT:udpInDatagrams:MAX:\ %6.2lf%s\\\\n"; - $options .= " LINE1.25:udpOutDatagrams#006600:OutDatagrams"; - $options .= " GPRINT:udpOutDatagrams:LAST:%6.2lf%s"; - $options .= " GPRINT:udpOutDatagrams:AVERAGE:\ %6.2lf%s"; - $options .= " GPRINT:udpOutDatagrams:MAX:\ %6.2lf%s\\\\n"; - $options .= " LINE1.25:udpInErrors#cc0000:InErrors\ \ \ \ "; - $options .= " GPRINT:udpInErrors:LAST:%6.2lf%s"; - $options .= " GPRINT:udpInErrors:AVERAGE:\ %6.2lf%s"; - $options .= " GPRINT:udpInErrors:MAX:\ %6.2lf%s\\\\n"; - $options .= " LINE1.25:udpNoPorts#660000:NoPorts\ \ \ \ \ "; - $options .= " GPRINT:udpNoPorts:LAST:%6.2lf%s"; - $options .= " GPRINT:udpNoPorts:AVERAGE:\ %6.2lf%s"; - $options .= " GPRINT:udpNoPorts:MAX:\ %6.2lf%s\\\\n"; - $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; -} - - ?> diff --git a/includes/graphing/unix.php b/includes/graphing/unix.php index a5ed4e9de..d7e53b271 100755 --- a/includes/graphing/unix.php +++ b/includes/graphing/unix.php @@ -1,9 +1,9 @@ $b_in:$b_out:$p_in:$p_out ");} + $rrdfile = $host_rrd . "/cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"; + + if(!is_file($rrdfile)) { + $woo = shell_exec($config['rrdtool'] ." create $rrdfile \ + DS:IN:COUNTER:600:0:12500000000 \ + DS:OUT:COUNTER:600:0:12500000000 \ + DS:PIN:COUNTER:600:0:12500000000 \ + DS:POUT:COUNTER:600:0:12500000000 \ + 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"); + } + $woo = "N:".($b_in+0).":".($b_out+0).":".($p_in+0).":".($p_out+0); + if($debug) {echo("\n rrdtool update $rrdfile $woo");} + $ret = rrdtool_update("$rrdfile", $woo); + + if ($update) { /// Do Updates + $update_query = "UPDATE `mac_accounting` SET ".$update." WHERE `ma_id` = '" . $acc['ma_id'] . "'"; + @mysql_query($update_query); $mysql++; + if($debug) {echo("\nMYSQL : [ $update_query ]");} + } /// End Updates + unset($update_query); unset($update); + + } +} + +if($mac_entries) { echo("$mac_entries mac accounting entries updated\n"); } + +?> diff --git a/includes/polling/interfaces.inc.php b/includes/polling/interfaces.inc.php index cee6eb951..5c72bbcf6 100644 --- a/includes/polling/interfaces.inc.php +++ b/includes/polling/interfaces.inc.php @@ -3,7 +3,7 @@ if($device['os'] == "CatOS" || $device['os'] == "IOS") { $portifIndex = array(); $cmd = $config['snmpwalk'] . " -CI -m CISCO-STACK-MIB -O q -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " portIfIndex"; - echo("$cmd"); + #echo("$cmd"); $portifIndex_output = trim(shell_exec($cmd)); foreach(explode("\n", $portifIndex_output) as $entry){ $entry = str_replace("CISCO-STACK-MIB::portIfIndex.", "", $entry); @@ -118,7 +118,7 @@ while ($interface = mysql_fetch_array($interface_query)) { $update_query = "UPDATE `interfaces` SET "; $update_query .= $update; $update_query .= " WHERE `interface_id` = '" . $interface['interface_id'] . "'"; - echo("Updating : " . $device['hostname'] . " $ifDescr\nSQL :$update_query\n\n"); + #echo("Updating : " . $device['hostname'] . " $ifDescr\nSQL :$update_query\n\n"); $update_result = mysql_query($update_query); } else { # echo("Not Updating : " . $device['hostname'] ." $ifDescr ( " . $interface['ifDescr'] . " )\n\n"); @@ -147,7 +147,7 @@ while ($interface = mysql_fetch_array($interface_query)) { $ret = rrdtool_update("$rrdfile", $woo); } else { - echo("Interface " . $device['hostname'] . " " . $interface['ifDescr'] . " is down\n"); + #echo("Interface " . $device['hostname'] . " " . $interface['ifDescr'] . " is down\n"); } } diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php new file mode 100755 index 000000000..02f5dd894 --- /dev/null +++ b/includes/polling/ports.inc.php @@ -0,0 +1,167 @@ + (count($ports)*2.5)) { /// If there are 2.5x more interfaces than OIDs, do per-OID + $sub_start = utime(); + echo("Caching Ports: "); + foreach($ports as $port) { echo("$port "); $array = snmp_cache_port_oids($ifmib_oids, $port, $device, $array, "IF-MIB"); } + $end = utime(); $run = $end - $sub_start; $proctime = substr($run, 0, 5); + #echo("\n$proctime secs\n"); + } else { + $sub_start = utime(); + echo("Caching Oids: "); + foreach ($ifmib_oids as $oid) { echo("$oid "); $array = snmp_cache_oid($oid, $device, $array, "IF-MIB"); } + $end = utime(); $run = $end - $sub_start; $proctime = substr($run, 0, 5); + #echo("\n$proctime secs\n"); + } + + #foreach ($etherlike_oids as $oid) { $array = snmp_cache_oid($oid, $device, $array, "EtherLike-MIB"); } + #foreach ($cisco_oids as $oid) { $array = snmp_cache_oid($oid, $device, $array, "OLD-CISCO-INTERFACES-MIB"); } + #foreach ($pagp_oids as $oid) { $array = snmp_cache_oid($oid, $device, $array, "CISCO-PAGP-MIB"); } + + if($device['os'] == "IOS" || $device['os'] == "CatOS" || $device['os'] == "IOS XE") { + #$array = snmp_cache_portIfIndex ($device, $array); + #$array = snmp_cache_portName ($device, $array); + #$array = snmp_cache_oid("vmVlan", $device, $array, "CISCO-VLAN-MEMBERSHIP-MIB"); + #$array = snmp_cache_oid("vlanTrunkPortEncapsulationOperType", $device, $array, "CISCO-VTP-MIB"); + #$array = snmp_cache_oid("vlanTrunkPortNativeVlan", $device, $array, "CISCO-VTP-MIB"); + } + + $polled = time(); + + /// End Building SNMP Cache Array + + if($debug) { print_r($array); } + + /// New interface detection + ///// TO DO + /// End New interface detection + + /// Loop interfaces in the DB and update where necessary + $port_query = mysql_query("SELECT * FROM `interfaces` WHERE `device_id` = '".$device['device_id']."'"); + while ($port = mysql_fetch_array($port_query)) { + + echo(" --> " . $port['ifDescr'] . " "); + if($array[$device[device_id]][$port[ifIndex]]) { // Check to make sure Port data is cached. + + $this_port = &$array[$device[device_id]][$port[ifIndex]]; + + $polled_period = $polled - $port['poll_time']; + + $update .= "`poll_time` = '".$polled."'"; + $update .= ", `poll_prev` = '".$port['poll_time']."'"; + $update .= ", `poll_period` = '".$polled_period."'"; + + /// Copy ifHC[In|Out]Octets values to non-HC if they exist + if(isset($this_port['ifHCInOctets']) && isset($this_port['ifHCOutOctets'])) { + echo("HC "); + $this_port['ifInOctets'] = $this_port['ifHCInOctets']; + $this_port['ifOutOctets'] = $this_port['ifHCOutOctets']; + } + + /// Update IF-MIB data + foreach ($data_oids as $oid) { + if ( $port[$oid] != $this_port[$oid]) { + $update .= ", `$oid` = '".mysql_real_escape_string($this_port[$oid])."'"; + #mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $port['device_id'] . "', '" . $port['interface_id'] . "', NOW(), '".$oid . ": ".$port[$oid]." -> " . $this_port[$oid]."')"); + #eventlog($device['device_id'], 'interface', $port['interface_id'], $oid . ": ".$port[$oid]." -> " . $this_port[$oid]); + echo($oid . " "); + } + } + + /// Update IF-MIB metrics + foreach ($stat_oids_db as $oid) { + $update .= ", `$oid` = '".$this_port[$oid]."'"; + $update .= ", `".$oid."_prev` = '".$port[$oid]."'"; + $oid_prev = $oid . "_prev"; + if($port[$oid]) { + $oid_diff = $this_port[$oid] - $port[$oid]; + $oid_rate = $oid_diff / $polled_period; + $update .= ", `".$oid."_rate` = '".$oid_rate."'"; + $update .= ", `".$oid."_delta` = '".$oid_diff."'"; + #echo("\n $oid ($oid_diff B) $oid_rate Bps $polled_period secs\n"); + } + } + + /// Update RRDs + $rrdfile = $host_rrd . "/" . $port['ifIndex'] . ".rrd"; + if(!is_file($rrdfile)) { + $woo = shell_exec($config['rrdtool'] . " create $rrdfile -s 300 \ + DS:INOCTETS:DERIVE:600:0:12500000000 \ + DS:OUTOCTETS:DERIVE:600:0:12500000000 \ + DS:INERRORS:DERIVE:600:0:12500000000 \ + DS:OUTERRORS:DERIVE:600:0:12500000000 \ + DS:INUCASTPKTS:DERIVE:600:0:12500000000 \ + DS:OUTUCASTPKTS:DERIVE:600:0:12500000000 \ + DS:INNUCASTPKTS:DERIVE:600:0:12500000000 \ + DS:OUTNUCASTPKTS:DERIVE:600:0:12500000000 \ + RRA:AVERAGE:0.5:1:600 \ + RRA:AVERAGE:0.5:6:700 \ + RRA:AVERAGE:0.5:24:775 \ + RRA:AVERAGE:0.5:288:797 \ + RRA:MAX:0.5:1:600 \ + RRA:MAX:0.5:6:700 \ + RRA:MAX:0.5:24:775 \ + RRA:MAX:0.5:288:797"); + } + + foreach ($stat_oids as $oid) { /// Copy values from array to global variables and force numeric. + $$oid = $this_port[$oid]; + $$oid = $$oid+0; + } + + $woo = "$polled:$ifInOctets:$ifOutOctets:$ifInErrors:$ifOutErrors:$ifInUcastPkts:$ifOutUcastPkts:$ifInNUcastPkts:$ifOutNUcastPkts"; + echo("\n rrdtool update $rrdfile $woo\n"); + $ret = rrdtool_update("$rrdfile", $woo); + + /// End Update IF-MIB + + /// Update PAgP + if($this_port['pagpOperationMode']) { + foreach ($pagp_oids as $oid) { // Loop the OIDs + if ( $this_port[$oid] != $port[$oid] ) { // If data has changed, build a query + $update .= ", `$oid` = '".mres($this_port[$oid])."'"; + echo("PAgP "); + } + } + } + // End Update PAgP + + if ($update) { /// Do Updates + $update_query = "UPDATE `interfaces` SET ".$update." WHERE `interface_id` = '" . $port['interface_id'] . "'"; + @mysql_query($update_query); $mysql++; + if($debug) {echo("\nMYSQL : [ $update_query ]");} + } /// End Updates + + unset($update_query); unset($update); + } else { + echo("Port Deleted?"); // Port missing from SNMP cache? + } + echo("\n"); + } + +?> diff --git a/includes/procurve-graphing.php b/includes/procurve-graphing.php index 637220999..eb854c552 100755 --- a/includes/procurve-graphing.php +++ b/includes/procurve-graphing.php @@ -2,10 +2,8 @@ function cpugraphHP ($rrd, $graph , $from, $to, $width, $height) { - global $config, $installdir; + global $config; $database = "rrd/" . $rrd; - $imgfile = "graphs/" . "$graph"; - $optsa = array( "--start", $from, "--width", $width, "--height", $height, "--vertical-label", $vertical, "--alt-autoscale-max", "-l 0", "-E", @@ -23,14 +21,14 @@ function cpugraphHP ($rrd, $graph , $from, $to, $width, $height) "--font-render-mode", "normal");} $opts = array_merge($config['rrdgraph_defaults'], $$optsa, $optsb); - $ret = rrd_graph("$imgfile", $opts, count($opts)); + $ret = rrd_graph("$graph", $opts, count($opts)); if( !is_array($ret) ) { $err = rrd_error(); #echo "rrd_graph() ERROR: $err\n"; return FALSE; } else { - return $imgfile; + return $graph; } } @@ -38,7 +36,7 @@ function memgraphHP ($rrd, $graph , $from, $to, $width, $height, $title, $vertic { global $config, $installdir; $database = "rrd/" . $rrd; - $imgfile = "graphs/" . "$graph"; + $memrrd = $database; $opts = array("--start", "$from", "--alt-autoscale-max", "--width", "$width", "--height", "$height", "-l", "0", "-E", "-b", "1024", @@ -55,14 +53,14 @@ function memgraphHP ($rrd, $graph , $from, $to, $width, $height, $title, $vertic $opts = array_merge($config['rrdgraph_defaults'], $$opts, $optsb); - $ret = rrd_graph("$imgfile", $opts, count($opts)); + $ret = rrd_graph("$graph", $opts, count($opts)); if( !is_array($ret) ) { $err = rrd_error(); #echo "rrd_graph() ERROR: $err\n"; return FALSE; } else { - return $imgfile; + return $graph; } } diff --git a/includes/static-config.php b/includes/static-config.php index f102adc04..08907315b 100644 --- a/includes/static-config.php +++ b/includes/static-config.php @@ -68,8 +68,8 @@ $year = time() - (365 * 24 * 60 * 60); ### Update Database between 0.6.0 and 0.6.1 (slight slowdown) $exists = false; -$columns = mysql_query("SHOW columns FROM `interfaces`"); -while($c = mysql_fetch_assoc($columns)){ +$columns = @mysql_query("SHOW columns FROM `interfaces`"); +while($c = @mysql_fetch_assoc($columns)){ if($c['Field'] == "pagpOperationMode"){ $db_pagp = true; } diff --git a/includes/unix-graphing.php b/includes/unix-graphing.php index a3bf53d33..c98aa52e7 100755 --- a/includes/unix-graphing.php +++ b/includes/unix-graphing.php @@ -3,7 +3,6 @@ function mailerrorgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) { global $config, $installdir; $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = "graphs/" . "$graph"; $period = $to - $from; $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 "; } @@ -55,14 +54,14 @@ function mailerrorgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $options .= " GPRINT:sspam:MAX:\ %6.0lf"; $options .= " GPRINT:rspam:AVERAGE:\ \ %5.2lf/min"; $options .= " GPRINT:rmspam:MAX:\ %5.2lf/min\\\\l"; - shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; + shell_exec($config['rrdtool'] . " graph $graph $options"); + return $graph; } function mailsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) { global $config, $installdir; $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = "graphs/" . "$graph"; + $period = $to - $from; $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 "; } @@ -93,14 +92,14 @@ function mailsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $ver $options .= " GPRINT:srecv:MAX:\ \ %6.0lf"; $options .= " GPRINT:rrecv:AVERAGE:\ \ %5.2lf/min"; $options .= " GPRINT:rmrecv:MAX:\ %5.2lf/min\\\\l"; - shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; + shell_exec($config['rrdtool'] . " graph $graph $options"); + return $graph; } function memgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) { global $config, $installdir; $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = "graphs/" . "$graph"; + $options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height -b 1024"; if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } $options .= " DEF:atotalswap=$database:totalswap:AVERAGE"; @@ -158,14 +157,14 @@ function memgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $verti $options .= " LINE1:totalreal#050505:total"; $options .= " GPRINT:totalreal:AVERAGE:\ \ %7.2lf%sB"; - shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; + shell_exec($config['rrdtool'] . " graph $graph $options"); + return $graph; } function loadgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) { global $config, $installdir; $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = "graphs/" . "$graph"; + $period = $to - $from; $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 "; } @@ -190,15 +189,15 @@ function loadgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vert $options .= " GPRINT:c:LAST:\ \ \ %7.2lf"; $options .= " GPRINT:c:AVERAGE:\ \ %7.2lf"; $options .= " GPRINT:c:MAX:\ \ %7.2lf\\\\n"; - shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; + shell_exec($config['rrdtool'] . " graph $graph $options"); + return $graph; } function usersgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) { global $config, $installdir; $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = "graphs/" . "$graph"; + $period = $to - $from; $options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height -l 0"; if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } @@ -210,14 +209,13 @@ function usersgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $ver $options .= " GPRINT:users:AVERAGE:%6.2lf"; $options .= " GPRINT:users:MIN:%6.2lf"; $options .= " GPRINT:users:MAX:%6.2lf\\\\n"; - shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; + shell_exec($config['rrdtool'] . " graph $graph $options"); + return $graph; } function procsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) { global $config, $installdir; $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = "graphs/" . "$graph"; $period = $to - $from; $options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height -l 0"; if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } @@ -229,17 +227,15 @@ function procsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $ver $options .= " GPRINT:procs:AVERAGE:%6.2lf"; $options .= " GPRINT:procs:MIN:%6.2lf"; $options .= " GPRINT:procs:MAX:%6.2lf\\\\n"; - shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; - + shell_exec($config['rrdtool'] . " graph $graph $options"); + return $graph; } function cpugraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) { - global $config, $installdir; + global $config; $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = "graphs/" . "$graph"; $period = $to - $from; $options = "-l 0 --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 "; } @@ -269,14 +265,13 @@ function cpugraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $verti $options .= " GPRINT:idle_perc:LAST:\ \ \ \ \ %5.2lf%%"; $options .= " GPRINT:idle_perc:AVERAGE:\ \ \ %5.2lf%%"; $options .= " GPRINT:idle_perc:MAX:\ \ \ %5.2lf%%\\\\n"; - shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; + shell_exec($config['rrdtool'] . " graph $graph $options"); + return $graph; } function couriergraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) { global $config, $installdir; - $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = "graphs/" . "$graph"; + $database = $config['rrd_dir'] . "/" . $rrd; $period = $to - $from; $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 "; } @@ -319,14 +314,14 @@ function couriergraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $v $options .= " GPRINT:vimapd_ssl_login:AVERAGE:\ %6.0lf"; $options .= " GPRINT:rimapd_ssl_login:AVERAGE:%5.2lf/min"; $options .= " GPRINT:rmimapd_ssl_login:MAX:%5.2lf/min\\\\l"; - shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; + shell_exec($config['rrdtool'] . " graph $graph $options"); + return $graph; } function apachehitsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) { global $config, $installdir; $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = "graphs/" . "$graph"; + $options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height -l 0"; if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } $options .= " DEF:hits=$database:hits:AVERAGE"; @@ -336,13 +331,13 @@ function apachehitsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $options .= " GPRINT:hits:LAST:\ %6.2lf/sec"; $options .= " GPRINT:hits:AVERAGE:%6.2lf/sec"; $options .= " GPRINT:hits:MAX:%6.2lf/sec\\\\n"; - shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; + shell_exec($config['rrdtool'] . " graph $graph $options"); + return $graph; } function unixfsgraph ($id, $graph, $from, $to, $width, $height, $title, $vertical) { global $config, $installdir; - $imgfile = "graphs/" . "$graph"; + $options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height -b 1024 -l 0"; if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } $hostname = gethostbyid($device); @@ -367,47 +362,14 @@ function unixfsgraph ($id, $graph, $from, $to, $width, $height, $title, $vertica $options .= " GPRINT:$fs[storage_id]p:LAST:%5.2lf%%\\\\l"; $iter++; } - shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; + shell_exec($config['rrdtool'] . " graph $graph $options"); + return $graph; } -function unixfsgraph_dev ($device, $graph, $from, $to, $width, $height, $title, $vertical) { - global $config, $installdir; - $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = "graphs/" . "$graph"; - $options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height -b 1024 -l 0"; - if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } - $hostname = gethostbyid($device); - $iter = "1"; - $sql = mysql_query("SELECT * FROM storage where host_id = '$device'"); - $options .= "COMMENT:\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Size\ \ \ \ \ \ Used\ \ \ \ %age\l"; - while($fs = 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"; $iter = "0"; } - - $descr = str_pad($fs[hrStorageDescr], 14); - $descr = substr($descr,0,14); - $text = str_replace("/", "_", $fs['hrStorageDescr']); - $rrd = $config['rrd_dir'] . "/$hostname/storage-$text.rrd"; - $options .= " DEF:$fs[storage_id]=$rrd:used:AVERAGE"; - $options .= " DEF:$fs[storage_id]s=$rrd:size:AVERAGE"; - $options .= " DEF:$fs[storage_id]p=$rrd:perc:AVERAGE"; - $options .= " LINE1.25:$fs[storage_id]p#" . $colour . ":'$descr'"; - $options .= " GPRINT:$fs[storage_id]s:LAST:%6.2lf%SB"; - $options .= " GPRINT:$fs[storage_id]:LAST:%6.2lf%SB"; - $options .= " GPRINT:$fs[storage_id]p:LAST:%5.2lf%%\\\\l"; - $iter++; - } - shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; -} - function apachebitsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $vertical) { global $config, $installdir; - $database = $config['rrd_dir'] . "/" . $rrd; - $imgfile = "graphs/" . "$graph"; + $database = $config['rrd_dir'] . "/" . $rrd; $options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height -l 0"; if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; } $options .= " DEF:bits=$database:bits:AVERAGE"; @@ -417,6 +379,6 @@ function apachebitsgraphUnix ($rrd, $graph, $from, $to, $width, $height, $title, $options .= " GPRINT:bits:LAST:\ %6.2lf/sec"; $options .= " GPRINT:bits:AVERAGE:%6.2lf/sec"; $options .= " GPRINT:bits:MAX:%6.2lf/sec\\\\n"; - shell_exec($config['rrdtool'] . " graph $imgfile $options"); - return $imgfile; + shell_exec($config['rrdtool'] . " graph $graph $options"); + return $graph; } diff --git a/poll-device.php b/poll-device.php index 5295ae0dd..b2b3d30b3 100755 --- a/poll-device.php +++ b/poll-device.php @@ -3,33 +3,33 @@ include("config.php"); include("includes/functions.php"); +include("includes/functions-poller.inc.php"); + +$poller_start = utime(); echo("Observer Poller v".$config['version']."\n\n"); -if($argv[1] == "--device" && $argv[2]) { - $where = "AND `device_id` = '".$argv[2]."'"; -} elseif ($argv[1] == "--odd") { +$options = getopt("h:t:i:n:d::a::"); + +if ($options['h'] == "odd") { $where = "AND MOD(device_id,2) = 1"; -} elseif ($argv[1] == "--even") { + $doing = $options['h']; +} elseif ($options['h'] == "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") { - -} else { - echo("--device Poll single device\n"); - echo("--all Poll all devices\n\n"); - echo("No polling type specified!\n"); - exit; + $doing = $options['h']; +} elseif($options['h']) { + $where = "AND `device_id` = '".$options['h']."'"; + $doing = "Host ".$options['h']; +} elseif ($options['i'] && isset($options['n'])) { + $where = "AND MOD(device_id,".$options['i'].") = '" . $options['n'] . "'"; + $doing = "Proc ".$options['n'] ."/".$options['i']; +} elseif ($options['h'] == "all") { + $where = " "; + $doing = "all"; } echo("Starting polling run:\n\n"); - +$i = 0; $device_query = mysql_query("SELECT * FROM `devices` WHERE `ignore` = '0' $where ORDER BY `device_id` ASC"); while ($device = mysql_fetch_array($device_query)) { @@ -154,10 +154,15 @@ while ($device = mysql_fetch_array($device_query)) { echo("Polling temperatures\n"); include("includes/polling/temperatures.inc.php"); include("includes/polling/device-netstats.inc.php"); - echo("Polling interfaces\n"); - $where = "WHERE device_id = '" . $device['device_id'] . "' AND deleted = '0'"; - include("includes/polling/interfaces.inc.php"); +# echo("Polling interfaces\n"); +# $where = "WHERE device_id = '" . $device['device_id'] . "' AND deleted = '0'"; +# include("includes/polling/interfaces.inc.php"); + + include("includes/polling/ports.inc.php"); + 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'"); @@ -276,9 +281,16 @@ while ($device = mysql_fetch_array($device_query)) { } else { echo("No Changes to " . $device['hostname'] . "\n"); } - + $i++; echo("\n"); } +$poller_end = utime(); $poller_run = $poller_end - $poller_start; $poller_time = substr($poller_run, 0, 5); + +$string = $argv[0] . " $doing " . date("F j, Y, G:i") . " - $i devices polled in $poller_time secs"; +echo("$string\n"); +shell_exec("echo '".$string."' >> /opt/observer/observer.log"); + + ?> diff --git a/poll-mac_accounting.php b/poll-mac_accounting.php deleted file mode 100755 index cf484cb76..000000000 --- a/poll-mac_accounting.php +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/php - $rrdfile \n"); }; - $pkts_rrdfile = $acc_rrd . "/" . $acc['ifIndex'] . "-" . $acc['mac'] . "-pkts.rrd"; - - if(!is_file($pkts_rrdfile)) { - $woo = shell_exec($config['rrdtool'] ." create $pkts_rrdfile \ - DS:IN:COUNTER:600:0:12500000000 \ - DS:OUT:COUNTER:600:0:12500000000 \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797"); - } - - if(!is_file($rrdfile)) { - $woo = shell_exec($config['rrdtool'] ." create $rrdfile \ - DS:IN:COUNTER:600:0:12500000000 \ - DS:OUT:COUNTER:600:0:12500000000 \ - 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"); - } - - $woo = "N:".($in+0).":".($out+0); - $ret = rrdtool_update("$rrdfile", $woo); - - $woo = "N:".($pktin+0).":".($pktout+0); - $ret = rrdtool_update("$pkts_rrdfile", $woo); - -# $rates = interface_rates ($rrdfile); - -# $pkt_rates = interface_rates ($pkts_rrdfile); - - $pkt_rate['in'] = round($pkt_rate['in'] / 8); - $pkt_rate['out'] = round($pkt_rate['out'] / 8); - -# mysql_query("UPDATE `mac_accounting` SET bps_in = '" . $rates['in'] . "', bps_out = '" . $rates['out'] . "', pps_in = '" . $pkt_rates['in'] . "', pps_out = '" . $pkt_rates['out'] . "' WHERE ma_id= '" . $acc['ma_id'] . "'"); - -# echo(formatRates($rates['in']) . " (" . $pkt_rates['in'] . "pps) in " . formatRates($rates['out']) . " (" . $pkt_rates['out'] . "pps) out \n"); - - } -?> diff --git a/poller.php b/poller.php new file mode 100755 index 000000000..255b9b45e --- /dev/null +++ b/poller.php @@ -0,0 +1,84 @@ +#!/usr/bin/php + 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("-a Poll all devices\n\n"); + echo("-i -n Poll as instance of \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; } + +$i = 0; +$device_query = mysql_query("SELECT * FROM `devices` WHERE `ignore` = '0' AND `disabled` = '0' AND `status` = '1' $where ORDER BY device_id DESC"); +while ($device = mysql_fetch_array($device_query)) { + + echo("-> " . $device['hostname'] . "\n"); + + $device_start = utime(); // Start counting device poll time + + $host_rrd = $config['rrd_dir'] . "/" . $device['hostname']; + if(!is_dir($host_rrd)) { mkdir($host_rrd); echo("Created directory : $host_rrd\n"); } + $i++; + + $device['pingable'] = isPingable($device['hostname']); + if($device['pingable']) { + $device['snmpable'] = isSNMPable($device['hostname'], $device['community'], $device['snmpver'], $device['port']); + } + + if($device['pingable'] && $device['snmpable']) { // Reachability Check + if($options['t']) { + include("includes/polling/".$options['t'].".inc.php"); + } else { + include("includes/polling/ports.inc.php"); + include("includes/polling/ports-etherlike.inc.php"); + include("includes/polling/cisco-mac-accounting.inc.php"); + } + } else { echo(" Unreachable"); } // End Reachability Check + + unset($array); // Clear $array SNMP cache + + $device_end = utime(); $device_run = $device_end - $device_start; $device_time = substr($device_run, 0, 5); + + echo("Polled in $device_time seconds\n"); + #shell_exec("echo 'Polled ".$device['hostname']." in $device_time seconds' >> /opt/observer/observer.log"); +} + + +$poller_end = utime(); $poller_run = $poller_end - $poller_start; $poller_time = substr($poller_run, 0, 5); + +$string = $argv[0] . " " . date("F j, Y, G:i") . " - $i devices polled in $poller_time secs"; +echo("$string\n"); + +shell_exec("echo '".$string."' >> /opt/observer/observer.log"); + +?> diff --git a/scripts/update-sql.php b/scripts/update-sql.php new file mode 100755 index 000000000..a6665db00 --- /dev/null +++ b/scripts/update-sql.php @@ -0,0 +1,13 @@ +#!/usr/bin/php + diff --git a/test-poll.php b/test-poll.php index 3d0389e66..57c683c7b 100755 --- a/test-poll.php +++ b/test-poll.php @@ -4,7 +4,7 @@ include("config.php"); include("includes/functions.php"); -$start = utime(); +$poller_start = utime(); ### Observer Device Polling Test @@ -43,16 +43,17 @@ $device_query = mysql_query("SELECT * FROM `devices` WHERE status = '1' $where O while ($device = mysql_fetch_array($device_query)) { echo("\n" . $device['hostname'] ."\n"); - + $host_rrd = $config['rrd_dir'] . "/" . $device['hostname']; + $where = "WHERE device_id = '" . $device['device_id'] . "' AND deleted = '0'"; include("includes/polling/".$type.".inc.php"); echo("\n"); $devices_polled++; } -$end = utime(); $run = $end - $start; -$proctime = substr($run, 0, 5); - -echo("$devices_polled devices polled in $proctime secs\n"); +$poller_end = utime(); $poller_run = $poller_end - $poller_start; $poller_time = substr($poller_run, 0, 5); +$string = $argv[0] . " " . date("F j, Y, G:i") . " - $i devices polled in $poller_time secs"; +echo("$string\n"); +shell_exec("echo '".$string."' >> /opt/observer/observer.log"); ?>