diff --git a/cleanup.php b/cleanup.php index 6cceabf3c..ebbff1619 100755 --- a/cleanup.php +++ b/cleanup.php @@ -41,7 +41,8 @@ while ($device = mysql_fetch_array($query)) unset($valid_ips); - foreach (explode("\n", $oids) as $data) { + foreach (explode("\n", $oids) as $data) + { $data = trim($data); list($ipv6addr,$ifIndex) = explode(" ", $data); $valid_ips[] = $ipv6addr; diff --git a/html/includes/graphs/bill/auth.inc.php b/html/includes/graphs/bill/auth.inc.php index 5710b48cb..f91c0b571 100644 --- a/html/includes/graphs/bill/auth.inc.php +++ b/html/includes/graphs/bill/auth.inc.php @@ -7,8 +7,7 @@ include("../includes/functions.php"); ## FIXME zeropad() if (is_numeric($_GET['id']) && ($config['allow_unauth_graphs'] || bill_permitted($_GET['id']))) { - - $bill_query = mysql_query("SELECT * FROM `bills` WHERE bill_id = '".mres($_GET['id'])."'"); + $bill_query = mysql_query("SELECT * FROM `bills` WHERE bill_id = '".mres($_GET['id'])."'"); $bill = mysql_fetch_assoc($bill_query); $day_data = getDates($bill['bill_day']); @@ -22,9 +21,6 @@ if (is_numeric($_GET['id']) && ($config['allow_unauth_graphs'] || bill_permitted AND D.device_id = P.device_id"); $auth = TRUE; - - - } -?> +?> \ No newline at end of file diff --git a/html/includes/graphs/multiport/bits.inc.php b/html/includes/graphs/multiport/bits.inc.php index 2aeb781f4..039bddcab 100644 --- a/html/includes/graphs/multiport/bits.inc.php +++ b/html/includes/graphs/multiport/bits.inc.php @@ -4,10 +4,10 @@ $i = 1; foreach (explode(",", $id) as $ifid) { - if(strstr($ifid, "!")) - { - $rrd_inverted[$i] = TRUE; - $ifid = str_replace("!", "", $ifid); + if (strstr($ifid, "!")) + { + $rrd_inverted[$i] = TRUE; + $ifid = str_replace("!", "", $ifid); } $query = mysql_query("SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.interface_id = '" . $ifid . "' AND I.device_id = D.device_id"); diff --git a/html/includes/graphs/port/mac_acc_total.inc.php b/html/includes/graphs/port/mac_acc_total.inc.php index 8c6729507..59ba6b048 100644 --- a/html/includes/graphs/port/mac_acc_total.inc.php +++ b/html/includes/graphs/port/mac_acc_total.inc.php @@ -51,6 +51,7 @@ while ($acc = mysql_fetch_array($query)) $mac = formatmac($acc['mac']); $name = $mac; $addy = mysql_fetch_array(mysql_query("SELECT * FROM ipv4_mac where mac_address = '".$acc['mac']."' AND interface_id = '".$acc['interface_id']."'")); + if ($addy) { $name = $addy['ipv4_address'] . " (".$mac.")"; @@ -69,8 +70,9 @@ while ($acc = mysql_fetch_array($query)) $peer_info = mysql_fetch_array($peer_query); $name .= " - AS".$peer_info['bgpPeerRemoteAs']; } - - if ($peer_info) { + + if ($peer_info) + { $asn = "AS".$peer_info['bgpPeerRemoteAs']; $astext = $peer_info['astext']; } else { unset ($as); unset ($astext); unset($asn); diff --git a/html/includes/graphs/storage/usage.inc.php b/html/includes/graphs/storage/usage.inc.php index 8022b99a6..712c0cd36 100644 --- a/html/includes/graphs/storage/usage.inc.php +++ b/html/includes/graphs/storage/usage.inc.php @@ -13,7 +13,7 @@ $rrd_options .= " COMMENT:' Size Free % Used\\n'"; $hostname = gethostbyid($storage['device_id']); -if ($iter=="1") { $colour="CC0000"; } elseif ($iter=="2") { $colour="008C00"; } elseif ($iter=="3") { $colour="4096EE"; } +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"; } diff --git a/html/index.php b/html/index.php index 364b4b112..1a280273f 100755 --- a/html/index.php +++ b/html/index.php @@ -34,7 +34,8 @@ $month = time() - (31 * 24 * 60 * 60); $year = time() - (365 * 24 * 60 * 60); # Load the settings for Multi-Tenancy. -if (is_array($config['branding'])) { +if (is_array($config['branding'])) +{ if ($config['branding'][$_SERVER['SERVER_NAME']]) { foreach ($config['branding'][$_SERVER['SERVER_NAME']] as $confitem => $confval) diff --git a/html/pages/bgp.inc.php b/html/pages/bgp.inc.php index 2e0abe207..40b40ce5f 100644 --- a/html/pages/bgp.inc.php +++ b/html/pages/bgp.inc.php @@ -11,7 +11,8 @@ else $i = "1"; - if ($_GET['opta'] == "alerts") { + if ($_GET['opta'] == "alerts") + { $where = "AND (B.bgpPeerAdminStatus = 'start' or B.bgpPeerAdminStatus = 'running') AND B.bgpPeerState != 'established'"; } elseif ($_GET['opta'] == "external") { $where = "AND D.bgpLocalAs != B.bgpPeerRemoteAs"; diff --git a/html/pages/device.inc.php b/html/pages/device.inc.php index 64173b3c1..8929a47d7 100644 --- a/html/pages/device.inc.php +++ b/html/pages/device.inc.php @@ -80,7 +80,8 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id']) '); } - if (is_dir($config['collectd_dir'] . "/" . $device['hostname'] ."/")) { + if (is_dir($config['collectd_dir'] . "/" . $device['hostname'] ."/")) + { echo('
CollectD
@@ -88,7 +89,8 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id'])
Ports
@@ -197,14 +199,17 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id'])
}
- if ($_SESSION['userlevel'] >= "7") {
+ if ($_SESSION['userlevel'] >= "7")
+ {
if (!is_array($config['rancid_configs'])) { $config['rancid_configs'] = array($config['rancid_configs']); }
- foreach ($config['rancid_configs'] as $configs) {
+ foreach ($config['rancid_configs'] as $configs)
+ {
if ($configs[strlen($configs)-1] != '/') { $configs .= '/'; }
if (is_file($configs . $device['hostname'])) { $device_config_file = $configs . $device['hostname']; }
}
}
- if ($device_config_file) {
+ if ($device_config_file)
+ {
echo('
Config
@@ -213,7 +218,8 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id'])
');
}
- if ($_SESSION['userlevel'] >= "7") {
+ if ($_SESSION['userlevel'] >= "7")
+ {
echo('
Settings
diff --git a/html/pages/device/edit.inc.php b/html/pages/device/edit.inc.php
index e17c84a50..d12df5d2b 100644
--- a/html/pages/device/edit.inc.php
+++ b/html/pages/device/edit.inc.php
@@ -9,12 +9,12 @@ if ($_SESSION['userlevel'] < '7')
$panes['snmp'] = 'SNMP';
$panes['ports'] = 'Port Settings';
$panes['apps'] = 'Applications';
-
+
if ($config['enable_services'])
{
$panes['services'] = 'Services';
}
-
+
$panes['ipmi'] = 'IPMI';
print_optionbar_start();
diff --git a/html/pages/device/edit/apps.inc.php b/html/pages/device/edit/apps.inc.php
index 6fd482b9f..32a58457b 100644
--- a/html/pages/device/edit/apps.inc.php
+++ b/html/pages/device/edit/apps.inc.php
@@ -25,7 +25,7 @@ if ($_POST['device'])
$enabled[] = "'" . substr($key,4) . "'";
}
}
-
+
$sql = "DELETE FROM applications WHERE device_id=" . $device['device_id'];
if ($enabled)
{
@@ -33,7 +33,7 @@ if ($_POST['device'])
}
mysql_query($sql);
$updated += mysql_affected_rows();
-
+
$sql = "SELECT app_type FROM applications WHERE device_id=" . $device['device_id'];
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result))
diff --git a/html/pages/devices.inc.php b/html/pages/devices.inc.php
index 0a0d55b9a..73e991b5f 100644
--- a/html/pages/devices.inc.php
+++ b/html/pages/devices.inc.php
@@ -90,7 +90,8 @@ print_optionbar_start(62);
= '5') {
+ if($_SESSION['userlevel'] >= '5')
+ {
$query = mysql_query("SELECT location FROM devices WHERE 1 $where GROUP BY location ORDER BY location");
} else {
$query = mysql_query("SELECT location FROM devices AS D, devices_perms AS P WHERE 1 $where AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' GROUP BY location ORDER BY location");
diff --git a/html/pages/edituser.inc.php b/html/pages/edituser.inc.php
index b6f94a9d4..e48de4c6d 100644
--- a/html/pages/edituser.inc.php
+++ b/html/pages/edituser.inc.php
@@ -14,37 +14,43 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
if ($_GET['action'] == "deldevperm")
{
- if (mysql_result(mysql_query("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = '" . $_GET['device_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
+ if (mysql_result(mysql_query("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = '" . $_GET['device_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0))
+ {
mysql_query("DELETE FROM devices_perms WHERE `device_id` = '" . $_GET['device_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'");
}
}
if ($_GET['action'] == "adddevperm")
{
- if (!mysql_result(mysql_query("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = '" . $_GET['device_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
+ if (!mysql_result(mysql_query("SELECT COUNT(*) FROM devices_perms WHERE `device_id` = '" . $_GET['device_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0))
+ {
mysql_query("INSERT INTO devices_perms (`device_id`, `user_id`) VALUES ('" . $_GET['device_id'] . "', '" . $_GET['user_id'] . "')");
}
}
if ($_GET['action'] == "delifperm")
{
- if (mysql_result(mysql_query("SELECT COUNT(*) FROM ports_perms WHERE `interface_id` = '" . $_GET['interface_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
+ if (mysql_result(mysql_query("SELECT COUNT(*) FROM ports_perms WHERE `interface_id` = '" . $_GET['interface_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0))
+ {
mysql_query("DELETE FROM ports_perms WHERE `interface_id` = '" . $_GET['interface_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'");
}
}
if ($_GET['action'] == "addifperm")
{
- if (!mysql_result(mysql_query("SELECT COUNT(*) FROM ports_perms WHERE `interface_id` = '" . $_GET['interface_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
+ if (!mysql_result(mysql_query("SELECT COUNT(*) FROM ports_perms WHERE `interface_id` = '" . $_GET['interface_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0))
+ {
mysql_query("INSERT INTO ports_perms (`interface_id`, `user_id`) VALUES ('" . $_GET['interface_id'] . "', '" . $_GET['user_id'] . "')");
}
}
if ($_GET['action'] == "delbillperm")
{
- if (mysql_result(mysql_query("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = '" . $_GET['bill_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
+ if (mysql_result(mysql_query("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = '" . $_GET['bill_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0))
+ {
mysql_query("DELETE FROM bill_perms WHERE `bill_id` = '" . $_GET['bill_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'");
}
}
if ($_GET['action'] == "addbillperm")
{
- if (!mysql_result(mysql_query("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = '" . $_GET['bill_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0)) {
+ if (!mysql_result(mysql_query("SELECT COUNT(*) FROM bill_perms WHERE `bill_id` = '" . $_GET['bill_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'"),0))
+ {
mysql_query("INSERT INTO bill_perms (`bill_id`, `user_id`) VALUES ('" . $_GET['bill_id'] . "', '" . $_GET['user_id'] . "')");
}
}
diff --git a/includes/discovery/os/vmware.inc.php b/includes/discovery/os/vmware.inc.php
index cfa17d63b..2fa6b19be 100755
--- a/includes/discovery/os/vmware.inc.php
+++ b/includes/discovery/os/vmware.inc.php
@@ -5,4 +5,4 @@ if (!$os)
if (preg_match("/^VMware ESX/", $sysDescr)) { $os = "vmware"; }
}
-?>
+?>
\ No newline at end of file
diff --git a/includes/discovery/ports.inc.php b/includes/discovery/ports.inc.php
index 873e35b6a..682594460 100755
--- a/includes/discovery/ports.inc.php
+++ b/includes/discovery/ports.inc.php
@@ -13,17 +13,21 @@ $ports = str_replace("ifDescr.", "", $ports);
$interface_ignored = 0;
$interface_added = 0;
-foreach (explode("\n", $ports) as $entry){
-
+foreach (explode("\n", $ports) as $entry)
+{
$entry = trim($entry);
list($ifIndex, $ifDescr) = explode(" ", $entry, 2);
- if (!strstr($entry, "irtual")) {
+ if (!strstr($entry, "irtual"))
+ {
$if = trim(strtolower($ifDescr));
$nullintf = 0;
foreach ($config['bad_if'] as $bi) { if (strstr($if, $bi)) { $nullintf = 1; } }
- if (is_array($config['bad_if_regexp'])) {
- foreach ($config['bad_if_regexp'] as $bi) {
- if (preg_match($bi ."i", $if)) {
+ if (is_array($config['bad_if_regexp']))
+ {
+ foreach ($config['bad_if_regexp'] as $bi)
+ {
+ if (preg_match($bi ."i", $if))
+ {
$nullintf = 1;
}
}
@@ -34,11 +38,13 @@ foreach (explode("\n", $ports) as $entry){
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; }
- if (isset($config['allow_ng']) && !$config['allow_ng']) {
+ if (isset($config['allow_ng']) && !$config['allow_ng'])
+ {
if (preg_match('/ng[0-9]+$/', $if)) { $nullintf = 1; }
}
if ($debug) echo("\n $if ");
- if ($nullintf == 0) {
+ if ($nullintf == 0)
+ {
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) == '0') {
mysql_query("INSERT INTO `ports` (`device_id`,`ifIndex`,`ifDescr`) VALUES ('".$device['device_id']."','$ifIndex','".mres($ifDescr)."')");
# Add Interface
@@ -61,19 +67,21 @@ foreach (explode("\n", $ports) as $entry){
}
}
-
$sql = "SELECT * FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `deleted` = '0'";
$query = mysql_query($sql);
-while ($test_if = mysql_fetch_array($query)) {
+while ($test_if = mysql_fetch_array($query))
+{
unset($exists);
$i = 0;
- while ($i < count($int_exists) && !isset($exists)) {
+ while ($i < count($int_exists) && !isset($exists))
+ {
$this_if = $test_if['ifIndex'];
if ($int_exists[$i] == $this_if) { $exists = 1; }
$i++;
}
- if (!$exists) {
+ if (!$exists)
+ {
echo("-");
mysql_query("UPDATE `ports` SET `deleted` = '1' WHERE interface_id = '" . $test_if['interface_id'] . "'");
}
@@ -82,4 +90,4 @@ while ($test_if = mysql_fetch_array($query)) {
unset($temp_exists);
echo("\n");
-?>
+?>
\ No newline at end of file
diff --git a/includes/discovery/processors/aos-device.inc.php b/includes/discovery/processors/aos-device.inc.php
index dc8ad89bc..a7079a236 100644
--- a/includes/discovery/processors/aos-device.inc.php
+++ b/includes/discovery/processors/aos-device.inc.php
@@ -3,8 +3,6 @@
global $valid_processor;
## Hardcoded discovery of device CPU usage on Alcatel-Lucent Omniswitches.
-##
-
if ($device['os'] == "aos")
{
@@ -21,4 +19,4 @@ if ($device['os'] == "aos")
unset ($processors_array);
-?>
+?>
\ No newline at end of file
diff --git a/includes/discovery/temperatures/cometsystem-p85xx.inc.php b/includes/discovery/temperatures/cometsystem-p85xx.inc.php
index a03ad0e36..c44587d4f 100644
--- a/includes/discovery/temperatures/cometsystem-p85xx.inc.php
+++ b/includes/discovery/temperatures/cometsystem-p85xx.inc.php
@@ -26,22 +26,22 @@ if ($device['os'] == "cometsystem-p85xx")
preg_match($regexp, $line, $match);
if ($match['name'])
{
- $out[$match['id']]['name'] = $match['name'];
+ $out[$match['id']]['name'] = $match['name'];
}
if ($match['temp_intval'])
{
- $out[$match['id']]['temp_intval'] = $match['temp_intval'];
+ $out[$match['id']]['temp_intval'] = $match['temp_intval'];
}
if ($match['limit_high'])
{
- $out[$match['id']]['limit_high'] = $match['limit_high'];
+ $out[$match['id']]['limit_high'] = $match['limit_high'];
}
if ($match['limit_low'])
{
- $out[$match['id']]['limit_low'] = $match['limit_low'];
+ $out[$match['id']]['limit_low'] = $match['limit_low'];
}
}
diff --git a/includes/discovery/vmware-vminfo.inc.php b/includes/discovery/vmware-vminfo.inc.php
index f83fc5583..a59d0523e 100755
--- a/includes/discovery/vmware-vminfo.inc.php
+++ b/includes/discovery/vmware-vminfo.inc.php
@@ -4,115 +4,108 @@
* Try to discover any Virtual Machines.
*/
-if ($device['os'] == "vmware") {
-
-
+if ($device['os'] == "vmware")
+{
+ /*
+ * Variable to hold the discovered Virtual Machines.
+ */
+
+ $vmw_vmlist = array();
+
+ /*
+ * CONSOLE: Start the VMware discovery process.
+ */
+
+ echo("VMware VM: ");
+
+ /*
+ * Fetch the list is Virtual Machines.
+ *
+ * VMWARE-VMINFO-MIB::vmwVmVMID.224 = INTEGER: 224
+ * VMWARE-VMINFO-MIB::vmwVmVMID.416 = INTEGER: 416
+ * ...
+ */
+
+ $oids = snmp_walk($device, "VMWARE-VMINFO-MIB::vmwVmVMID", "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
+ $oids = explode("\n", $oids);
+
+ foreach ($oids as $oid)
+ {
/*
- * Variable to hold the discovered Virtual Machines.
- */
-
- $vmw_vmlist = array();
-
-
- /*
- * CONSOLE: Start the VMware discovery process.
- */
-
- echo("VMware VM: ");
-
-
- /*
- * Fetch the list is Virtual Machines.
+ * Fetch the Virtual Machine information.
*
- * VMWARE-VMINFO-MIB::vmwVmVMID.224 = INTEGER: 224
- * VMWARE-VMINFO-MIB::vmwVmVMID.416 = INTEGER: 416
- * ...
+ * VMWARE-VMINFO-MIB::vmwVmDisplayName.224 = STRING: My First VM
+ * VMWARE-VMINFO-MIB::vmwVmDisplayName.416 = STRING: My Second VM
+ * VMWARE-VMINFO-MIB::vmwVmGuestOS.224 = STRING: windows7Server64Guest
+ * VMWARE-VMINFO-MIB::vmwVmGuestOS.416 = STRING: winLonghornGuest
+ * VMWARE-VMINFO-MIB::vmwVmMemSize.224 = INTEGER: 8192 megabytes
+ * VMWARE-VMINFO-MIB::vmwVmMemSize.416 = INTEGER: 8192 megabytes
+ * VMWARE-VMINFO-MIB::vmwVmState.224 = STRING: poweredOn
+ * VMWARE-VMINFO-MIB::vmwVmState.416 = STRING: poweredOn
+ * VMWARE-VMINFO-MIB::vmwVmVMID.224 = INTEGER: 224
+ * VMWARE-VMINFO-MIB::vmwVmVMID.416 = INTEGER: 416
+ * VMWARE-VMINFO-MIB::vmwVmCpus.224 = INTEGER: 2
+ * VMWARE-VMINFO-MIB::vmwVmCpus.416 = INTEGER: 2
*/
-
- $oids = snmp_walk($device, "VMWARE-VMINFO-MIB::vmwVmVMID", "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
- $oids = explode("\n", $oids);
-
- foreach ($oids as $oid) {
-
-
- /*
- * Fetch the Virtual Machine information.
- *
- * VMWARE-VMINFO-MIB::vmwVmDisplayName.224 = STRING: My First VM
- * VMWARE-VMINFO-MIB::vmwVmDisplayName.416 = STRING: My Second VM
- * VMWARE-VMINFO-MIB::vmwVmGuestOS.224 = STRING: windows7Server64Guest
- * VMWARE-VMINFO-MIB::vmwVmGuestOS.416 = STRING: winLonghornGuest
- * VMWARE-VMINFO-MIB::vmwVmMemSize.224 = INTEGER: 8192 megabytes
- * VMWARE-VMINFO-MIB::vmwVmMemSize.416 = INTEGER: 8192 megabytes
- * VMWARE-VMINFO-MIB::vmwVmState.224 = STRING: poweredOn
- * VMWARE-VMINFO-MIB::vmwVmState.416 = STRING: poweredOn
- * VMWARE-VMINFO-MIB::vmwVmVMID.224 = INTEGER: 224
- * VMWARE-VMINFO-MIB::vmwVmVMID.416 = INTEGER: 416
- * 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");
- $vmwVmGuestOS = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmGuestOS." . $oid, "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
- $vmwVmMemSize = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmMemSize." . $oid, "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
- $vmwVmState = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmState." . $oid, "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
- $vmwVmCpus = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmCpus." . $oid, "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
-
-
- /*
- * 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 absolete.
- */
-
- 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 vmware_vminfo WHERE device_id = '" . $device["device_id"] . "' AND vmwVmVMID = '" . $oid . "'"), 0) == 0) {
- mysql_query("INSERT INTO vmware_vminfo (device_id, vmwVmVMID, vmwVmDisplayName, vmwVmGuestOS, vmwVmMemSize, vmwVmCpus, vmwVmState) VALUES (" . $device["device_id"] . ", " . $oid . ", '" . mres($vmwVmDisplayName) . "', '" . mres($vmwVmGuestOS) . "', " . $vmwVmMemSize . ", " . $vmwVmCpus . ", '" . mres($vmwVmState) . "')");
- echo("+");
- } else {
- echo ".";
- }
-
-
- /*
- * Save the discovered Virtual Machine.
- */
-
- $vmw_vmlist[] = $oid;
- }
-
-
+
+ $vmwVmDisplayName = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmDisplayName." . $oid, "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
+ $vmwVmGuestOS = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmGuestOS." . $oid, "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
+ $vmwVmMemSize = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmMemSize." . $oid, "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
+ $vmwVmState = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmState." . $oid, "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
+ $vmwVmCpus = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmCpus." . $oid, "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
+
/*
- * Get a list of all the known Virtual Machines for this host.
+ * 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 absolete.
*/
-
- $db_vm_list = mysql_query("SELECT id, vmwVmVMID FROM vmware_vminfo WHERE device_id = '" . $device["device_id"] . "'");
-
- while ($db_vm = mysql_fetch_array($db_vm_list)) {
-
-
- /*
- * Delete the Virtual Machines that are removed from the host.
- */
-
- if (!in_array($db_vm["vmwVmVMID"], $vmw_vmlist)) {
- mysql_query("DELETE FROM vmware_vminfo WHERE id = '" . $db_vm["id"] . "'");
- echo("-");
- }
+
+ if (preg_match("/^([0-9]+) .*$/", $vmwVmMemSize, $matches))
+ {
+ $vmwVmMemSize = $matches[1];
}
-
-
+
/*
- * Finished discovering VMware information.
+ * Check whether the Virtual Machine is already known for this host.
*/
-
- echo("\n");
+
+ if (mysql_result(mysql_query("SELECT COUNT(id) FROM vmware_vminfo WHERE device_id = '" . $device["device_id"] . "' AND vmwVmVMID = '" . $oid . "'"), 0) == 0)
+ {
+ mysql_query("INSERT INTO vmware_vminfo (device_id, vmwVmVMID, vmwVmDisplayName, vmwVmGuestOS, vmwVmMemSize, vmwVmCpus, vmwVmState) VALUES (" . $device["device_id"] . ", " . $oid . ", '" . mres($vmwVmDisplayName) . "', '" . mres($vmwVmGuestOS) . "', " . $vmwVmMemSize . ", " . $vmwVmCpus . ", '" . mres($vmwVmState) . "')");
+ echo("+");
+ } else {
+ echo ".";
+ }
+
+ /*
+ * Save the discovered Virtual Machine.
+ */
+
+ $vmw_vmlist[] = $oid;
+ }
+
+ /*
+ * Get a list of all the known Virtual Machines for this host.
+ */
+
+ $db_vm_list = mysql_query("SELECT id, vmwVmVMID FROM vmware_vminfo WHERE device_id = '" . $device["device_id"] . "'");
+
+ while ($db_vm = mysql_fetch_array($db_vm_list))
+ {
+ /*
+ * Delete the Virtual Machines that are removed from the host.
+ */
+
+ if (!in_array($db_vm["vmwVmVMID"], $vmw_vmlist)) {
+ mysql_query("DELETE FROM vmware_vminfo WHERE id = '" . $db_vm["id"] . "'");
+ echo("-");
+ }
+ }
+
+ /*
+ * Finished discovering VMware information.
+ */
+
+ echo("\n");
}
+
?>
\ No newline at end of file
diff --git a/includes/functions.php b/includes/functions.php
index 476324782..1eff41650 100755
--- a/includes/functions.php
+++ b/includes/functions.php
@@ -92,7 +92,7 @@ function shorthost($hostname, $len=16)
{
$parts = explode(".", $hostname);
$shorthost = $parts[0];
- $i=1;
+ $i = 1;
while ($i < count($parts) && strlen($shorthost.'.'.$parts[$i]) < $len)
{
$shorthost = $shorthost.'.'.$parts[$i];
@@ -150,14 +150,14 @@ function format_si($rate)
$sizes = Array('', 'k', 'M', 'G', 'T', 'P', 'E');
$round = Array('2','2','2','2','2','2','2','2','2');
$ext = $sizes[0];
- for ($i=1; (($i < count($sizes)) && ($rate >= 1000)); $i++) { $rate = $rate / 1000; $ext = $sizes[$i]; }
+ for ($i = 1; (($i < count($sizes)) && ($rate >= 1000)); $i++) { $rate = $rate / 1000; $ext = $sizes[$i]; }
}
else
{
$sizes = Array('', 'm', 'u', 'n');
$round = Array('2','2','2','2');
$ext = $sizes[0];
- for ($i=1; (($i < count($sizes)) && ($rate != 0) && ($rate <= 0.1)); $i++) { $rate = $rate * 1000; $ext = $sizes[$i]; }
+ for ($i = 1; (($i < count($sizes)) && ($rate != 0) && ($rate <= 0.1)); $i++) { $rate = $rate * 1000; $ext = $sizes[$i]; }
}
return round($rate, $round[$i]).$ext;
@@ -167,7 +167,7 @@ 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;
}
@@ -256,7 +256,7 @@ function delete_port($int_id)
function delete_device($id)
{
global $config;
-
+
$host = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '$id'"), 0);
mysql_query("DELETE FROM `devices` WHERE `device_id` = '$id'");
$int_query = mysql_query("SELECT * FROM `ports` WHERE `device_id` = '$id'");
@@ -267,7 +267,7 @@ function delete_device($id)
delete_port($int_id);
$ret .= "Removed interface $int_id ($int_if)\n";
}
-
+
mysql_query("DELETE FROM `entPhysical` WHERE `device_id` = '$id'");
mysql_query("DELETE FROM `devices_attribs` WHERE `device_id` = '$id'");
mysql_query("DELETE FROM `devices_perms` WHERE `device_id` = '$id'");
@@ -286,7 +286,7 @@ function delete_device($id)
mysql_query("DELETE FROM `current` WHERE `device_id` = '$id'");
mysql_query("DELETE FROM `sensors` WHERE `device_id` = '$id'");
shell_exec("rm -rf ".trim($config['rrd_dir'])."/$host");
-
+
$ret = "Removed Device $host\n";
return $ret;
}
@@ -294,7 +294,7 @@ function delete_device($id)
function addHost($host, $community, $snmpver, $port = 161, $transport = 'udp')
{
global $config;
-
+
list($hostshort) = explode(".", $host);
if (isDomainResolves($host))
{
@@ -746,7 +746,7 @@ function hex2str($hex)
{
$string='';
- for ($i=0; $i < strlen($hex)-1; $i+=2)
+ for ($i = 0; $i < strlen($hex)-1; $i+=2)
{
$string .= chr(hexdec($hex[$i].$hex[$i+1]));
}
@@ -790,4 +790,4 @@ function include_dir($dir, $regex = "")
}
}
-?>
+?>
\ No newline at end of file
diff --git a/includes/polling/os/vmware.inc.php b/includes/polling/os/vmware.inc.php
index 4caee61f4..a83cb4d5e 100644
--- a/includes/polling/os/vmware.inc.php
+++ b/includes/polling/os/vmware.inc.php
@@ -3,100 +3,97 @@
/*
* Fetch the VMware product version.
*
- * VMWARE-SYSTEM-MIB::vmwProdName.0 = STRING: VMware ESXi
- * VMWARE-SYSTEM-MIB::vmwProdVersion.0 = STRING: 4.1.0
- * VMWARE-SYSTEM-MIB::vmwProdBuild.0 = STRING: 348481
+ * VMWARE-SYSTEM-MIB::vmwProdName.0 = STRING: VMware ESXi
+ * VMWARE-SYSTEM-MIB::vmwProdVersion.0 = STRING: 4.1.0
+ * VMWARE-SYSTEM-MIB::vmwProdBuild.0 = STRING: 348481
*
- * version: ESXi 4.1.0
- * features: build-348481
+ * version: ESXi 4.1.0
+ * features: build-348481
*/
-$data = snmp_get_multi($device, "VMWARE-SYSTEM-MIB::vmwProdName.0 VMWARE-SYSTEM-MIB::vmwProdVersion.0 VMWARE-SYSTEM-MIB::vmwProdBuild.0", "-OQUs", "+VMWARE-ROOT-MIB:VMWARE-SYSTEM-MIB", "+" . $config['install_dir'] . "/mibs/vmware");
+$data = snmp_get_multi($device, "VMWARE-SYSTEM-MIB::vmwProdName.0 VMWARE-SYSTEM-MIB::vmwProdVersion.0 VMWARE-SYSTEM-MIB::vmwProdBuild.0", "-OQUs", "+VMWARE-ROOT-MIB:VMWARE-SYSTEM-MIB", "+" . $config['install_dir'] . "/mibs/vmware");
$version = preg_replace("/^VMware /", "", $data[0]["vmwProdName"]) . " " . $data[0]["vmwProdVersion"];
$features = "build-" . $data[0]["vmwProdBuild"];
-
/*
* VMware ESXi returns "not set" instead of a NULL value.
*/
-if ($sysLocation == "not set") {
- $sysLocation = "";
+if ($sysLocation == "not set")
+{
+ $sysLocation = "";
}
-if ($sysContact == "not set") {
- $sysContact = "";
+if ($sysContact == "not set")
+{
+ $sysContact = "";
}
-
/*
* CONSOLE: Start the VMware discovery process.
*/
echo("VMware VM: ");
-
/*
* Get a list of all the known Virtual Machines for this host.
*/
$db_info_list = mysql_query("SELECT id, vmwVmVMID, vmwVmDisplayName, vmwVmGuestOS, vmwVmMemSize, vmwVmCpus, vmwVmState FROM vmware_vminfo WHERE device_id = '" . $device["device_id"] . "'");
-while ($db_info = mysql_fetch_array($db_info_list)) {
-
-
- /*
- * Fetch the Virtual Machine information.
- *
- * VMWARE-VMINFO-MIB::vmwVmDisplayName.224 = STRING: My First VM
- * VMWARE-VMINFO-MIB::vmwVmGuestOS.224 = STRING: windows7Server64Guest
- * VMWARE-VMINFO-MIB::vmwVmMemSize.224 = INTEGER: 8192 megabytes
- * VMWARE-VMINFO-MIB::vmwVmState.224 = STRING: poweredOn
- * VMWARE-VMINFO-MIB::vmwVmVMID.224 = INTEGER: 224
- * VMWARE-VMINFO-MIB::vmwVmCpus.224 = INTEGER: 2
- */
-
- $vm_info = array();
-
- $vm_info["vmwVmDisplayName"] = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmDisplayName." . $db_info["vmwVmVMID"], "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
- $vm_info["vmwVmGuestOS"] = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmGuestOS." . $db_info["vmwVmVMID"], "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
- $vm_info["vmwVmMemSize"] = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmMemSize." . $db_info["vmwVmVMID"], "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
- $vm_info["vmwVmState"] = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmState." . $db_info["vmwVmVMID"], "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
- $vm_info["vmwVmCpus"] = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmCpus." . $db_info["vmwVmVMID"], "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
-
-
- /*
- * 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 absolete.
- */
-
- if (preg_match("/^([0-9]+) .*$/", $vm_info["vmwVmMemSize"], $matches)) {
- $vm_info["vmwVmMemSize"] = $matches[1];
- }
-
-
- /*
- * Proceess all the VMware Virtual Machine properties.
- */
-
- foreach ($vm_info as $property => $value) {
-
-
- /*
- * Check the property for any modifications.
- */
-
- if ($vm_info[$property] != $db_info[$property]) {
- mysql_query("UPDATE vmware_vminfo SET " . $property ." = '" . mres($vm_info[$property]) ."' WHERE id = '" . $db_info["id"] . "'");
- log_event($db_info["vmwVmDisplayName"] . " (" . preg_replace("/^vmwVm/", "", $property) . ") -> " . $vm_info[$property], $device['device_id']);
- }
- }
-}
+while ($db_info = mysql_fetch_array($db_info_list))
+{
+ /*
+ * Fetch the Virtual Machine information.
+ *
+ * VMWARE-VMINFO-MIB::vmwVmDisplayName.224 = STRING: My First VM
+ * VMWARE-VMINFO-MIB::vmwVmGuestOS.224 = STRING: windows7Server64Guest
+ * VMWARE-VMINFO-MIB::vmwVmMemSize.224 = INTEGER: 8192 megabytes
+ * VMWARE-VMINFO-MIB::vmwVmState.224 = STRING: poweredOn
+ * VMWARE-VMINFO-MIB::vmwVmVMID.224 = INTEGER: 224
+ * VMWARE-VMINFO-MIB::vmwVmCpus.224 = INTEGER: 2
+ */
+ $vm_info = array();
+
+ $vm_info["vmwVmDisplayName"] = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmDisplayName." . $db_info["vmwVmVMID"], "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
+ $vm_info["vmwVmGuestOS"] = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmGuestOS." . $db_info["vmwVmVMID"], "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
+ $vm_info["vmwVmMemSize"] = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmMemSize." . $db_info["vmwVmVMID"], "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
+ $vm_info["vmwVmState"] = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmState." . $db_info["vmwVmVMID"], "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
+ $vm_info["vmwVmCpus"] = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmCpus." . $db_info["vmwVmVMID"], "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
+
+ /*
+ * 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 absolete.
+ */
+
+ if (preg_match("/^([0-9]+) .*$/", $vm_info["vmwVmMemSize"], $matches))
+ {
+ $vm_info["vmwVmMemSize"] = $matches[1];
+ }
+
+ /*
+ * Proceess all the VMware Virtual Machine properties.
+ */
+
+ foreach ($vm_info as $property => $value)
+ {
+ /*
+ * Check the property for any modifications.
+ */
+
+ if ($vm_info[$property] != $db_info[$property])
+ {
+ mysql_query("UPDATE vmware_vminfo SET " . $property ." = '" . mres($vm_info[$property]) ."' WHERE id = '" . $db_info["id"] . "'");
+ log_event($db_info["vmwVmDisplayName"] . " (" . preg_replace("/^vmwVm/", "", $property) . ") -> " . $vm_info[$property], $device['device_id']);
+ }
+ }
+}
/*
* Finished discovering VMware information.
*/
echo("\n");
+
?>
\ No newline at end of file