mirror of
https://github.com/stylersnico/librenms.git
synced 2026-08-01 16:26:55 +02:00
code standard/cleanups
git-svn-id: http://www.observium.org/svn/observer/trunk@1978 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
+2
-1
@@ -41,7 +41,8 @@ while ($device = mysql_fetch_array($query))
|
|||||||
|
|
||||||
unset($valid_ips);
|
unset($valid_ips);
|
||||||
|
|
||||||
foreach (explode("\n", $oids) as $data) {
|
foreach (explode("\n", $oids) as $data)
|
||||||
|
{
|
||||||
$data = trim($data);
|
$data = trim($data);
|
||||||
list($ipv6addr,$ifIndex) = explode(" ", $data);
|
list($ipv6addr,$ifIndex) = explode(" ", $data);
|
||||||
$valid_ips[] = $ipv6addr;
|
$valid_ips[] = $ipv6addr;
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ include("../includes/functions.php"); ## FIXME zeropad()
|
|||||||
|
|
||||||
if (is_numeric($_GET['id']) && ($config['allow_unauth_graphs'] || bill_permitted($_GET['id'])))
|
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);
|
$bill = mysql_fetch_assoc($bill_query);
|
||||||
|
|
||||||
$day_data = getDates($bill['bill_day']);
|
$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");
|
AND D.device_id = P.device_id");
|
||||||
|
|
||||||
$auth = TRUE;
|
$auth = TRUE;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -4,10 +4,10 @@ $i = 1;
|
|||||||
|
|
||||||
foreach (explode(",", $id) as $ifid)
|
foreach (explode(",", $id) as $ifid)
|
||||||
{
|
{
|
||||||
if(strstr($ifid, "!"))
|
if (strstr($ifid, "!"))
|
||||||
{
|
{
|
||||||
$rrd_inverted[$i] = TRUE;
|
$rrd_inverted[$i] = TRUE;
|
||||||
$ifid = str_replace("!", "", $ifid);
|
$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");
|
$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");
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ while ($acc = mysql_fetch_array($query))
|
|||||||
$mac = formatmac($acc['mac']);
|
$mac = formatmac($acc['mac']);
|
||||||
$name = $mac;
|
$name = $mac;
|
||||||
$addy = mysql_fetch_array(mysql_query("SELECT * FROM ipv4_mac where mac_address = '".$acc['mac']."' AND interface_id = '".$acc['interface_id']."'"));
|
$addy = mysql_fetch_array(mysql_query("SELECT * FROM ipv4_mac where mac_address = '".$acc['mac']."' AND interface_id = '".$acc['interface_id']."'"));
|
||||||
|
|
||||||
if ($addy)
|
if ($addy)
|
||||||
{
|
{
|
||||||
$name = $addy['ipv4_address'] . " (".$mac.")";
|
$name = $addy['ipv4_address'] . " (".$mac.")";
|
||||||
@@ -69,8 +70,9 @@ while ($acc = mysql_fetch_array($query))
|
|||||||
$peer_info = mysql_fetch_array($peer_query);
|
$peer_info = mysql_fetch_array($peer_query);
|
||||||
$name .= " - AS".$peer_info['bgpPeerRemoteAs'];
|
$name .= " - AS".$peer_info['bgpPeerRemoteAs'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($peer_info) {
|
if ($peer_info)
|
||||||
|
{
|
||||||
$asn = "AS".$peer_info['bgpPeerRemoteAs']; $astext = $peer_info['astext'];
|
$asn = "AS".$peer_info['bgpPeerRemoteAs']; $astext = $peer_info['astext'];
|
||||||
} else {
|
} else {
|
||||||
unset ($as); unset ($astext); unset($asn);
|
unset ($as); unset ($astext); unset($asn);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ $rrd_options .= " COMMENT:' Size Free % Used\\n'";
|
|||||||
|
|
||||||
$hostname = gethostbyid($storage['device_id']);
|
$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=="4") { $colour="73880A"; } elseif ($iter=="5") { $colour="D01F3C"; } elseif ($iter=="6") { $colour="36393D"; }
|
||||||
elseif ($iter=="7") { $colour="FF0084"; $iter = "0"; }
|
elseif ($iter=="7") { $colour="FF0084"; $iter = "0"; }
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -34,7 +34,8 @@ $month = time() - (31 * 24 * 60 * 60);
|
|||||||
$year = time() - (365 * 24 * 60 * 60);
|
$year = time() - (365 * 24 * 60 * 60);
|
||||||
|
|
||||||
# Load the settings for Multi-Tenancy.
|
# Load the settings for Multi-Tenancy.
|
||||||
if (is_array($config['branding'])) {
|
if (is_array($config['branding']))
|
||||||
|
{
|
||||||
if ($config['branding'][$_SERVER['SERVER_NAME']])
|
if ($config['branding'][$_SERVER['SERVER_NAME']])
|
||||||
{
|
{
|
||||||
foreach ($config['branding'][$_SERVER['SERVER_NAME']] as $confitem => $confval)
|
foreach ($config['branding'][$_SERVER['SERVER_NAME']] as $confitem => $confval)
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ else
|
|||||||
|
|
||||||
$i = "1";
|
$i = "1";
|
||||||
|
|
||||||
if ($_GET['opta'] == "alerts") {
|
if ($_GET['opta'] == "alerts")
|
||||||
|
{
|
||||||
$where = "AND (B.bgpPeerAdminStatus = 'start' or B.bgpPeerAdminStatus = 'running') AND B.bgpPeerState != 'established'";
|
$where = "AND (B.bgpPeerAdminStatus = 'start' or B.bgpPeerAdminStatus = 'running') AND B.bgpPeerState != 'established'";
|
||||||
} elseif ($_GET['opta'] == "external") {
|
} elseif ($_GET['opta'] == "external") {
|
||||||
$where = "AND D.bgpLocalAs != B.bgpPeerRemoteAs";
|
$where = "AND D.bgpLocalAs != B.bgpPeerRemoteAs";
|
||||||
|
|||||||
@@ -80,7 +80,8 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id'])
|
|||||||
</li>');
|
</li>');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_dir($config['collectd_dir'] . "/" . $device['hostname'] ."/")) {
|
if (is_dir($config['collectd_dir'] . "/" . $device['hostname'] ."/"))
|
||||||
|
{
|
||||||
echo('<li class="' . $select['collectd'] . '">
|
echo('<li class="' . $select['collectd'] . '">
|
||||||
<a href="'.$config['base_url'].'/device/' . $device['device_id'] . '/collectd/">
|
<a href="'.$config['base_url'].'/device/' . $device['device_id'] . '/collectd/">
|
||||||
<img src="images/16/chart_line.png" align="absmiddle" border="0" /> CollectD
|
<img src="images/16/chart_line.png" align="absmiddle" border="0" /> CollectD
|
||||||
@@ -88,7 +89,8 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id'])
|
|||||||
</li>');
|
</li>');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (@mysql_result(mysql_query("select count(interface_id) from ports WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') {
|
if (@mysql_result(mysql_query("select count(interface_id) from ports WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0')
|
||||||
|
{
|
||||||
echo('<li class="' . $select['ports'] . '">
|
echo('<li class="' . $select['ports'] . '">
|
||||||
<a href="'.$config['base_url'].'/device/' . $device['device_id'] . '/ports/' .$config['ports_page_default']. '">
|
<a href="'.$config['base_url'].'/device/' . $device['device_id'] . '/ports/' .$config['ports_page_default']. '">
|
||||||
<img src="images/16/connect.png" align="absmiddle" border="0" /> Ports
|
<img src="images/16/connect.png" align="absmiddle" border="0" /> 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']); }
|
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 ($configs[strlen($configs)-1] != '/') { $configs .= '/'; }
|
||||||
if (is_file($configs . $device['hostname'])) { $device_config_file = $configs . $device['hostname']; }
|
if (is_file($configs . $device['hostname'])) { $device_config_file = $configs . $device['hostname']; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($device_config_file) {
|
if ($device_config_file)
|
||||||
|
{
|
||||||
echo('<li class="' . $select['showconfig'] . '">
|
echo('<li class="' . $select['showconfig'] . '">
|
||||||
<a href="'.$config['base_url']."/device/" . $device['device_id'] . '/showconfig/">
|
<a href="'.$config['base_url']."/device/" . $device['device_id'] . '/showconfig/">
|
||||||
<img src="images/16/page_white_text.png" align="absmiddle" border="0" /> Config
|
<img src="images/16/page_white_text.png" align="absmiddle" border="0" /> Config
|
||||||
@@ -213,7 +218,8 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id'])
|
|||||||
');
|
');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_SESSION['userlevel'] >= "7") {
|
if ($_SESSION['userlevel'] >= "7")
|
||||||
|
{
|
||||||
echo('<li class="' . $select['edit'] . '">
|
echo('<li class="' . $select['edit'] . '">
|
||||||
<a href="'.$config['base_url']."/device/" . $device['device_id'] . '/edit/">
|
<a href="'.$config['base_url']."/device/" . $device['device_id'] . '/edit/">
|
||||||
<img src="images/16/server_edit.png" align="absmiddle" border="0" /> Settings
|
<img src="images/16/server_edit.png" align="absmiddle" border="0" /> Settings
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ if ($_SESSION['userlevel'] < '7')
|
|||||||
$panes['snmp'] = 'SNMP';
|
$panes['snmp'] = 'SNMP';
|
||||||
$panes['ports'] = 'Port Settings';
|
$panes['ports'] = 'Port Settings';
|
||||||
$panes['apps'] = 'Applications';
|
$panes['apps'] = 'Applications';
|
||||||
|
|
||||||
if ($config['enable_services'])
|
if ($config['enable_services'])
|
||||||
{
|
{
|
||||||
$panes['services'] = 'Services';
|
$panes['services'] = 'Services';
|
||||||
}
|
}
|
||||||
|
|
||||||
$panes['ipmi'] = 'IPMI';
|
$panes['ipmi'] = 'IPMI';
|
||||||
|
|
||||||
print_optionbar_start();
|
print_optionbar_start();
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ if ($_POST['device'])
|
|||||||
$enabled[] = "'" . substr($key,4) . "'";
|
$enabled[] = "'" . substr($key,4) . "'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "DELETE FROM applications WHERE device_id=" . $device['device_id'];
|
$sql = "DELETE FROM applications WHERE device_id=" . $device['device_id'];
|
||||||
if ($enabled)
|
if ($enabled)
|
||||||
{
|
{
|
||||||
@@ -33,7 +33,7 @@ if ($_POST['device'])
|
|||||||
}
|
}
|
||||||
mysql_query($sql);
|
mysql_query($sql);
|
||||||
$updated += mysql_affected_rows();
|
$updated += mysql_affected_rows();
|
||||||
|
|
||||||
$sql = "SELECT app_type FROM applications WHERE device_id=" . $device['device_id'];
|
$sql = "SELECT app_type FROM applications WHERE device_id=" . $device['device_id'];
|
||||||
$result = mysql_query($sql);
|
$result = mysql_query($sql);
|
||||||
while ($row = mysql_fetch_assoc($result))
|
while ($row = mysql_fetch_assoc($result))
|
||||||
|
|||||||
@@ -90,7 +90,8 @@ print_optionbar_start(62);
|
|||||||
<option value="">All Locations</option>
|
<option value="">All Locations</option>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if($_SESSION['userlevel'] >= '5') {
|
if($_SESSION['userlevel'] >= '5')
|
||||||
|
{
|
||||||
$query = mysql_query("SELECT location FROM devices WHERE 1 $where GROUP BY location ORDER BY location");
|
$query = mysql_query("SELECT location FROM devices WHERE 1 $where GROUP BY location ORDER BY location");
|
||||||
} else {
|
} 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");
|
$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");
|
||||||
|
|||||||
@@ -14,37 +14,43 @@ if ($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php");
|
|||||||
|
|
||||||
if ($_GET['action'] == "deldevperm")
|
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'] . "'");
|
mysql_query("DELETE FROM devices_perms WHERE `device_id` = '" . $_GET['device_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($_GET['action'] == "adddevperm")
|
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'] . "')");
|
mysql_query("INSERT INTO devices_perms (`device_id`, `user_id`) VALUES ('" . $_GET['device_id'] . "', '" . $_GET['user_id'] . "')");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($_GET['action'] == "delifperm")
|
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'] . "'");
|
mysql_query("DELETE FROM ports_perms WHERE `interface_id` = '" . $_GET['interface_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($_GET['action'] == "addifperm")
|
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'] . "')");
|
mysql_query("INSERT INTO ports_perms (`interface_id`, `user_id`) VALUES ('" . $_GET['interface_id'] . "', '" . $_GET['user_id'] . "')");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($_GET['action'] == "delbillperm")
|
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'] . "'");
|
mysql_query("DELETE FROM bill_perms WHERE `bill_id` = '" . $_GET['bill_id'] . "' AND `user_id` = '" . $_GET['user_id'] . "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($_GET['action'] == "addbillperm")
|
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'] . "')");
|
mysql_query("INSERT INTO bill_perms (`bill_id`, `user_id`) VALUES ('" . $_GET['bill_id'] . "', '" . $_GET['user_id'] . "')");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ if (!$os)
|
|||||||
if (preg_match("/^VMware ESX/", $sysDescr)) { $os = "vmware"; }
|
if (preg_match("/^VMware ESX/", $sysDescr)) { $os = "vmware"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -13,17 +13,21 @@ $ports = str_replace("ifDescr.", "", $ports);
|
|||||||
$interface_ignored = 0;
|
$interface_ignored = 0;
|
||||||
$interface_added = 0;
|
$interface_added = 0;
|
||||||
|
|
||||||
foreach (explode("\n", $ports) as $entry){
|
foreach (explode("\n", $ports) as $entry)
|
||||||
|
{
|
||||||
$entry = trim($entry);
|
$entry = trim($entry);
|
||||||
list($ifIndex, $ifDescr) = explode(" ", $entry, 2);
|
list($ifIndex, $ifDescr) = explode(" ", $entry, 2);
|
||||||
if (!strstr($entry, "irtual")) {
|
if (!strstr($entry, "irtual"))
|
||||||
|
{
|
||||||
$if = trim(strtolower($ifDescr));
|
$if = trim(strtolower($ifDescr));
|
||||||
$nullintf = 0;
|
$nullintf = 0;
|
||||||
foreach ($config['bad_if'] as $bi) { if (strstr($if, $bi)) { $nullintf = 1; } }
|
foreach ($config['bad_if'] as $bi) { if (strstr($if, $bi)) { $nullintf = 1; } }
|
||||||
if (is_array($config['bad_if_regexp'])) {
|
if (is_array($config['bad_if_regexp']))
|
||||||
foreach ($config['bad_if_regexp'] as $bi) {
|
{
|
||||||
if (preg_match($bi ."i", $if)) {
|
foreach ($config['bad_if_regexp'] as $bi)
|
||||||
|
{
|
||||||
|
if (preg_match($bi ."i", $if))
|
||||||
|
{
|
||||||
$nullintf = 1;
|
$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]; }
|
if ($device['os'] == "vmware" && preg_match("/Device ([a-z0-9]+) at .*/", $ifDescr, $matches)) { $ifDescr = $matches[1]; }
|
||||||
$ifDescr = fixifName($ifDescr);
|
$ifDescr = fixifName($ifDescr);
|
||||||
if (preg_match('/serial[0-9]:/', $if)) { $nullintf = 1; }
|
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 (preg_match('/ng[0-9]+$/', $if)) { $nullintf = 1; }
|
||||||
}
|
}
|
||||||
if ($debug) echo("\n $if ");
|
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') {
|
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)."')");
|
mysql_query("INSERT INTO `ports` (`device_id`,`ifIndex`,`ifDescr`) VALUES ('".$device['device_id']."','$ifIndex','".mres($ifDescr)."')");
|
||||||
# Add Interface
|
# 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'";
|
$sql = "SELECT * FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `deleted` = '0'";
|
||||||
$query = mysql_query($sql);
|
$query = mysql_query($sql);
|
||||||
|
|
||||||
while ($test_if = mysql_fetch_array($query)) {
|
while ($test_if = mysql_fetch_array($query))
|
||||||
|
{
|
||||||
unset($exists);
|
unset($exists);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < count($int_exists) && !isset($exists)) {
|
while ($i < count($int_exists) && !isset($exists))
|
||||||
|
{
|
||||||
$this_if = $test_if['ifIndex'];
|
$this_if = $test_if['ifIndex'];
|
||||||
if ($int_exists[$i] == $this_if) { $exists = 1; }
|
if ($int_exists[$i] == $this_if) { $exists = 1; }
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
if (!$exists) {
|
if (!$exists)
|
||||||
|
{
|
||||||
echo("-");
|
echo("-");
|
||||||
mysql_query("UPDATE `ports` SET `deleted` = '1' WHERE interface_id = '" . $test_if['interface_id'] . "'");
|
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);
|
unset($temp_exists);
|
||||||
echo("\n");
|
echo("\n");
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -3,8 +3,6 @@
|
|||||||
global $valid_processor;
|
global $valid_processor;
|
||||||
|
|
||||||
## Hardcoded discovery of device CPU usage on Alcatel-Lucent Omniswitches.
|
## Hardcoded discovery of device CPU usage on Alcatel-Lucent Omniswitches.
|
||||||
##
|
|
||||||
|
|
||||||
|
|
||||||
if ($device['os'] == "aos")
|
if ($device['os'] == "aos")
|
||||||
{
|
{
|
||||||
@@ -21,4 +19,4 @@ if ($device['os'] == "aos")
|
|||||||
|
|
||||||
unset ($processors_array);
|
unset ($processors_array);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -26,22 +26,22 @@ if ($device['os'] == "cometsystem-p85xx")
|
|||||||
preg_match($regexp, $line, $match);
|
preg_match($regexp, $line, $match);
|
||||||
if ($match['name'])
|
if ($match['name'])
|
||||||
{
|
{
|
||||||
$out[$match['id']]['name'] = $match['name'];
|
$out[$match['id']]['name'] = $match['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($match['temp_intval'])
|
if ($match['temp_intval'])
|
||||||
{
|
{
|
||||||
$out[$match['id']]['temp_intval'] = $match['temp_intval'];
|
$out[$match['id']]['temp_intval'] = $match['temp_intval'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($match['limit_high'])
|
if ($match['limit_high'])
|
||||||
{
|
{
|
||||||
$out[$match['id']]['limit_high'] = $match['limit_high'];
|
$out[$match['id']]['limit_high'] = $match['limit_high'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($match['limit_low'])
|
if ($match['limit_low'])
|
||||||
{
|
{
|
||||||
$out[$match['id']]['limit_low'] = $match['limit_low'];
|
$out[$match['id']]['limit_low'] = $match['limit_low'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,115 +4,108 @@
|
|||||||
* Try to discover any Virtual Machines.
|
* 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.
|
* Fetch the Virtual Machine information.
|
||||||
*/
|
|
||||||
|
|
||||||
$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::vmwVmDisplayName.224 = STRING: My First VM
|
||||||
* VMWARE-VMINFO-MIB::vmwVmVMID.416 = INTEGER: 416
|
* 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");
|
$vmwVmDisplayName = snmp_get($device, "VMWARE-VMINFO-MIB::vmwVmDisplayName." . $oid, "-Osqnv", "+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB", "+" . $config["install_dir"] . "/mibs/vmware");
|
||||||
$oids = explode("\n", $oids);
|
$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");
|
||||||
foreach ($oids as $oid) {
|
$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");
|
||||||
|
|
||||||
/*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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"] . "'");
|
if (preg_match("/^([0-9]+) .*$/", $vmwVmMemSize, $matches))
|
||||||
|
{
|
||||||
while ($db_vm = mysql_fetch_array($db_vm_list)) {
|
$vmwVmMemSize = $matches[1];
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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.
|
* 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
+10
-10
@@ -92,7 +92,7 @@ function shorthost($hostname, $len=16)
|
|||||||
{
|
{
|
||||||
$parts = explode(".", $hostname);
|
$parts = explode(".", $hostname);
|
||||||
$shorthost = $parts[0];
|
$shorthost = $parts[0];
|
||||||
$i=1;
|
$i = 1;
|
||||||
while ($i < count($parts) && strlen($shorthost.'.'.$parts[$i]) < $len)
|
while ($i < count($parts) && strlen($shorthost.'.'.$parts[$i]) < $len)
|
||||||
{
|
{
|
||||||
$shorthost = $shorthost.'.'.$parts[$i];
|
$shorthost = $shorthost.'.'.$parts[$i];
|
||||||
@@ -150,14 +150,14 @@ function format_si($rate)
|
|||||||
$sizes = Array('', 'k', 'M', 'G', 'T', 'P', 'E');
|
$sizes = Array('', 'k', 'M', 'G', 'T', 'P', 'E');
|
||||||
$round = Array('2','2','2','2','2','2','2','2','2');
|
$round = Array('2','2','2','2','2','2','2','2','2');
|
||||||
$ext = $sizes[0];
|
$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
|
else
|
||||||
{
|
{
|
||||||
$sizes = Array('', 'm', 'u', 'n');
|
$sizes = Array('', 'm', 'u', 'n');
|
||||||
$round = Array('2','2','2','2');
|
$round = Array('2','2','2','2');
|
||||||
$ext = $sizes[0];
|
$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;
|
return round($rate, $round[$i]).$ext;
|
||||||
@@ -167,7 +167,7 @@ function format_bi($size, $round = '2')
|
|||||||
{
|
{
|
||||||
$sizes = Array('', 'k', 'M', 'G', 'T', 'P', 'E');
|
$sizes = Array('', 'k', 'M', 'G', 'T', 'P', 'E');
|
||||||
$ext = $sizes[0];
|
$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;
|
return round($size, $round).$ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,7 +256,7 @@ function delete_port($int_id)
|
|||||||
function delete_device($id)
|
function delete_device($id)
|
||||||
{
|
{
|
||||||
global $config;
|
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);
|
||||||
mysql_query("DELETE FROM `devices` WHERE `device_id` = '$id'");
|
mysql_query("DELETE FROM `devices` WHERE `device_id` = '$id'");
|
||||||
$int_query = mysql_query("SELECT * FROM `ports` 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);
|
delete_port($int_id);
|
||||||
$ret .= "Removed interface $int_id ($int_if)\n";
|
$ret .= "Removed interface $int_id ($int_if)\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
mysql_query("DELETE FROM `entPhysical` WHERE `device_id` = '$id'");
|
mysql_query("DELETE FROM `entPhysical` WHERE `device_id` = '$id'");
|
||||||
mysql_query("DELETE FROM `devices_attribs` WHERE `device_id` = '$id'");
|
mysql_query("DELETE FROM `devices_attribs` WHERE `device_id` = '$id'");
|
||||||
mysql_query("DELETE FROM `devices_perms` 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 `current` WHERE `device_id` = '$id'");
|
||||||
mysql_query("DELETE FROM `sensors` WHERE `device_id` = '$id'");
|
mysql_query("DELETE FROM `sensors` WHERE `device_id` = '$id'");
|
||||||
shell_exec("rm -rf ".trim($config['rrd_dir'])."/$host");
|
shell_exec("rm -rf ".trim($config['rrd_dir'])."/$host");
|
||||||
|
|
||||||
$ret = "Removed Device $host\n";
|
$ret = "Removed Device $host\n";
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
@@ -294,7 +294,7 @@ function delete_device($id)
|
|||||||
function addHost($host, $community, $snmpver, $port = 161, $transport = 'udp')
|
function addHost($host, $community, $snmpver, $port = 161, $transport = 'udp')
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
list($hostshort) = explode(".", $host);
|
list($hostshort) = explode(".", $host);
|
||||||
if (isDomainResolves($host))
|
if (isDomainResolves($host))
|
||||||
{
|
{
|
||||||
@@ -746,7 +746,7 @@ function hex2str($hex)
|
|||||||
{
|
{
|
||||||
$string='';
|
$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]));
|
$string .= chr(hexdec($hex[$i].$hex[$i+1]));
|
||||||
}
|
}
|
||||||
@@ -790,4 +790,4 @@ function include_dir($dir, $regex = "")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -3,100 +3,97 @@
|
|||||||
/*
|
/*
|
||||||
* Fetch the VMware product version.
|
* Fetch the VMware product version.
|
||||||
*
|
*
|
||||||
* VMWARE-SYSTEM-MIB::vmwProdName.0 = STRING: VMware ESXi
|
* VMWARE-SYSTEM-MIB::vmwProdName.0 = STRING: VMware ESXi
|
||||||
* VMWARE-SYSTEM-MIB::vmwProdVersion.0 = STRING: 4.1.0
|
* VMWARE-SYSTEM-MIB::vmwProdVersion.0 = STRING: 4.1.0
|
||||||
* VMWARE-SYSTEM-MIB::vmwProdBuild.0 = STRING: 348481
|
* VMWARE-SYSTEM-MIB::vmwProdBuild.0 = STRING: 348481
|
||||||
*
|
*
|
||||||
* version: ESXi 4.1.0
|
* version: ESXi 4.1.0
|
||||||
* features: build-348481
|
* 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"];
|
$version = preg_replace("/^VMware /", "", $data[0]["vmwProdName"]) . " " . $data[0]["vmwProdVersion"];
|
||||||
$features = "build-" . $data[0]["vmwProdBuild"];
|
$features = "build-" . $data[0]["vmwProdBuild"];
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* VMware ESXi returns "not set" instead of a NULL value.
|
* VMware ESXi returns "not set" instead of a NULL value.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($sysLocation == "not set") {
|
if ($sysLocation == "not set")
|
||||||
$sysLocation = "";
|
{
|
||||||
|
$sysLocation = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sysContact == "not set") {
|
if ($sysContact == "not set")
|
||||||
$sysContact = "";
|
{
|
||||||
|
$sysContact = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CONSOLE: Start the VMware discovery process.
|
* CONSOLE: Start the VMware discovery process.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
echo("VMware VM: ");
|
echo("VMware VM: ");
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get a list of all the known Virtual Machines for this host.
|
* 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"] . "'");
|
$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)) {
|
while ($db_info = mysql_fetch_array($db_info_list))
|
||||||
|
{
|
||||||
|
/*
|
||||||
/*
|
* Fetch the Virtual Machine information.
|
||||||
* Fetch the Virtual Machine information.
|
*
|
||||||
*
|
* VMWARE-VMINFO-MIB::vmwVmDisplayName.224 = STRING: My First VM
|
||||||
* VMWARE-VMINFO-MIB::vmwVmDisplayName.224 = STRING: My First VM
|
* VMWARE-VMINFO-MIB::vmwVmGuestOS.224 = STRING: windows7Server64Guest
|
||||||
* VMWARE-VMINFO-MIB::vmwVmGuestOS.224 = STRING: windows7Server64Guest
|
* VMWARE-VMINFO-MIB::vmwVmMemSize.224 = INTEGER: 8192 megabytes
|
||||||
* VMWARE-VMINFO-MIB::vmwVmMemSize.224 = INTEGER: 8192 megabytes
|
* VMWARE-VMINFO-MIB::vmwVmState.224 = STRING: poweredOn
|
||||||
* VMWARE-VMINFO-MIB::vmwVmState.224 = STRING: poweredOn
|
* VMWARE-VMINFO-MIB::vmwVmVMID.224 = INTEGER: 224
|
||||||
* VMWARE-VMINFO-MIB::vmwVmVMID.224 = INTEGER: 224
|
* VMWARE-VMINFO-MIB::vmwVmCpus.224 = INTEGER: 2
|
||||||
* 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']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
$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.
|
* Finished discovering VMware information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
echo("\n");
|
echo("\n");
|
||||||
|
|
||||||
?>
|
?>
|
||||||
Reference in New Issue
Block a user