From 6a1cce6090661d2f6eb8431cdceee9763eab4d62 Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Mon, 7 May 2012 16:23:43 +0000 Subject: [PATCH] syntaxer run git-svn-id: http://www.observium.org/svn/observer/trunk@3147 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/map.php | 8 ++-- html/pages/device/edit.inc.php | 2 +- html/pages/device/edit/icon.inc.php | 1 - includes/discovery/bgp-peers.inc.php | 2 +- includes/discovery/vmware-vminfo.inc.php | 22 +++++----- includes/polling/system.inc.php | 2 +- .../polling/unix-agent/munin-plugins.inc.php | 44 +++++++++---------- includes/rrdtool.inc.php | 4 +- 8 files changed, 42 insertions(+), 43 deletions(-) diff --git a/html/map.php b/html/map.php index 0852b8364..35faea90b 100755 --- a/html/map.php +++ b/html/map.php @@ -60,7 +60,7 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) $links = dbFetch("SELECT * from ports AS I, links AS L WHERE I.device_id = ? AND L.local_interface_id = I.interface_id ORDER BY L.remote_hostname", array($device['device_id'])); if (count($links)) { - if($anon) { $device['hostname'] = md5($device['hostname']); } + if ($anon) { $device['hostname'] = md5($device['hostname']); } if (!isset($locations[$device['location']])) { $locations[$device['location']] = $loc_count; $loc_count++; } $loc_id = $locations[$device['location']]; @@ -95,17 +95,17 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) } $src = $device['hostname']; - if($anon) { $src = md5($src); } + if ($anon) { $src = md5($src); } if ($remote_interface_id) { - $dst = dbFetchCell("SELECT `hostname` FROM `devices` AS D, `ports` AS I WHERE I.interface_id = ? AND D.device_id = I.device_id", array($remote_interface_id)); + $dst = dbFetchCell("SELECT `hostname` FROM `devices` AS D, `ports` AS I WHERE I.interface_id = ? AND D.device_id = I.device_id", array($remote_interface_id)); $dst_host = dbFetchCell("SELECT D.device_id FROM `devices` AS D, `ports` AS I WHERE I.interface_id = ? AND D.device_id = I.device_id", array($remote_interface_id)); } else { unset($dst_host); $dst = $link['remote_hostname']; } - if($anon) { $dst = md5($dst); $src = md5($src);} + if ($anon) { $dst = md5($dst); $src = md5($src);} $sif = ifNameDescr(dbFetchRow("SELECT * FROM ports WHERE `interface_id` = ?", array($link['local_interface_id'])),$device); if ($remote_interface_id) diff --git a/html/pages/device/edit.inc.php b/html/pages/device/edit.inc.php index 374570e35..3f387be2a 100644 --- a/html/pages/device/edit.inc.php +++ b/html/pages/device/edit.inc.php @@ -28,7 +28,7 @@ if ($_SESSION['userlevel'] < '7') } $panes['ipmi'] = 'IPMI'; - + print_optionbar_start(); unset($sep); diff --git a/html/pages/device/edit/icon.inc.php b/html/pages/device/edit/icon.inc.php index 3b78c7ff9..62184c94a 100644 --- a/html/pages/device/edit/icon.inc.php +++ b/html/pages/device/edit/icon.inc.php @@ -60,7 +60,6 @@ for ($i = 0;$i < count($config['os'][$device['os']]['icons']);$i++) echo('' . "\n"); } - if ($numicons %10 == 0) { echo(" \n"); diff --git a/includes/discovery/bgp-peers.inc.php b/includes/discovery/bgp-peers.inc.php index 3792859f0..783732c7f 100755 --- a/includes/discovery/bgp-peers.inc.php +++ b/includes/discovery/bgp-peers.inc.php @@ -151,7 +151,7 @@ if ($config['enable_bgp']) $j_afisafi[$index][] = $afisafi; } } - + foreach ($j_afisafi[$j_peerIndexes[$peer['ip']]] as $afisafi) { list ($afi,$safi) = explode('.',$afisafi); $safi = $safis[$safi]; diff --git a/includes/discovery/vmware-vminfo.inc.php b/includes/discovery/vmware-vminfo.inc.php index 4ce399f55..28c396807 100755 --- a/includes/discovery/vmware-vminfo.inc.php +++ b/includes/discovery/vmware-vminfo.inc.php @@ -32,7 +32,7 @@ if (($device['os'] == "vmware") || ($device['os'] == "linux")) if ($oids != "") { $oids = explode("\n", $oids); - + foreach ($oids as $oid) { /* @@ -51,27 +51,27 @@ if (($device['os'] == "vmware") || ($device['os'] == "linux")) * VMWARE-VMINFO-MIB::vmwVmCpus.224 = INTEGER: 2 * VMWARE-VMINFO-MIB::vmwVmCpus.416 = INTEGER: 2 */ - + $vmwVmDisplayName = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmDisplayName." . $oid, "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware:" . $config["install_dir"] . "/mibs"); $vmwVmGuestOS = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmGuestOS." . $oid, "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware:" . $config["install_dir"] . "/mibs"); $vmwVmMemSize = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmMemSize." . $oid, "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware:" . $config["install_dir"] . "/mibs"); $vmwVmState = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmState." . $oid, "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware:" . $config["install_dir"] . "/mibs"); $vmwVmCpus = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmCpus." . $oid, "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware:" . $config["install_dir"] . "/mibs"); - + /* * VMware does not return an INTEGER but a STRING of the vmwVmMemSize. This bug * might be resolved by VMware in the future making this code obsolete. */ - + if (preg_match("/^([0-9]+) .*$/", $vmwVmMemSize, $matches)) { $vmwVmMemSize = $matches[1]; } - + /* * Check whether the Virtual Machine is already known for this host. */ - + if (mysql_result(mysql_query("SELECT COUNT(id) FROM vminfo WHERE device_id = '" . $device["device_id"] . "' AND vmwVmVMID = '" . $oid . "' AND vm_type='vmware'"), 0) == 0) { mysql_query("INSERT INTO vminfo (device_id, vm_type, vmwVmVMID, vmwVmDisplayName, vmwVmGuestOS, vmwVmMemSize, vmwVmCpus, vmwVmState) VALUES (" . $device["device_id"] . ",'vmware', " . $oid . ", '" . mres($vmwVmDisplayName) . "', '" . mres($vmwVmGuestOS) . "', " . $vmwVmMemSize . ", " . $vmwVmCpus . ", '" . mres($vmwVmState) . "')"); @@ -81,15 +81,15 @@ if (($device['os'] == "vmware") || ($device['os'] == "linux")) echo("."); } # FIXME update code! - + /* * Save the discovered Virtual Machine. */ - + $vmw_vmlist[] = $oid; } } - + /* * Get a list of all the known Virtual Machines for this host. */ @@ -113,8 +113,8 @@ if (($device['os'] == "vmware") || ($device['os'] == "linux")) /* * Finished discovering VMware information. */ - + echo("\n"); } - + ?> \ No newline at end of file diff --git a/includes/polling/system.inc.php b/includes/polling/system.inc.php index 7a3add003..ffdef2b25 100755 --- a/includes/polling/system.inc.php +++ b/includes/polling/system.inc.php @@ -20,7 +20,7 @@ $poll_device['sysObjectID'] = snmp_get($device, "sysObjectID.0", "-Oqvn", "SNMPv2-MIB"); $poll_device['sysName'] = strtolower($poll_device['sysName']); - if(!empty($agent_data['uptime'])) { list($uptime) = explode(" ", $agent_data['uptime']); $uptime = round($uptime); echo("Using UNIX Agent Uptime ($uptime)\n");} + if (!empty($agent_data['uptime'])) { list($uptime) = explode(" ", $agent_data['uptime']); $uptime = round($uptime); echo("Using UNIX Agent Uptime ($uptime)\n");} if (empty($uptime)) { diff --git a/includes/polling/unix-agent/munin-plugins.inc.php b/includes/polling/unix-agent/munin-plugins.inc.php index ac7efc094..5c00aee27 100755 --- a/includes/polling/unix-agent/munin-plugins.inc.php +++ b/includes/polling/unix-agent/munin-plugins.inc.php @@ -4,7 +4,7 @@ if (!empty($agent_data['munin'])) { echo("Munin Plugins:"); - if($debug) { print_r($agent_data['munin']); } + if ($debug) { print_r($agent_data['munin']); } // Build array of existing plugins $plugins_dbq = dbFetchRows("SELECT * FROM `munin_plugins` WHERE `device_id` = ?", array($device['device_id'])); @@ -18,12 +18,12 @@ if (is_dir($old_plugins_rrd_dir) && !is_dir($plugins_rrd_dir)) { rename($old_plugins_dir, $plugins_dir); } if (!is_dir($plugins_rrd_dir)) { mkdir($plugins_rrd_dir); echo("Created directory : $plugins_rrd_dir\n"); } $plugin = array(); - foreach($agent_data['munin'] AS $plugin_type => $plugin_data) + foreach ($agent_data['munin'] AS $plugin_type => $plugin_data) { $plugin = array(); # list($plugin_type, $instance) = explode("_", $plugin_type); -# if(!empty($instance)) +# if (!empty($instance)) # { # echo("\nPlugin: $plugin_type ($instance)"); # $plugin_rrd = $plugins_rrd_dir . "/" . $plugin_type."_".$instance; @@ -34,12 +34,12 @@ $plugin_uniq = $plugin_type."_"; # } - if($debug) { echo("\n[$plugin_data]\n"); } - - foreach(explode("\n", $plugin_data) as $line) + if ($debug) { echo("\n[$plugin_data]\n"); } + + foreach (explode("\n", $plugin_data) as $line) { list($key, $value) = explode(" ", $line, 2); - if(preg_match("/^graph_/", $key)) + if (preg_match("/^graph_/", $key)) { list(,$key) = explode("_", $key); $plugin['graph'][$key] = $value; @@ -49,7 +49,7 @@ } } - if(!is_array($plugins_db[$plugin_type])) + if (!is_array($plugins_db[$plugin_type])) { $insert = array('device_id' => $device['device_id'], 'mplug_type' => $plugin_type, 'mplug_instance' => ($instance == NULL ? array('NULL') : $instance), @@ -64,10 +64,10 @@ $mplug_id = $plugins_db[$plugin_type]['id']; } - if($mplug_id) + if ($mplug_id) { - echo(" ID: $mplug_id"); + echo(" ID: $mplug_id"); $dbq = dbFetchRows("SELECT * FROM `munin_plugins_ds` WHERE `mplug_id` = ?", array($mplug_id)); foreach ($dbq as $v) @@ -75,27 +75,27 @@ $vu = $v['mplug_id']."_".$v['ds_name']; $ds_list[$vu] = 1; } - unset($dbq); unset($v); + unset($dbq); unset($v); - foreach($plugin['values'] as $name => $data) + foreach ($plugin['values'] as $name => $data) { echo(" $name"); - if(empty($data['type'])) { $data['type'] = "GAUGE"; } - if(empty($data['graph'])) { $data['graph'] = "yes"; } - if(empty($data['label'])) { $data['label'] = $name; } - if(empty($data['draw'])) { $data['draw'] = "LINE1.5"; } + if (empty($data['type'])) { $data['type'] = "GAUGE"; } + if (empty($data['graph'])) { $data['graph'] = "yes"; } + if (empty($data['label'])) { $data['label'] = $name; } + if (empty($data['draw'])) { $data['draw'] = "LINE1.5"; } - $cmd = "--step 300 DS:val:".$data['type'].":600:0:U "; + $cmd = "--step 300 DS:val:".$data['type'].":600:0:U "; $cmd .= $config['rrd_rra']; $ds_uniq = $mplug_id."_".$name; - $filename = $plugin_rrd."_".$name.".rrd"; - if (!is_file($filename)) + $filename = $plugin_rrd."_".$name.".rrd"; + if (!is_file($filename)) { - rrdtool_create($filename, $cmd); + rrdtool_create($filename, $cmd); } - rrdtool_update($filename,"N:".$data['value']); + rrdtool_update($filename,"N:".$data['value']); - if(empty($ds_list[$ds_uniq])) + if (empty($ds_list[$ds_uniq])) { $insert = array('mplug_id' => $mplug_id, 'ds_name' => $name, 'ds_type' => $data['type'], 'ds_label' => $data['label'], diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index ee186486a..e36f92287 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -162,7 +162,7 @@ function rrdtool($command, $filename, $options) $cmd .= " --daemon " . $config['rrdcached']; } - if($config['norrd']) + if ($config['norrd']) { print Console_Color::convert("%g RRD Disabled %n", false); } else { @@ -194,7 +194,7 @@ function rrdtool_create($filename, $options) { global $config, $debug; - if($config['norrd']) + if ($config['norrd']) { print Console_Color::convert("%g RRD Disabled %n", false); } else {