diff --git a/addhost.php b/addhost.php index 6a5ed1d4b..d2d2819ed 100755 --- a/addhost.php +++ b/addhost.php @@ -38,7 +38,7 @@ if (isset($argv[1]) && $argv[1]) } list($hostshort) = explode(".", $host); - if (mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '".mres($host)."'"), 0) == '0' ) + if (mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '".mres($host)."'"), 0) == '0') { if (isDomainResolves($argv[1])) { diff --git a/discovery.php b/discovery.php index 17ea705a5..823f80279 100755 --- a/discovery.php +++ b/discovery.php @@ -73,13 +73,13 @@ if (isset($options['d'])) if (!$where) { echo("-h | Poll single device\n"); - echo("-h odd Poll odd numbered devices (same as -i 2 -n 0)\n"); - echo("-h even Poll even numbered devices (same as -i 2 -n 1)\n"); - echo("-h all Poll all devices\n"); - echo("-h new Poll all devices that have not had a discovery run before\n\n"); - echo("-i -n Poll as instance of \n"); - echo(" Instances start at 0. 0-3 for -n 4\n\n"); - echo("-d Enable debugging output\n"); + echo("-h odd Poll odd numbered devices (same as -i 2 -n 0)\n"); + echo("-h even Poll even numbered devices (same as -i 2 -n 1)\n"); + echo("-h all Poll all devices\n"); + echo("-h new Poll all devices that have not had a discovery run before\n\n"); + echo("-i -n Poll as instance of \n"); + echo(" Instances start at 0. 0-3 for -n 4\n\n"); + echo("-d Enable debugging output\n"); echo("\n"); echo("No polling type specified!\n"); exit; diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index 4f76b0468..87a0131ed 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -187,7 +187,7 @@ function device_permitted($device_id) if ($_SESSION['userlevel'] >= "5") { $allowed = true; - } elseif ($permissions['device'][$device_id] ) { + } elseif ($permissions['device'][$device_id]) { $allowed = true; } else { $allowed = false; @@ -307,8 +307,8 @@ function geteventicon($message) { if ($message == "Device status changed to Down") { $icon = "server_connect.png"; } if ($message == "Device status changed to Up") { $icon = "server_go.png"; } - if ($message == "Interface went down" || $message == "Interface changed state to Down" ) { $icon = "if-disconnect.png"; } - if ($message == "Interface went up" || $message == "Interface changed state to Up" ) { $icon = "if-connect.png"; } + if ($message == "Interface went down" || $message == "Interface changed state to Down") { $icon = "if-disconnect.png"; } + if ($message == "Interface went up" || $message == "Interface changed state to Up") { $icon = "if-connect.png"; } if ($message == "Interface disabled") { $icon = "if-disable.png"; } if ($message == "Interface enabled") { $icon = "if-enable.png"; } if (isset($icon)) { return $icon; } else { return false; } diff --git a/html/includes/print-interface.inc.php b/html/includes/print-interface.inc.php index c14b31241..7e47d625c 100644 --- a/html/includes/print-interface.inc.php +++ b/html/includes/print-interface.inc.php @@ -192,7 +192,7 @@ if (strpos($interface['label'], "oopback") === false && !$graph_type) if ($int_links_phys[$int_link]) { echo(" "); } else { echo(" "); } - echo("" . generate_port_link($link_if, makeshortif($link_if['label'])) . " on " . generate_device_link($link_if, shorthost($link_if['hostname'])) ); + echo("" . generate_port_link($link_if, makeshortif($link_if['label'])) . " on " . generate_device_link($link_if, shorthost($link_if['hostname']))); if ($int_links_v6[$int_link]) { echo(" v6"); } if ($int_links_v4[$int_link]) { echo(" v4"); } diff --git a/html/map.php b/html/map.php index b08abdd92..33ac3cbb2 100755 --- a/html/map.php +++ b/html/map.php @@ -113,7 +113,8 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) $map .= "\"$dst\" [URL=\"{$config['base_url']}/device/$dst_host/map/\" fontsize=20 shape=box3d]\n"; - if ($dst_host == $device['device_id'] || $where == '') { + if ($dst_host == $device['device_id'] || $where == '') + { $map .= "\"" . $dif['interface_id'] . "\" [label=\"" . $dif['label'] . "\", fontsize=12, fillcolor=lightblue, URL=\"{$config['base_url']}/device/$dst_host/interface/$remote_interface_id/\"]\n"; } else { $map .= "\"" . $dif['interface_id'] . "\" [label=\"" . $dif['label'] . " \", fontsize=12, fillcolor=lightgray, URL=\"{$config['base_url']}/device/$dst_host/interface/$remote_interface_id/\"]\n"; @@ -156,7 +157,8 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) if ($where == '') { $maptool = 'neato -Gpack'; } $img = shell_exec("echo \"".addslashes($map)."\" | $maptool -T".$_GET['format'].""); - if ($_GET['format'] == "png") { + if ($_GET['format'] == "png") + { header("Content-type: image/".$_GET['format']); } elseif ($_GET['format'] == "svg") { header("Content-type: image/svg+xml"); diff --git a/html/pages/addhost.inc.php b/html/pages/addhost.inc.php index dfee96cf4..02f8e347f 100644 --- a/html/pages/addhost.inc.php +++ b/html/pages/addhost.inc.php @@ -24,9 +24,9 @@ if ($_POST['hostname'] && $_POST['community']) } else { echo("

Error: You don't have the necessary privileges to add hosts.

"); } -} elseif ($_POST['hostname'] && !$_POST['community'] ) { +} elseif ($_POST['hostname'] && !$_POST['community']) { echo("

Error: A community string is required.

"); -} elseif (!$_POST['hostname'] && $_POST['community'] ) { +} elseif (!$_POST['hostname'] && $_POST['community']) { echo("

Error: A hostname is required.

"); } @@ -35,27 +35,28 @@ if ($_POST['hostname'] && $_POST['community'])

Devices will be checked for Ping and SNMP reachability before being probed. Only devices with recognised OSes will be added.

-
- - - - - - - - - - - - - - - -
Hostname
Community
SNMP Version -  Port -
-
+
+ + + + + + + + + + + + + + + +
Hostname
Community
SNMP Version + +  Port +
+
diff --git a/html/pages/device/ports.inc.php b/html/pages/device/ports.inc.php index b1d9f0755..33035d8d0 100644 --- a/html/pages/device/ports.inc.php +++ b/html/pages/device/ports.inc.php @@ -1,6 +1,6 @@ "); } else { - if ($_GET['opta'] == "arp" ) + if ($_GET['opta'] == "arp") { include("arp.inc.php"); } elseif ($_GET['opta'] == "adsl") { @@ -70,7 +70,7 @@ if ($_GET['optc'] == thumbs) echo(""); echo("
"); } else { - if ($_GET['opta'] == "details" ) { $port_details = 1; } + if ($_GET['opta'] == "details") { $port_details = 1; } echo("
"); $i = "1"; $interface_query = mysql_query("select * from ports WHERE device_id = '".$device['device_id']."' AND deleted = '0' ORDER BY `ifIndex` ASC"); diff --git a/html/pages/front/demo.php b/html/pages/front/demo.php index 8c5a90eed..ab877e8e2 100644 --- a/html/pages/front/demo.php +++ b/html/pages/front/demo.php @@ -75,7 +75,7 @@ while ($peer = mysql_fetch_array($sql)){ $sql = mysql_query("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '84600' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"); while ($device = mysql_fetch_array($sql)){ - if (device_permitted($device['device_id']) && $device['attrib_value'] < "84600" && $device['attrib_type'] == "uptime" ) { + if (device_permitted($device['device_id']) && $device['attrib_value'] < "84600" && $device['attrib_type'] == "uptime") { echo("
".generate_device_link($device, shorthost($device['hostname']))."
Device
Rebooted

diff --git a/html/pages/front/jt.php b/html/pages/front/jt.php index 0d9372010..f2c585eac 100644 --- a/html/pages/front/jt.php +++ b/html/pages/front/jt.php @@ -75,7 +75,7 @@ while ($peer = mysql_fetch_array($sql)){ $sql = mysql_query("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '84600' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'"); while ($device = mysql_fetch_array($sql)){ - if (device_permitted($device['device_id']) && $device['attrib_value'] < "84600" && $device['attrib_type'] == "uptime" ) { + if (device_permitted($device['device_id']) && $device['attrib_value'] < "84600" && $device['attrib_type'] == "uptime") { echo("
".generate_device_link($device, shorthost($device['hostname']))."
Device
Rebooted

diff --git a/html/pages/ipv4.inc.php b/html/pages/ipv4.inc.php index d6f18d4e6..f3477eda5 100644 --- a/html/pages/ipv4.inc.php +++ b/html/pages/ipv4.inc.php @@ -57,7 +57,7 @@ while ($interface = mysql_fetch_array($query)) { list($addy, $mask) = explode("/", $_POST['address']); if (!$mask) { $mask = "32"; } - if (!match_network($addy . "/" . $mask, $interface['ipv4_address'] )) { $ignore = 1; } + if (!match_network($addy . "/" . $mask, $interface['ipv4_address'])) { $ignore = 1; } } if (!$ignore) diff --git a/html/pages/ipv6.inc.php b/html/pages/ipv6.inc.php index 960c1228a..bd72e69fd 100644 --- a/html/pages/ipv6.inc.php +++ b/html/pages/ipv6.inc.php @@ -1,6 +1,6 @@ -
+
diff --git a/html/pages/purgeports.inc.php b/html/pages/purgeports.inc.php index 569adad43..074a12f97 100644 --- a/html/pages/purgeports.inc.php +++ b/html/pages/purgeports.inc.php @@ -5,7 +5,7 @@ function delete_port($interface_id) $ipaddrs = mysql_query("SELECT * FROM `ipaddr` WHERE `interface_id` = '$interface_id'"); while ($ipaddr = mysql_fetch_array($ipaddrs)) { - echo("
Deleting IPv4 address " . $ipaddr['addr'] . "/" . $ipaddr['cidr'] ); + echo("
Deleting IPv4 address " . $ipaddr['addr'] . "/" . $ipaddr['cidr']); mysql_query("DELETE FROM addr WHERE id = '".$addr['id']."'"); echo("
"); } @@ -13,7 +13,7 @@ function delete_port($interface_id) $ip6addr = mysql_query("SELECT * FROM `ip6addr` WHERE `interface_id` = '$interface_id'"); while ($ip6addr = mysql_fetch_array($ip6addrs)) { - echo("
Deleting IPv6 address " . $ip6addr['ip6_comp_addr'] . "/" . $ip6addr['ip6_prefixlen'] ); + echo("
Deleting IPv6 address " . $ip6addr['ip6_comp_addr'] . "/" . $ip6addr['ip6_prefixlen']); mysql_query("DELETE FROM ip6addr WHERE ip6_addr_id = '".$ip6addr['ip6_addr_id']."'"); echo("
"); } @@ -21,7 +21,7 @@ function delete_port($interface_id) $ip6addr = mysql_query("SELECT * FROM `ip6addr` WHERE `interface_id` = '$interface_id'"); while ($ip6addr = mysql_fetch_array($ip6addrs)) { - echo("
Deleting IPv6 address " . $ip6addr['ip6_comp_addr'] . "/" . $ip6addr['ip6_prefixlen'] ); + echo("
Deleting IPv6 address " . $ip6addr['ip6_comp_addr'] . "/" . $ip6addr['ip6_prefixlen']); mysql_query("DELETE FROM ip6addr WHERE ip6_addr_id = '".$ip6addr['ip6_addr_id']."'"); echo("
"); } @@ -37,7 +37,7 @@ function delete_port($interface_id) $ports = mysql_query("SELECT * FROM `ports` WHERE `deleted` = '1'"); while ($port = mysql_fetch_array($ports)) { - echo("
Deleting port " . $port['interface_id'] . " - " . $port['ifDescr'] ); + echo("
Deleting port " . $port['interface_id'] . " - " . $port['ifDescr']); delete_port($port['interface_id']); echo("
"); } diff --git a/html/pages/syslog.inc.php b/html/pages/syslog.inc.php index b369976f0..81bf05ed1 100644 --- a/html/pages/syslog.inc.php +++ b/html/pages/syslog.inc.php @@ -14,7 +14,8 @@ ".$data['program'].""); @@ -28,7 +29,8 @@ "); -?> -
@@ -74,7 +74,7 @@ while ($interface = mysql_fetch_array($query)) $error_img = generate_port_link($interface,"Interface Errors",errors); } else { $error_img = ""; } - if (port_permitted($interface['interface_id']) ) + if (port_permitted($interface['interface_id'])) { echo('
' . generate_device_link($interface) . '
\ No newline at end of file +?> \ No newline at end of file diff --git a/includes/discovery/entity-sensor.inc.php b/includes/discovery/entity-sensor.inc.php index ec7931b35..b07666ec7 100644 --- a/includes/discovery/entity-sensor.inc.php +++ b/includes/discovery/entity-sensor.inc.php @@ -62,13 +62,13 @@ if (is_array($oids)) ### FIXME this stuff is foul - if ($entry['entPhySensorScale'] == "nano") { $divisor = "1000000000"; $multiplier = "1"; } - if ($entry['entPhySensorScale'] == "micro") { $divisor = "1000000"; $multiplier = "1"; } - if ($entry['entPhySensorScale'] == "milli") { $divisor = "1000"; $multiplier = "1"; } - if ($entry['entPhySensorScale'] == "units") { $divisor = "1"; $multiplier = "1"; } - if ($entry['entPhySensorScale'] == "kilo") { $divisor = "1"; $multiplier = "1000"; } - if ($entry['entPhySensorScale'] == "mega") { $divisor = "1"; $multiplier = "1000000"; } - if ($entry['entPhySensorScale'] == "giga") { $divisor = "1"; $multiplier = "1000000000"; } + if ($entry['entPhySensorScale'] == "nano") { $divisor = "1000000000"; $multiplier = "1"; } + if ($entry['entPhySensorScale'] == "micro") { $divisor = "1000000"; $multiplier = "1"; } + if ($entry['entPhySensorScale'] == "milli") { $divisor = "1000"; $multiplier = "1"; } + if ($entry['entPhySensorScale'] == "units") { $divisor = "1"; $multiplier = "1"; } + if ($entry['entPhySensorScale'] == "kilo") { $divisor = "1"; $multiplier = "1000"; } + if ($entry['entPhySensorScale'] == "mega") { $divisor = "1"; $multiplier = "1000000"; } + if ($entry['entPhySensorScale'] == "giga") { $divisor = "1"; $multiplier = "1000000000"; } if (is_numeric($entry['entPhySensorPrecision']) && $entry['entPhySensorPrecision'] > "0") { $divisor = $divisor . str_pad('', $entry['entPhySensorPrecision'], "0"); } $current = $current * $multiplier / $divisor; diff --git a/includes/discovery/mempools/junos.inc.php b/includes/discovery/mempools/junos.inc.php index c2b6074fb..edb2038bb 100755 --- a/includes/discovery/mempools/junos.inc.php +++ b/includes/discovery/mempools/junos.inc.php @@ -21,7 +21,7 @@ if ($device['os'] == "junos") $usage_oid = ".1.3.6.1.4.1.2636.3.1.13.1.8." . $index; $descr = $entry['jnxOperatingDescr']; $usage = $entry['jnxOperatingBuffer']; - if (!strstr($descr, "No") && !strstr($usage, "No") && $descr != "" ) + if (!strstr($descr, "No") && !strstr($usage, "No") && $descr != "") { discover_mempool($valid_mempool, $device, $index, "junos", $descr, "1", NULL, NULL); } diff --git a/includes/discovery/os/fortigate.inc.php b/includes/discovery/os/fortigate.inc.php index 170adeb7c..55476c9e4 100755 --- a/includes/discovery/os/fortigate.inc.php +++ b/includes/discovery/os/fortigate.inc.php @@ -2,8 +2,8 @@ if (!$os) { - if (strstr($sysObjectId, ".1.3.6.1.4.1.12356.15")) { $os = "fortigate"; } - if (strstr($sysObjectId, ".1.3.6.1.4.1.12356.101.1")) { $os = "fortigate"; } + if (strstr($sysObjectId, ".1.3.6.1.4.1.12356.15")) { $os = "fortigate"; } + if (strstr($sysObjectId, ".1.3.6.1.4.1.12356.101.1")) { $os = "fortigate"; } } ?> \ No newline at end of file diff --git a/includes/discovery/os/screenos.inc.php b/includes/discovery/os/screenos.inc.php index 1982878ae..3023d22a8 100755 --- a/includes/discovery/os/screenos.inc.php +++ b/includes/discovery/os/screenos.inc.php @@ -2,8 +2,8 @@ if (!$os) { - if (strstr($sysObjectId, ".1.3.6.1.4.1.674.3224.1")) { $os = "screenos"; } - if (strstr($sysObjectId, ".1.3.6.1.4.1.3224")) { $os = "screenos"; } + if (strstr($sysObjectId, ".1.3.6.1.4.1.674.3224.1")) { $os = "screenos"; } + if (strstr($sysObjectId, ".1.3.6.1.4.1.3224")) { $os = "screenos"; } } ?> \ No newline at end of file diff --git a/includes/discovery/ports.inc.php b/includes/discovery/ports.inc.php index 682594460..0da4b84f3 100755 --- a/includes/discovery/ports.inc.php +++ b/includes/discovery/ports.inc.php @@ -34,7 +34,7 @@ foreach (explode("\n", $ports) as $entry) } if (empty($ifDescr)) { $nullintf = 1; } - if ($device['os'] == "catos" && strstr($if, "vlan") ) { $nullintf = 1; } + if ($device['os'] == "catos" && strstr($if, "vlan")) { $nullintf = 1; } if ($device['os'] == "vmware" && preg_match("/Device ([a-z0-9]+) at .*/", $ifDescr, $matches)) { $ifDescr = $matches[1]; } $ifDescr = fixifName($ifDescr); if (preg_match('/serial[0-9]:/', $if)) { $nullintf = 1; } diff --git a/includes/discovery/processors/ios.inc.php b/includes/discovery/processors/ios.inc.php index fa7c7e47e..842549a4e 100755 --- a/includes/discovery/processors/ios.inc.php +++ b/includes/discovery/processors/ios.inc.php @@ -41,7 +41,7 @@ if ($device['os'] == "ios" || $device['os_group'] == "ios") #echo("|".$descr."|"); - if (!strstr($descr, "No") && !strstr($usage, "No") && $descr != "" ) + if (!strstr($descr, "No") && !strstr($usage, "No") && $descr != "") { discover_processor($valid_processor, $device, $usage_oid, $index, "cpm", $descr, "1", $entry['juniSystemModuleCpuUtilPct'], $entPhysicalIndex, NULL); } diff --git a/includes/discovery/processors/junos.inc.php b/includes/discovery/processors/junos.inc.php index c84170cd0..59f85fdd4 100755 --- a/includes/discovery/processors/junos.inc.php +++ b/includes/discovery/processors/junos.inc.php @@ -21,7 +21,7 @@ if ($device['os'] == "junos") $usage_oid = ".1.3.6.1.4.1.2636.3.1.13.1.8." . $index; $descr = $entry['jnxOperatingDescr']; $usage = $entry['jnxOperatingCPU']; - if (!strstr($descr, "No") && !strstr($usage, "No") && $descr != "" ) + if (!strstr($descr, "No") && !strstr($usage, "No") && $descr != "") { discover_processor($valid_processor, $device, $usage_oid, $index, "junos", $descr, "1", $usage, NULL, NULL); } diff --git a/includes/discovery/processors/junose.inc.php b/includes/discovery/processors/junose.inc.php index 0593d712c..500bec20d 100755 --- a/includes/discovery/processors/junose.inc.php +++ b/includes/discovery/processors/junose.inc.php @@ -19,7 +19,7 @@ if ($device['os'] == "junose") $descr = $entry['juniSystemModuleDescr']; $usage = $entry['juniSystemModuleCpuFiveMinAvgPct']; - if (!strstr($descr, "No") && !strstr($usage, "No") && $descr != "" ) + if (!strstr($descr, "No") && !strstr($usage, "No") && $descr != "") { discover_processor($valid_processor, $device, $usage_oid, $index, "junose", $descr, "1", $usage, $entPhysicalIndex, NULL); } diff --git a/includes/functions.php b/includes/functions.php index 1eff41650..c0093410e 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -121,7 +121,7 @@ function getHostOS($device) $dir_handle = @opendir($config['install_dir'] . "/includes/discovery/os") or die("Unable to open $path"); while ($file = readdir($dir_handle)) { - if (preg_match("/.php$/", $file) ) + if (preg_match("/.php$/", $file)) { include($config['install_dir'] . "/includes/discovery/os/" . $file); } @@ -167,20 +167,22 @@ function format_bi($size, $round = '2') { $sizes = Array('', 'k', 'M', 'G', 'T', 'P', 'E'); $ext = $sizes[0]; - for ($i = 1; (($i < count($sizes)) && ($size >= 1024)); $i++) { $size = $size / 1024; $ext = $sizes[$i]; } + for ($i = 1; (($i < count($sizes)) && ($size >= 1024)); $i++) { $size = $size / 1024; $ext = $sizes[$i]; } return round($size, $round).$ext; } function percent_colour($perc) { - $r = min(255, 5 * ($perc - 25)); - $b = max(0, 255 - (5 * ($perc + 25))); - return sprintf('#%02x%02x%02x', $r, $b, $b); + $r = min(255, 5 * ($perc - 25)); + $b = max(0, 255 - (5 * ($perc + 25))); + + return sprintf('#%02x%02x%02x', $r, $b, $b); } function interface_errors($rrd_file, $period = '-1d') // Returns the last in/out errors value in RRD { global $config; + $cmd = $config['rrdtool']." fetch -s $period -e -300s $rrd_file AVERAGE | grep : | cut -d\" \" -f 4,5"; $data = trim(shell_exec($cmd)); foreach (explode("\n", $data) as $entry) @@ -191,6 +193,7 @@ function interface_errors($rrd_file, $period = '-1d') // Returns the last in/out } $errors['in'] = round($in_errors); $errors['out'] = round($out_errors); + return $errors; } @@ -223,16 +226,19 @@ function getImage($host) } elseif (file_exists($config['html_dir'] . "/images/os/$distro" . ".gif")){ $image = ''; } } } + return $image; } -function renamehost($id, $new) +function renamehost($id, $new, $source = 'console') { global $config; - $host = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '$id'"), 0); + + $host = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '$id'"), 0); # FIXME getdevicebyid? + rename($config['rrd_dir']."/$host",$config['rrd_dir']."/$new"); mysql_query("UPDATE devices SET hostname = '$new' WHERE device_id = '$id'"); - eventlog("Hostname changed -> $new (console)", $id); + eventlog("Hostname changed -> $new ($source)", $id); } function delete_port($int_id) @@ -300,7 +306,7 @@ function addHost($host, $community, $snmpver, $port = 161, $transport = 'udp') { if (isPingable($host)) { - if (mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '$host'"), 0) == '0' ) + if (mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '$host'"), 0) == '0') { # FIXME internalize -- but we don't have $device yet! # FIXME this needs to be addhost.php's content instead, kindof, also use this function there then. @@ -378,7 +384,7 @@ function formatUptime($diff, $format="long") else { if ($yearsDiff > '0') { $uptime .= $yearsDiff . " years, "; } - if ($daysDiff > '0') { $uptime .= $daysDiff . " day" . ($daysDiff != 1 ? 's' : '' ) . ", "; } + if ($daysDiff > '0') { $uptime .= $daysDiff . " day" . ($daysDiff != 1 ? 's' : '') . ", "; } if ($hrsDiff > '0') { $uptime .= $hrsDiff . "h "; } if ($minsDiff > '0') { $uptime .= $minsDiff . "m "; } if ($secsDiff > '0') { $uptime .= $secsDiff . "s "; } @@ -402,12 +408,12 @@ function isSNMPable($device) function isPingable($hostname) { global $config; - $status = shell_exec($config['fping'] . " $hostname"); + $status = shell_exec($config['fping'] . " $hostname 2>/dev/null"); if (strstr($status, "alive")) { return TRUE; } else { - $status = shell_exec($config['fping6'] . " $hostname"); + $status = shell_exec($config['fping6'] . " $hostname 2>/dev/null"); if (strstr($status, "alive")) { return TRUE; diff --git a/includes/polling/os/arista_eos.inc.php b/includes/polling/os/arista_eos.inc.php index 966a6c886..d0ff19c36 100755 --- a/includes/polling/os/arista_eos.inc.php +++ b/includes/polling/os/arista_eos.inc.php @@ -1,6 +1,6 @@ \ No newline at end of file diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index 88657c743..999ea749a 100755 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -154,7 +154,7 @@ while ($port = mysql_fetch_array($port_query)) $update .= ", `$oid` = NULL"; log_event($oid . ": ".$port[$oid]." -> NULL", $device['device_id'], 'interface', $port['interface_id']); if ($debug) { echo($oid . ": ".$port[$oid]." -> NULL "); } else { echo($oid . " "); } - } elseif ($port[$oid] != $this_port[$oid] ) { + } elseif ($port[$oid] != $this_port[$oid]) { $update .= ", `$oid` = '".mres($this_port[$oid])."'"; log_event($oid . ": ".$port[$oid]." -> " . $this_port[$oid], $device['device_id'], 'interface', $port['interface_id']); if ($debug) { echo($oid . ": ".$port[$oid]." -> " . $this_port[$oid]." "); } else { echo($oid . " "); } @@ -251,7 +251,7 @@ while ($port = mysql_fetch_array($port_query)) { foreach ($pagp_oids as $oid) { // Loop the OIDs - if ($this_port[$oid] != $port[$oid] ) + if ($this_port[$oid] != $port[$oid]) { // If data has changed, build a query $update .= ", `$oid` = '".mres($this_port[$oid])."'"; echo("PAgP "); diff --git a/poll-billing.php b/poll-billing.php index c4b407606..b04e10361 100644 --- a/poll-billing.php +++ b/poll-billing.php @@ -105,7 +105,7 @@ function CollectData($bill_id) $prev_out_delta = '0'; } - if ($delta < '0' ) + if ($delta < '0') { $delta = $prev_delta; $in_delta = $prev_in_delta; diff --git a/poller.php b/poller.php index 6cbc60ab4..c64c23c42 100755 --- a/poller.php +++ b/poller.php @@ -12,8 +12,6 @@ * See COPYING for more details. */ -### Observium Device Poller - include("includes/defaults.inc.php"); include("config.php"); include("includes/functions.php"); @@ -48,17 +46,17 @@ if (isset($options['i']) && $options['i'] && isset($options['n'])) if (!$where) { - echo("-h | Poll single device\n"); - echo("-h odd Poll odd numbered devices (same as -i 2 -n 0)\n"); - echo("-h even Poll even numbered devices (same as -i 2 -n 1)\n"); - echo("-h all Poll all devices\n\n"); - echo("-i -n Poll as instance of \n"); - echo(" Instances start at 0. 0-3 for -n 4\n\n"); - echo("-d Enable some debugging output\n"); + echo("-h | Poll single device\n"); + echo("-h odd Poll odd numbered devices (same as -i 2 -n 0)\n"); + echo("-h even Poll even numbered devices (same as -i 2 -n 1)\n"); + echo("-h all Poll all devices\n\n"); + echo("-i -n Poll as instance of \n"); + echo(" Instances start at 0. 0-3 for -n 4\n\n"); + echo("-d Enable some debugging output\n"); echo("\n"); echo("No polling type specified!\n"); exit; - } +} if (isset($options['d'])) { @@ -76,7 +74,6 @@ if (isset($options['d'])) # ini_set('error_reporting', 0); } - echo("Starting polling run:\n\n"); $polled_devices = 0; $device_query = mysql_query("SELECT `device_id` FROM `devices` WHERE `ignore` = 0 AND `disabled` = 0 $where ORDER BY `device_id` ASC"); @@ -102,7 +99,6 @@ while ($device = mysql_fetch_assoc($device_query)) $host_rrd = $config['rrd_dir'] . "/" . $device['hostname']; if (!is_dir($host_rrd)) { mkdir($host_rrd); echo("Created directory : $host_rrd\n"); } - $device['pingable'] = isPingable($device['hostname']); if ($device['pingable']) { @@ -119,7 +115,7 @@ while ($device = mysql_fetch_assoc($device_query)) $status = "0"; } - if ($device['status'] != $status ) + if ($device['status'] != $status) { $poll_update .= $poll_separator . "`status` = '$status'"; $poll_separator = ", "; @@ -131,7 +127,6 @@ while ($device = mysql_fetch_assoc($device_query)) if ($status == "1") { - $graphs = array(); $oldgraphs = array(); @@ -175,8 +170,8 @@ while ($device = mysql_fetch_assoc($device_query)) if (is_numeric($uptime)) { - - if ($uptime < $device['uptime'] ) { + if ($uptime < $device['uptime']) + { notify($device,"Device rebooted: " . $device['hostname'], "Device Rebooted : " . $device['hostname'] . " " . formatUptime($uptime) . " ago."); log_event('Device rebooted after '.formatUptime($device['uptime']), $device['device_id'], 'reboot', $device['uptime']); } @@ -334,7 +329,6 @@ while ($device = mysql_fetch_assoc($device_query)) } } - $device_end = utime(); $device_run = $device_end - $device_start; $device_time = substr($device_run, 0, 5); $poll_update .= $poll_separator . "`last_polled_timetaken` = '$device_time'"; #echo("$device_end - $device_start; $device_time $device_run"); @@ -349,7 +343,6 @@ while ($device = mysql_fetch_assoc($device_query)) unset($storage_cache); // Clear cache of hrStorage ** MAYBE FIXME? ** unset($cache); // Clear cache (unify all things here?) - } $poller_end = utime(); $poller_run = $poller_end - $poller_start; $poller_time = substr($poller_run, 0, 5); @@ -369,4 +362,4 @@ unset($config); ### Remove this for testing #print_r(get_defined_vars()); -?> +?> \ No newline at end of file diff --git a/renamehost.php b/renamehost.php index 221f8fe07..e949a7ffc 100755 --- a/renamehost.php +++ b/renamehost.php @@ -13,7 +13,7 @@ if ($argv[1] && $argv[2]) $id = getidbyname($host); if ($id) { - renamehost($id, $argv[2]); + renamehost($id, $argv[2], 'console'); echo("Renamed $host\n"); } else { echo("Host doesn't exist!\n");