mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Foob
git-svn-id: http://www.observium.org/svn/observer/trunk@98 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -42,7 +42,7 @@ while ($device = mysql_fetch_array($device_query)) {
|
||||
$ip = gethostbyname($dst_host);
|
||||
if ( match_network($nets, $ip) ) {
|
||||
if ( mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `hostname` = '$dst_host'"), 0) == '0' ) {
|
||||
createHost ($dst_host);
|
||||
createHost ($dst_host, $community, "v2c");
|
||||
} else {
|
||||
#echo("Already got host $dst_host\n");
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@
|
||||
include("config.php");
|
||||
include("includes/functions.php");
|
||||
|
||||
$device_query = mysql_query("SELECT * FROM `devices` WHERE os = 'Linux' OR os = 'FreeBSD' OR os = 'NetBSD' OR os = 'OpenBSD' OR os = 'DragonFly' AND monowall = '0' AND status = '1'");
|
||||
$device_query = mysql_query("SELECT * FROM `devices` WHERE os = 'Linux' OR os = 'FreeBSD' OR os = 'NetBSD' OR os = 'OpenBSD' OR os = 'DragonFly' AND status = '1'");
|
||||
while ($device = mysql_fetch_array($device_query)) {
|
||||
$id = $device['id'];
|
||||
$id = $device['device_id'];
|
||||
$hostname = $device['hostname'];
|
||||
$community = $device['community'];
|
||||
echo("\n***$hostname***\n");
|
||||
@@ -13,19 +13,46 @@ while ($device = mysql_fetch_array($device_query)) {
|
||||
$oids = trim($oids);
|
||||
foreach(explode("\n", $oids) as $data) {
|
||||
$data = trim($data);
|
||||
list($oid,$ifIndex) = explode(" ", $data);
|
||||
list($oid,$hrStorageIndex) = explode(" ", $data);
|
||||
$temp = `snmpget -O qv -v2c -c $community $hostname hrStorageDescr.$oid hrStorageAllocationUnits.$oid hrStorageSize.$oid hrStorageType.$oid`;
|
||||
$temp = trim($temp);
|
||||
list($descr, $units, $size, $type) = explode("\n", $temp);
|
||||
list($units) = explode(" ", $units);
|
||||
if(strstr($type, "FixedDisk") && $size > '0') {
|
||||
echo("$oid,$descr,$units,$size\n");
|
||||
if(mysql_result(mysql_query("SELECT count(storage_id) FROM `storage` WHERE hrStorageIndex = '$ifIndex' AND host_id = '$id'"),0) == '0') {
|
||||
$query = "INSERT INTO storage (`host_id`, `hrStorageIndex`, `hrStorageDescr`,`hrStorageSize`,`hrStorageAllocationUnits`) values ('$id', '$ifIndex', '$descr', '$size', '$units')";
|
||||
if(mysql_result(mysql_query("SELECT count(storage_id) FROM `storage` WHERE hrStorageIndex = '$hrStorageIndex' AND host_id = '$id'"),0) == '0') {
|
||||
$query = "INSERT INTO storage (`host_id`, `hrStorageIndex`, `hrStorageDescr`,`hrStorageSize`,`hrStorageAllocationUnits`) values ('$id', '$hrStorageIndex', '$descr', '$size', '$units')";
|
||||
echo("$query \n");
|
||||
mysql_query($query);
|
||||
}
|
||||
$storage_exists[] = "$id $hrStorageIndex";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM storage";
|
||||
$query = mysql_query($sql);
|
||||
|
||||
while ($store = mysql_fetch_array($query)) {
|
||||
|
||||
unset($exists);
|
||||
|
||||
$i = 0;
|
||||
while ($i < count($storage_exists) && !$exists) {
|
||||
$thisstore = $store['host_id'] . " " . $store['hrStorageIndex'];
|
||||
if ($storage_exists[$i] == $thisstore) { $exists = 1; echo("Match!"); }
|
||||
$i++;
|
||||
echo("$storage_exists[$i] == $thisstore \n");
|
||||
}
|
||||
|
||||
if(!$exists) {
|
||||
echo("Deleting...\n");
|
||||
# mysql_query("DELETE FROM storage WHERE storage_id = '" . $store['storage_id'] . "'");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
@@ -4,17 +4,16 @@ include("config.php");
|
||||
include("includes/functions.php");
|
||||
|
||||
|
||||
### Discovery Observer-style temperature sensors
|
||||
### Discovery Observer-style NetSNMP temperatures
|
||||
|
||||
$device_query = mysql_query("SELECT * FROM `devices` WHERE status = '1' AND os != 'IOS' AND os != 'ProCurve'");
|
||||
while ($device = mysql_fetch_array($device_query)) {
|
||||
$id = $device['id'];
|
||||
$id = $device['device_id'];
|
||||
$hostname = $device['hostname'];
|
||||
$community = $device['community'];
|
||||
$snmpver = $device['snmpver'];
|
||||
echo("\n***$hostname***\n");
|
||||
$oids = `snmpwalk -$snmpver -Osqn -c $community $hostname .1.3.6.1.4.1.2021.7891 | sed s/.1.3.6.1.4.1.2021.7891.// | grep ".1.1 " | grep -v ".101." | cut -d"." -f 1`;
|
||||
#$oids = `snmpwalk -v2c -Osqn -c $community $hostname .1.3.6.1.4.1.2021.7891 | sed s/.1.3.6.1.4.1.2021.7891.// | grep '1.1.1' | grep -v 0 | cut -d " " -f 2`;
|
||||
$oids = trim($oids);
|
||||
if(strstr($oids, "no")) { unset ($oids); }
|
||||
foreach(explode("\n",$oids) as $oid) {
|
||||
@@ -26,9 +25,63 @@ while ($device = mysql_fetch_array($device_query)) {
|
||||
if(!mysql_result(mysql_query("SELECT count(temp_id) FROM temperature WHERE `temp_host` = '$id' AND `temp_oid` = '$fulloid'"), 0)) {
|
||||
mysql_query("INSERT INTO `temperature` (`temp_host`,`temp_oid`,`temp_descr`) VALUES ('$id', '$fulloid', '$descr');");
|
||||
echo("Created $fulloid on $hostname\n");
|
||||
}
|
||||
} else { $temp_exists[] = "$id $fulloid"; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Discover Dell temperatures
|
||||
|
||||
$device_query = mysql_query("SELECT * FROM `devices` WHERE status = '1' AND hardware like 'Dell %'");
|
||||
while ($device = mysql_fetch_array($device_query)) {
|
||||
$id = $device['device_id'];
|
||||
$hostname = $device['hostname'];
|
||||
$community = $device['community'];
|
||||
$snmpver = $device['snmpver'];
|
||||
echo("\n***$hostname***\n");
|
||||
$oids = `snmpwalk -$snmpver -Osqn -c $community $hostname .1.3.6.1.4.1.674.10892.1.700.20.1.8`;
|
||||
$oids = trim($oids);
|
||||
if(strstr($oids, "no")) { unset ($oids); }
|
||||
foreach(explode("\n",$oids) as $oid) {
|
||||
$oid = substr(trim($oid), 36);
|
||||
echo("$oid \n");
|
||||
list($oid) = explode(" ", $oid);
|
||||
if($oid != "") {
|
||||
$descr = trim(str_replace("\"", "", `snmpget -v2c -Onvq -c $community $hostname .1.3.6.1.4.1.674.10892.1.700.20.1.8.$oid`));
|
||||
$fulloid = ".1.3.6.1.4.1.674.10892.1.700.20.1.6.$oid";
|
||||
echo("Detected : $fulloid ($descr)\n");
|
||||
if(!mysql_result(mysql_query("SELECT count(temp_id) FROM temperature WHERE `temp_host` = '$id' AND `temp_oid` = '$fulloid'"), 0)) {
|
||||
mysql_query("INSERT INTO `temperature` (`temp_host`,`temp_oid`,`temp_descr`, `temp_tenths`) VALUES ('$id', '$fulloid', '$descr', '1');");
|
||||
echo("Created $fulloid on $hostname\n");
|
||||
}
|
||||
$temp_exists[] = "$id $fulloid";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM temperature";
|
||||
$query = mysql_query($sql);
|
||||
|
||||
while ($sensor = mysql_fetch_array($query)) {
|
||||
|
||||
unset($exists);
|
||||
|
||||
$i = 0;
|
||||
while ($i < count($temp_exists) && !$exists) {
|
||||
$thistemp = $sensor['temp_host'] . " " . $sensor['temp_oid'];
|
||||
if ($temp_exists[$i] == $thistemp) { $exists = 1; echo("Match!"); }
|
||||
$i++;
|
||||
echo("$temp_exists[$i] == $thistemp \n");
|
||||
}
|
||||
|
||||
if(!$exists) {
|
||||
echo("Deleting...\n");
|
||||
# mysql_query("DELETE FROM temperature WHERE temp_id = '" . $sensor['temp_id'] . "'");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
@@ -1,16 +1,16 @@
|
||||
<?php
|
||||
|
||||
$daily_traffic = "graph.php?if=$iid&type=$graph_type&from=$day&to=$now&width=217&height=100";
|
||||
$daily_url = "graph.php?if=$iid&type=$graph_type&from=$day&to=$now&width=400&height=150";
|
||||
$daily_traffic = "graph.php?if=$iid&type=$graph_type&from=$day&to=$now&width=333&height=100";
|
||||
$daily_url = "graph.php?if=$iid&type=$graph_type&from=$day&to=$now&width=550&height=175";
|
||||
|
||||
$weekly_traffic = "graph.php?if=$iid&type=$graph_type&from=$week&to=$now&width=217&height=100";
|
||||
$weekly_url = "graph.php?if=$iid&type=$graph_type&from=$week&to=$now&width=400&height=150";
|
||||
$weekly_traffic = "graph.php?if=$iid&type=$graph_type&from=$week&to=$now&width=333&height=100";
|
||||
$weekly_url = "graph.php?if=$iid&type=$graph_type&from=$week&to=$now&width=550&height=175";
|
||||
|
||||
$monthly_traffic = "graph.php?if=$iid&type=$graph_type&from=$month&to=$now&width=217&height=100";
|
||||
$monthly_url = "graph.php?if=$iid&type=$graph_type&from=$month&to=$now&width=400&height=150";
|
||||
$monthly_traffic = "graph.php?if=$iid&type=$graph_type&from=$month&to=$now&width=333&height=100";
|
||||
$monthly_url = "graph.php?if=$iid&type=$graph_type&from=$month&to=$now&width=550&height=175";
|
||||
|
||||
$yearly_traffic = "graph.php?if=$iid&type=$graph_type&from=$year&to=$now&width=217&height=100";
|
||||
$yearly_url = "graph.php?if=$iid&type=$graph_type&from=$year&to=$now&width=400&height=150";
|
||||
$yearly_traffic = "graph.php?if=$iid&type=$graph_type&from=$year&to=$now&width=333&height=100";
|
||||
$yearly_url = "graph.php?if=$iid&type=$graph_type&from=$year&to=$now&width=550&height=175";
|
||||
|
||||
echo("<a href='?page=interface&id=$iid' onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
|
||||
<img src='$daily_traffic' border=0></a> ");
|
||||
|
@@ -15,16 +15,16 @@ if($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; }
|
||||
echo("<tr style=\"background-color: $bg\">
|
||||
<td width=0></td>
|
||||
<td class=syslog width=150>
|
||||
$entry[datetime]
|
||||
" . $entry['datetime'] . "
|
||||
</td>
|
||||
<td class=list-bold width=75>
|
||||
$entry[priority]
|
||||
" . $entry['priority'] . "
|
||||
</td>
|
||||
<td class=syslog width=175>
|
||||
$entry[program]
|
||||
" . $entry['program'] . "
|
||||
</td>
|
||||
<td class=syslog>
|
||||
$entry[msg]
|
||||
" . htmlspecialchars($entry['msg']) . "
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>");
|
||||
|
@@ -30,7 +30,7 @@ if(@mysql_result(mysql_query("select count(vlan_id) from vlans WHERE device_id =
|
||||
echo("
|
||||
<li class=$select[devvlans]>
|
||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-vlans' >
|
||||
<img src='images/16/rainbow.png' align=absmiddle border=0> VLANs
|
||||
<img src='images/16/vlans.png' align=absmiddle border=0> VLANs
|
||||
</a>
|
||||
</li>");
|
||||
}
|
||||
@@ -39,7 +39,7 @@ if(@mysql_result(mysql_query("select count(interface_id) from interfaces WHERE d
|
||||
echo("
|
||||
<li class=$select[devifs]>
|
||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-ifs' >
|
||||
<img src='images/16/link.png' align=absmiddle border=0> Port Details
|
||||
<img src='images/16/server_link.png' align=absmiddle border=0> Port Details
|
||||
</a>
|
||||
</li>
|
||||
<li class=$select[devifgraphs]>
|
||||
@@ -60,7 +60,7 @@ if(mysql_result(mysql_query("select count(service_id) from services WHERE servic
|
||||
echo("
|
||||
<li class=$select[devsrv]>
|
||||
<a href='?page=device&id=" . $device['device_id'] . "§ion=dev-srv'>
|
||||
<img src='images/16/cog.png' align=absmiddle border=0> Service Details
|
||||
<img src='images/16/server_cog.png' align=absmiddle border=0> Service Details
|
||||
</a>
|
||||
</li>
|
||||
");
|
||||
|
@@ -6,15 +6,15 @@ $id = $_GET[id];
|
||||
|
||||
$device = mysql_fetch_array(mysql_query("SELECT * FROM `devices` WHERE `device_id` = '$_GET[id]'"));
|
||||
|
||||
$interfaces['total'] = mysql_result(mysql_query("SELECT count(*) FROM interfaces WHERE device_id = '$id'"),0);
|
||||
$interfaces['up'] = mysql_result(mysql_query("SELECT count(*) FROM interfaces WHERE device_id = '$id' AND ifOperStatus = 'up'"),0);
|
||||
$interfaces['down'] = mysql_result(mysql_query("SELECT count(*) FROM interfaces WHERE device_id = '$id' AND ifOperStatus = 'down' AND ifAdminStatus = 'up'"),0);
|
||||
$interfaces['disabled'] = mysql_result(mysql_query("SELECT count(*) FROM interfaces WHERE device_id = '$id' AND ifAdminStatus = 'down'"),0);
|
||||
$interfaces['total'] = mysql_result(mysql_query("SELECT count(*) FROM interfaces WHERE device_id = '" . $device['device_id'] . "'"),0);
|
||||
$interfaces['up'] = mysql_result(mysql_query("SELECT count(*) FROM interfaces WHERE device_id = '" . $device['device_id'] . "' AND ifOperStatus = 'up'"),0);
|
||||
$interfaces['down'] = mysql_result(mysql_query("SELECT count(*) FROM interfaces WHERE device_id = '" . $device['device_id'] . "' AND ifOperStatus = 'down' AND ifAdminStatus = 'up'"),0);
|
||||
$interfaces['disabled'] = mysql_result(mysql_query("SELECT count(*) FROM interfaces WHERE device_id = '" . $device['device_id'] . "' AND ifAdminStatus = 'down'"),0);
|
||||
|
||||
$services['total'] = mysql_result(mysql_query("SELECT count(service_id) FROM services WHERE service_host = '$id'"),0);
|
||||
$services['up'] = mysql_result(mysql_query("SELECT count(service_id) FROM services WHERE service_host = '$id' AND service_status = '1' AND service_ignore ='0'"),0);
|
||||
$services['down'] = mysql_result(mysql_query("SELECT count(service_id) FROM services WHERE service_host = '$id' AND service_status = '0' AND service_ignore = '0'"),0);
|
||||
$services['disabled'] = mysql_result(mysql_query("SELECT count(service_id) FROM services WHERE service_host = '$id' AND service_ignore = '1'"),0);
|
||||
$services['total'] = mysql_result(mysql_query("SELECT count(service_id) FROM services WHERE service_host = '" . $device['device_id'] . "'"),0);
|
||||
$services['up'] = mysql_result(mysql_query("SELECT count(service_id) FROM services WHERE service_host = '" . $device['device_id'] . "' AND service_status = '1' AND service_ignore ='0'"),0);
|
||||
$services['down'] = mysql_result(mysql_query("SELECT count(service_id) FROM services WHERE service_host = '" . $device['device_id'] . "' AND service_status = '0' AND service_ignore = '0'"),0);
|
||||
$services['disabled'] = mysql_result(mysql_query("SELECT count(service_id) FROM services WHERE service_host = '" . $device['device_id'] . "' AND service_ignore = '1'"),0);
|
||||
|
||||
if($services['down']) { $services_colour = $warn_colour_a; } else { $services_colour = $list_colour_a; }
|
||||
if($interfaces['down']) { $interfaces_colour = $warn_colour_a; } else { $interfaces_colour = $list_colour_a; }
|
||||
@@ -32,13 +32,69 @@ if(file_exists("includes/dev-data-" . strtolower($device[os]) . ".inc")) {
|
||||
}
|
||||
|
||||
|
||||
if(mysql_result(mysql_query("SELECT count(storage_id) from storage WHERE host_id = '" . $device['device_id'] . "'"),0)) {
|
||||
echo("<div style='background-color: #eeeeee; margin: 5px; padding: 5px;'>");
|
||||
echo("<p class=sectionhead>Storage</p>");
|
||||
echo("<table width=100%>");
|
||||
$i = '1';
|
||||
echo("<tr class=tablehead><td>Mountpoint</td><td width=203>Usage</td><td width=40>%</td><td width=75>Total</td>
|
||||
<td width=75>Used</td></tr>");
|
||||
$drives = mysql_query("SELECT * FROM `storage` WHERE host_id = '" . $device['device_id'] . "'");
|
||||
while($drive = mysql_fetch_array($drives)) {
|
||||
$total = $drive['hrStorageSize'] * $drive['hrStorageAllocationUnits'];
|
||||
$used = $drive['hrStorageUsed'] * $drive['hrStorageAllocationUnits'];
|
||||
$perc = $drive['storage_perc'];
|
||||
$total = formatStorage($total);
|
||||
$used = formatStorage($used);
|
||||
if($perc > '80') { $drv_class='red'; } else { $drvclass=''; }
|
||||
echo("<tr><td class=tablehead>" . $drive['hrStorageDescr'] . "</td><td><img src='percentage.php?per=" . $perc . "'>
|
||||
</td><td>" . $perc . "%</td><td>" . $total . "</td><td>" . $used . "</td></tr>");
|
||||
$i++;
|
||||
}
|
||||
echo("</table>");
|
||||
echo("</div>");
|
||||
}
|
||||
|
||||
unset($temp_seperator);
|
||||
if(mysql_result(mysql_query("SELECT count(temp_id) from temperature WHERE temp_host = '" . $device['device_id'] . "'"),0)) {
|
||||
$total = mysql_result(mysql_query("SELECT count(temp_id) from temperature WHERE temp_host = '" . $device['device_id'] . "'"),0);
|
||||
$rows = round($total / 2,0);
|
||||
echo("<div style='background-color: #eeeeee; margin: 5px; padding: 5px;'>");
|
||||
echo("<p class=sectionhead>Temperatures</p>");
|
||||
$i = '1';
|
||||
$temps = mysql_query("SELECT * FROM temperature WHERE temp_host = '" . $device['device_id'] . "'");
|
||||
echo("<table width=100% valign=top>");
|
||||
echo("<tr><td width=50%>");
|
||||
echo("<table width=100% cellspacing=0 cellpadding=2>");
|
||||
while($temp = mysql_fetch_array($temps)) {
|
||||
if(is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
|
||||
|
||||
if($temp['temp_current'] < '30') { $temp_class='';
|
||||
} elseif($temp['temp_current'] < '40') { $temp_class='blue';
|
||||
} elseif($temp['temp_current'] < '50') { $temp_class='green';
|
||||
} elseif($temp['temp_current'] < '60') { $temp_class='orange';
|
||||
} else { $temp_class='red'; }
|
||||
|
||||
$temp['temp_descr'] = truncate($temp['temp_descr'], 25, '');
|
||||
echo("<tr bgcolor='$row_colour'><td>" . $temp['temp_descr'] . "</td><td width=40 class=tablehead><span class='$temp_class'>" . $temp['temp_current'] . "°C</span></td></tr>");
|
||||
if($i == $rows) { echo("</table></td><td valign=top><table width=100% cellspacing=0 cellpadding=2>"); }
|
||||
$i++;
|
||||
}
|
||||
echo("</table>");
|
||||
echo("</td></tr>");
|
||||
echo("</table>");
|
||||
echo("</div>");
|
||||
}
|
||||
|
||||
|
||||
|
||||
echo("<div style='background-color: #eeeeee; margin: 5px; padding: 5px;'>");
|
||||
echo("<p class=sectionhead>Recent Events</p>");
|
||||
|
||||
$query = "SELECT *,DATE_FORMAT(datetime, '%d/%b/%y %T') as humandate FROM `eventlog` WHERE `host` = '$_GET[id]' ORDER BY `datetime` DESC LIMIT 0,10";
|
||||
$data = mysql_query($query);
|
||||
|
||||
echo("<p class=sectionhead>Recent Events</p><div style='height: 5px;'></div>
|
||||
<table cellspacing=0 cellpadding=2 width=100%>");
|
||||
echo("<table cellspacing=0 cellpadding=2 width=100%>");
|
||||
|
||||
while($entry = mysql_fetch_array($data)) {
|
||||
|
||||
@@ -69,7 +125,7 @@ echo("
|
||||
|
||||
echo("<div style='margin: 8px; font-size: 11px; font-weight: bold;'>");
|
||||
|
||||
$sql = "SELECT * FROM interfaces WHERE `device_id` = '$id'";
|
||||
$sql = "SELECT * FROM interfaces WHERE `device_id` = '" . $device['device_id'] . "'";
|
||||
$query = mysql_query($sql);
|
||||
while($data = mysql_fetch_array($query)) {
|
||||
echo("$ifsep" . generateiflink($data, makeshortif(strtolower($data['ifDescr']))));
|
||||
@@ -100,7 +156,7 @@ echo("
|
||||
|
||||
echo("<div style='padding: 8px; font-size: 11px; font-weight: bold;'>");
|
||||
|
||||
$sql = "SELECT * FROM services WHERE service_host = '$id' ORDER BY service_type";
|
||||
$sql = "SELECT * FROM services WHERE service_host = '" . $device['device_id'] . "' ORDER BY service_type";
|
||||
$query = mysql_query($sql);
|
||||
while($data = mysql_fetch_array($query)) {
|
||||
if ($data[service_status] == "0" && $data[service_ignore] == "1") { $status = "grey"; }
|
||||
@@ -115,8 +171,6 @@ echo("
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
echo("</td></tr></table>");
|
||||
|
||||
?>
|
||||
|
@@ -1,8 +1,20 @@
|
||||
<?
|
||||
|
||||
$query = "SELECT * FROM `syslog` WHERE `host` = '$_GET[id]' ORDER BY `datetime` DESC LIMIT 0,250";
|
||||
if($search) {
|
||||
$query = "SELECT * FROM `syslog` WHERE `host` = '" . $_GET['id'] . "' AND `msg` LIKE '%" . $_POST['search'] . "%' ORDER BY `seq` desc";
|
||||
} else {
|
||||
$query = "SELECT * FROM `syslog` WHERE `host` = '" . $_GET['id'] . "' ORDER BY `seq` desc LIMIT 0,500";
|
||||
}
|
||||
|
||||
$data = mysql_query($query);
|
||||
|
||||
echo("<div align=right><form id='form1' name='form1' method='post' action='" . $_SERVER['REQUEST_URI'] . "'>
|
||||
<label>
|
||||
<input type='text' name='search' id='search' />
|
||||
<input type='submit' name='button' id='button' value='Search' />
|
||||
</label>
|
||||
</form></div>");
|
||||
|
||||
echo("<table cellspacing=0 cellpadding=2 width=100%>");
|
||||
|
||||
while($entry = mysql_fetch_array($data)) {
|
||||
|
@@ -8,6 +8,16 @@ include("procurve.php");
|
||||
include("snom.php");
|
||||
include("graphing.php");
|
||||
|
||||
function formatStorage($size) {
|
||||
$sizes = Array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB');
|
||||
$ext = $sizes[0];
|
||||
for ($i=1; (($i < count($sizes)) && ($size >= 1024)); $i++) {
|
||||
$size = $size / 1024;
|
||||
$ext = $sizes[$i];
|
||||
}
|
||||
return round($size, 2).$ext;
|
||||
}
|
||||
|
||||
function print_error($text){
|
||||
|
||||
echo("<table class=errorbox cellpadding=3><tr><td><img src='/images/15/exclamation.png' align=absmiddle> $text</td></tr></table>");
|
||||
|
@@ -17,11 +17,11 @@ function temp_graph ($device, $graph, $from, $to, $width, $height, $title, $vert
|
||||
} elseif($iter=="4") {$colour="73880A";} elseif($iter=="5") {$colour="D01F3C";} elseif($iter=="6") {$colour="36393D";
|
||||
} elseif($iter=="7") {$colour="FF0084"; unset($iter); }
|
||||
|
||||
$temperature['temp_descr'] = str_pad($temperature['temp_descr'], 28);
|
||||
$temperature['temp_descr'] = substr($temperature['temp_descr'],0,28);
|
||||
$temperature['temp_descr_fixed'] = str_pad($temperature['temp_descr'], 28);
|
||||
$temperature['temp_descr_fixed'] = substr($temperature['temp_descr_fixed'],0,28);
|
||||
|
||||
$optsa[] = "DEF:temp" . $temperature[temp_id] . "=rrd/" . $hostname . "-temp-" . $temperature['temp_id'] . ".rrd:temp:AVERAGE";
|
||||
$optsa[] = "LINE1:temp" . $temperature[temp_id] . "#" . $colour . ":" . $temperature[temp_descr];
|
||||
$optsa[] = "DEF:temp" . $temperature[temp_id] . "=rrd/" . $hostname . "-temp-" . str_replace(" ", "_", $temperature['temp_descr']) . ".rrd:temp:AVERAGE";
|
||||
$optsa[] = "LINE1:temp" . $temperature[temp_id] . "#" . $colour . ":" . $temperature[temp_descr_fixed];
|
||||
$optsa[] = "GPRINT:temp" . $temperature[temp_id] . ":LAST:%3.0lf<EFBFBD>C";
|
||||
$optsa[] = "GPRINT:temp" . $temperature[temp_id] . ":MAX:%3.0lf<EFBFBD>C\l";
|
||||
$iter++;
|
||||
|
@@ -3,11 +3,6 @@
|
||||
$community = $device['community'];
|
||||
$id = $device['device_id'];
|
||||
$hostname = $device['hostname'];
|
||||
$hardware = $device['hardware'];
|
||||
$version = $device['version'];
|
||||
$features = $device['features'];
|
||||
$location = $device['location'];
|
||||
$os = $device['location'];
|
||||
|
||||
$temprrd = "rrd/" . $hostname . "-temp.rrd";
|
||||
$tempgraph = "public_html/graphs/" . $hostname . "-temp.png";
|
||||
|
@@ -20,9 +20,9 @@ while ($dr = mysql_fetch_array($dq)) {
|
||||
$hrStorageSize = $dr['hrStorageAllocationUnits'] * $dr['hrStorageSize'];
|
||||
$hrStorageDescr = $dr['hrStorageDescr'];
|
||||
$cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " hrStorageUsed.$hrStorageIndex";
|
||||
$used = `$cmd`;
|
||||
$used = $used * $hrStorageAllocationUnits;
|
||||
$perc = $used / $hrStorageSize * 100;
|
||||
$used_units = trim(`$cmd`);
|
||||
$used = $used_units * $hrStorageAllocationUnits;
|
||||
$perc = round($used / $hrStorageSize * 100, 2);
|
||||
|
||||
$filedesc = str_replace("\"", "", str_replace("/", "_", $hrStorageDescr));
|
||||
$storerrd = "rrd/" . $hostname . "-storage-" . $filedesc . ".rrd";
|
||||
@@ -42,6 +42,8 @@ while ($dr = mysql_fetch_array($dq)) {
|
||||
RRA:MAX:0.5:288:800`;
|
||||
}
|
||||
rrd_update($storerrd, "N:$hrStorageSize:$used:$perc");
|
||||
mysql_query("UPDATE `storage` SET `hrStorageUsed` = '$used_units', `storage_perc` = '$perc' WHERE storage_id = '" . $dr['storage_id'] . "'");
|
||||
|
||||
}
|
||||
|
||||
## Set OIDs
|
||||
|
@@ -8,11 +8,9 @@ while($temperature = mysql_fetch_array($temp_data)) {
|
||||
echo($temp_cmd);
|
||||
$temp = `$temp_cmd`;
|
||||
|
||||
$temprrd = "rrd/" . $device[hostname] . "-temp-" . $temperature[temp_id] . ".rrd";
|
||||
$temprrdold = "rrd/" . $device[hostname] . "-temp" . $temperature[temp_id] . ".rrd";
|
||||
if (is_file($temprrdold)) {
|
||||
rename($temprrdold, $temprrd);
|
||||
}
|
||||
|
||||
|
||||
$temprrd = "rrd/" . $device[hostname] . "-temp-" . str_replace(" ", "_",$temperature['temp_descr']) . ".rrd";
|
||||
|
||||
if (!is_file($temprrd)) {
|
||||
`rrdtool create $temprrd \
|
||||
@@ -25,6 +23,7 @@ while($temperature = mysql_fetch_array($temp_data)) {
|
||||
}
|
||||
|
||||
$temp = str_replace("\"", "", $temp);
|
||||
if($temperature['temp_tenths']) { $temp = $temp / 10; }
|
||||
echo("$temprrd, N:$temp");
|
||||
|
||||
`rrdtool update $temprrd N:$temp`;
|
||||
|
@@ -75,25 +75,28 @@ while ($device = mysql_fetch_array($device_query)) {
|
||||
} elseif ($device['os'] == "Linux") {
|
||||
list(,,$version) = explode (" ", $sysDescr);
|
||||
if(strstr($sysDescr, "386")|| strstr($sysDescr, "486")||strstr($sysDescr, "586")||strstr($sysDescr, "686")) { $hardware = "Generic x86"; }
|
||||
# list($version,$features,$featuresb) = explode("-", $version);
|
||||
if(strstr($sysDescr, "x86_64")) { $hardware = "Generic x86_64"; }
|
||||
$cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " .1.3.6.1.4.1.2021.7890.1.101.1";
|
||||
$features = `$cmd`;
|
||||
$features = trim(`$cmd`);
|
||||
$features = str_replace("No Such Object available on this agent at this OID", "", $features);
|
||||
$features = str_replace("\"", "", $features);
|
||||
// Detect Dell hardware via OpenManage SNMP
|
||||
$cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " .1.3.6.1.4.1.674.10892.1.300.10.1.9.1";
|
||||
$hw = trim(str_replace("\"", "", `$cmd`));
|
||||
if(strstr($hw, "No")) { unset($hw); } else { $hardware = "Dell " . $hw; }
|
||||
}
|
||||
|
||||
include("includes/polling/device-unix.inc.php");
|
||||
break;
|
||||
case "Windows":
|
||||
if($device['os'] == "Windows") {
|
||||
if(strstr($sysDescr, "x86")) { $hardware = "Generic x86"; }
|
||||
if(strstr($sysDescr, "Windows Version 5.2")) { $version = "2003 Server"; }
|
||||
if(strstr($sysDescr, "Uniprocessor Free")) { $features = "Uniprocessor"; }
|
||||
if(strstr($sysDescr, "Multiprocessor Free")) { $features = "Multiprocessor"; }
|
||||
}
|
||||
pollDeviceWin();
|
||||
break;
|
||||
|
||||
case "IOS":
|
||||
if ($device['os'] == "IOS") {
|
||||
$version = str_replace("Cisco IOS Software,", "", $sysDescr);
|
||||
$version = str_replace("IOS (tm) ", "", $version);
|
||||
$version = str_replace(",RELEASE SOFTWARE", "", $version);
|
||||
@@ -110,15 +113,13 @@ while ($device = mysql_fetch_array($device_query)) {
|
||||
#$hardware = fixIOSHardware($hardware);
|
||||
$ciscomodel = str_replace("\"", "", $ciscomodel);
|
||||
if(strstr($ciscomodel, "OID")){ unset($ciscomodel); }
|
||||
echo("\n|$ciscomodel|$hardware\n");
|
||||
if(!strstr($ciscomodel, " ") && strlen($ciscomodel) >= '3') {
|
||||
echo("$ciscomodel");
|
||||
$hardware = $ciscomodel;
|
||||
}
|
||||
|
||||
}
|
||||
echo($device['version'] . " $version");
|
||||
include("includes/polling/device-ios.inc.php");
|
||||
break;
|
||||
|
||||
case "ProCurve":
|
||||
$sysDescr = str_replace(", ", ",", $sysDescr);
|
||||
list($hardware, $features, $version) = explode(",", $sysDescr);
|
||||
@@ -147,13 +148,13 @@ while ($device = mysql_fetch_array($device_query)) {
|
||||
unset( $update ) ;
|
||||
|
||||
if ( $sysDescr && $sysDescr != $device['sysDescr'] ) {
|
||||
$update .= "`sysDescr` = '$sysDescr'";
|
||||
$update .= $seperator . "`sysDescr` = '$sysDescr'";
|
||||
$seperator = ", ";
|
||||
mysql_query("INSERT INTO eventlog (host, interface, datetime, message) VALUES ('" . $device['device_id'] . "', NULL, NOW(), 'sysDescr -> $sysDescr')");
|
||||
}
|
||||
|
||||
if ( $location && $device['location'] != $location ) {
|
||||
$update .= "`location` = '$location'";
|
||||
$update .= $seperator . "`location` = '$location'";
|
||||
$seperator = ", ";
|
||||
mysql_query("INSERT INTO eventlog (host, interface, datetime, message) VALUES ('" . $device['device_id'] . "', NULL, NOW(), 'Location -> $location')");
|
||||
}
|
||||
|
@@ -81,6 +81,7 @@ while ($interface = mysql_fetch_array($interface_query)) {
|
||||
}
|
||||
|
||||
if($ifOperStatus == "up") {
|
||||
|
||||
$snmp_data_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'];
|
||||
$snmp_data_cmd .= " ifHCInOctets." . $interface['ifIndex'] . " ifHCOutOctets." . $interface['ifIndex'] . " ifInErrors." . $interface['ifIndex'];
|
||||
$snmp_data_cmd .= " ifOutErrors." . $interface['ifIndex'] . " ifInUcastPkts." . $interface['ifIndex'] . " ifOutUcastPkts." . $interface['ifIndex'];
|
||||
@@ -104,9 +105,32 @@ while ($interface = mysql_fetch_array($interface_query)) {
|
||||
echo("Interface " . $device['hostname'] . " " . $interface['ifDescr'] . " is down\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mysql_query("UPDATE interfaces set ifPhysAddress = '' WHERE ifPhysAddress = 'No Such Instance currently exists at this OID'");
|
||||
if ( $interface['ifAlias'] != $ifAlias ) {
|
||||
$update .= $seperator . "`ifAlias` = '$ifAlias'";
|
||||
$seperator = ", ";
|
||||
mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $interface['device_id'] . "', '" . $interface['interface_id'] . "', NOW(), 'Desc -> $ifAlias')");
|
||||
}
|
||||
if ( $interface['ifOperStatus'] != $ifOperStatus && $ifOperStatus != "" ) {
|
||||
$update .= $seperator . "`ifOperStatus` = '$ifOperStatus'";
|
||||
$seperator = ", ";
|
||||
mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $interface['device_id'] . "', '" . $interface['interface_id'] . "', NOW(), 'Interface went $ifOperStatus')");
|
||||
}
|
||||
if ( $interface['ifAdminStatus'] != $ifAdminStatus && $ifAdminStatus != "" ) {
|
||||
$update .= $seperator . "`ifAdminStatus` = '$ifAdminStatus'";
|
||||
$seperator = ", ";
|
||||
if($ifAdminStatus == "up") { $admin = "enabled"; } else { $admin = "disabled"; }
|
||||
mysql_query("INSERT INTO eventlog (`host`, `interface`, `datetime`, `message`) VALUES ('" . $interface['device_id'] . "', '" . $interface['interface_id'] . "', NOW(), 'Interface $admin')");
|
||||
}
|
||||
if ($update) {
|
||||
$update_query = "UPDATE `interfaces` SET ";
|
||||
$update_query .= $update;
|
||||
$update_query .= " WHERE `interface_id` = '" . $interface['interface_id'] . "'";
|
||||
$update_result = mysql_query($update_query);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
@@ -9,6 +9,9 @@ $discard = 0;
|
||||
$total = 0;
|
||||
|
||||
|
||||
mysql_query("DELETE FROM `logs` WHERE `msg` LIKE '%Connection from UDP: [89.21.224.44]:%'");
|
||||
mysql_query("DELETE FROM `logs` WHERE `msg` LIKE '%Connection from UDP: [89.21.224.35]:%'");
|
||||
|
||||
$q = mysql_query("SELECT * FROM `logs`");
|
||||
while($l = mysql_fetch_array($q)){
|
||||
|
||||
@@ -55,6 +58,5 @@ while($l = mysql_fetch_array($q)){
|
||||
|
||||
}
|
||||
|
||||
echo("$total records processed: $add added to database, $discard discarded");
|
||||
|
||||
#echo("$total records processed: $add added to database, $discard discarded");
|
||||
?>
|
||||
|
Reference in New Issue
Block a user