Lots of additions.

git-svn-id: http://www.observium.org/svn/observer/trunk@108 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2007-06-24 14:56:47 +00:00
parent 2cd924d0dd
commit 9ca765c285
28 changed files with 521 additions and 400 deletions

View File

@ -66,7 +66,7 @@ while ($link = mysql_fetch_array($link_query)) {
echo(mysql_result(mysql_query("SELECT COUNT(id) FROM `links`"), 0) . " links at end\n");
echo(mysql_result(mysql_query("SELECT COUNT(adj_id) FROM `adjacencies`"), 0) . " adjacencies at start\n");
$link_query = mysql_query("SELECT * FROM `adjacencies` AS A, `interfaces` AS I, `devices` AS D, networks AS N WHERE I.interface_id = A.interface_id AND D.id = I.device_id AND N.id = A.network_id;");
$link_query = mysql_query("SELECT * FROM `adjacencies` AS A, `interfaces` AS I, `devices` AS D, networks AS N WHERE I.interface_id = A.interface_id AND D.device_id = I.device_id AND N.id = A.network_id;");
while ($link = mysql_fetch_array($link_query)) {
$id = $link['adj_id'];
$netid = $link['network_id'];

View File

@ -6,8 +6,9 @@ $db_user = "observer";
$db_pass = "";
$db_name = "observer";
### Installation Location
$installdir = "/var/sites/network.vostron.net/";
### Installation Locations
$installdir = "/var/sites/observer/";
$rrd_dir = $installdir . "rrd/";
### Default community
$community = "public";
@ -40,6 +41,8 @@ $show_if_transit = 0;
$show_if_peering = 0;
$show_locations = 1;
$enable_syslog = 0;
### Interface name strings to ignore
$bif = array("null", "virtual-", "unrouted", "eobc", "mpls", "sl0", "lp0", "faith0",
"-atm layer", "-atm subif", "-shdsl", "-adsl",

View File

@ -10,3 +10,4 @@
./discover-cisco-temp.php &
./discover-vlans.php &
./update-interface.php &
./check-errors.php &

Binary file not shown.

Before

Width:  |  Height:  |  Size: 594 B

After

Width:  |  Height:  |  Size: 384 B

View File

@ -22,12 +22,13 @@ if($_GET['logout']) {
$encrypted=$_COOKIE['encrypted'];
}
$sql = "select username, level from users where username='$_SESSION[username]' and password='$encrypted'";
$sql = "select username, level, user_id from users where username='$_SESSION[username]' and password='$encrypted'";
$row = mysql_fetch_row(mysql_query($sql));
if ( $_SESSION['username'] != "" && $row[0] == $_SESSION['username'] ) {
$_SESSION['userlevel'] = $row[1];
$_SESSION['authenticated'] = true;
$_SESSION['user_id'] = $row[2];
setcookie("username", $username);
setcookie("encrypted", $encrypted);
}

View File

@ -17,10 +17,10 @@ if($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; }
<td class=syslog width=140>
$entry[humandate]
</td>");
$if['id'] = $entry[interface];
$if['if'] = makeshortif($interface);
$if['interface_id'] = $entry[interface];
$if['ifDescr'] = makeshortif($interface);
echo("<td class=list-bold width=75>
" . generateiflink($if) . "
" . generateiflink($if) . "
</td>
<td class=syslog>" .
truncate($entry[message], 45)

View File

@ -1,24 +1,26 @@
<?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=550&height=175";
if(!$graph_type) { $graph_type = $_GET['type']; }
$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=550&height=175";
$daily_traffic = "graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$day&to=$now&width=217&height=100";
$daily_url = "graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$day&to=$now&width=500&height=150";
$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=550&height=175";
$weekly_traffic = "graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$week&to=$now&width=217&height=100";
$weekly_url = "graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$week&to=$now&width=500&height=150";
$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=550&height=175";
$monthly_traffic = "graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$month&to=$now&width=217&height=100";
$monthly_url = "graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$month&to=$now&width=500&height=150";
echo("<a href='?page=interface&id=$iid' onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
$yearly_traffic = "graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$year&to=$now&width=217&height=100";
$yearly_url = "graph.php?if=" . $interface['interface_id'] . "&type=$graph_type&from=$year&to=$now&width=500&height=150";
echo("<a href='?page=interface&id=" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT, BORDER, 0);\" onmouseout=\"return nd();\">
<img src='$daily_traffic' border=0></a> ");
echo("<a href='?page=interface&id=$iid' onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a href='?page=interface&id=" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT, BORDER, 0);\" onmouseout=\"return nd();\">
<img src='$weekly_traffic' border=0></a> ");
echo("<a href='?page=interface&id=$iid' onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a href='?page=interface&id=" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT, BORDER, 0, WIDTH, 350);\" onmouseout=\"return nd();\">
<img src='$monthly_traffic' border=0></a> ");
echo("<a href='?page=interface&id=$iid' onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
echo("<a href='?page=interface&id=" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT, BORDER, 0, WIDTH, 350);\" onmouseout=\"return nd();\">
<img src='$yearly_traffic' border=0></a>");
?>

View File

@ -2,6 +2,11 @@
# This file prints a table row for each interface
$interface['device_id'] = $device['device_id'];
$interface['hostname'] = $device['hostname'];
if(!$_GET['type']) { $_GET['type'] = "bits"; }
$if_id = $interface['interface_id'];
$ifDescr = fixifName($interface['ifDescr']);
$ifIndex = $interface['ifIndex'];
@ -10,18 +15,22 @@
$ifPhysAddress = $interface['ifPhysAddress'];
$ifType = fixiftype($interface['ifType']);
$ifHardType = $interface['ifHardType'];
# echo($interface['ifHardType']);
# $errors = interface_errors($interface);
# $rates = interface_rates($interface);
if($ifAlias) {$ifAlias = $ifAlias . "</br>";}
if($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg="#ffffff"; }
if($interface['in_errors'] > 0 || $interface['out_errors'] > 0) {
$error_img = generateiflink($interface,"<img src='/images/16/chart_curve_error.png' alt='Interface Errors' border=0>",errors);
} else { $error_img = ""; }
$graph_url = "graph.php?if=$if_id&from=$twoday&to=$now&width=400&height=120&type=bits";
echo("<tr style=\"background-color: $bg; padding: 5px;\" valign=top>
<td valign=top width=300>
<span class=list-large>
" . generateiflink($interface, "$i. $ifDescr") . "
" . generateiflink($interface, "$i. $ifDescr") . " $error_img
</span><br /><span class=interface-desc>$ifAlias</span>");
unset ($break);
if(!$dographs) {
@ -31,6 +40,16 @@
$break = " ";
}
echo("</span>");
echo("</td><td width=100>");
if($interface['ifOperStatus'] == "up") {
$in_perc = round($interface['in_rate']/$interface['ifSpeed']*100);
$out_perc = round($interface['in_rate']/$interface['ifSpeed']*100);
echo("<img src='/images/16/arrow_left.png' align=absmiddle> <span style='color: " . percent_colour($in_perc) . "'>" . formatRates($interface['in_rate']) . "</span><br />");
echo("<img align=absmiddle src='/images/16/arrow_out.png'> <span style='color: " . percent_colour($out_perc) . "'>" . formatRates($interface['out_rate']) . "</span>");
}
echo("</td><td width=70>");
if($ifSpeed && $ifSpeed != "") { echo("<span class=box-desc>$ifSpeed</span>"); }
echo("<br />");
@ -84,7 +103,7 @@ echo("</td>");
$this_ifname = fixifName($new['ifDescr']);
$wq = mysql_query("select count(*) FROM links WHERE dst_if = '$this_ifid' AND src_if = $if_id;");
if (@mysql_result($wq, 0) == '0' && $this_hostname != $hostname) {
$graph_url = "graph.php?if=$this_ifid&from=$twoday&to=$now&width=400&height=120&type=bits";
$graph_url = "graph.php?if=$this_ifid&from=$twoday&to=$now&width=400&height=120&type=bits'";
echo("$br &nbsp;<img src='images/16/bullet_go.png' alt='Same Subnet' align=absmiddle />" . generateiflink($new) . " on " . generatedevicelink($new));
$br = "<br />";
}
@ -97,15 +116,44 @@ echo("</td>");
// If we're showing graphs, generate the graph and print the img tags
if($dographs && is_file("rrd/" . $hostname . ".". $ifIndex . ".rrd")) {
$daily_traffic = "graph.php?if=$if_id&type=bits&from=$day&to=$now&width=210&height=100";
$weekly_traffic = "graph.php?if=$if_id&type=bits&from=$week&to=$now&width=210&height=100";
$monthly_traffic = "graph.php?if=$if_id&type=bits&from=$month&to=$now&width=210&height=100";
$yearly_traffic = "graph.php?if=$if_id&type=bits&from=$year&to=$now&width=210&height=100";
$type = $_GET['type'];
echo("<tr style='background-color: $bg; padding: 5px;'><td colspan=3>");
echo("<img src='$daily_traffic'> <img src='$weekly_traffic'> ");
echo("<img src='$monthly_traffic'> <img src='$yearly_traffic'>");
echo("</td></tr>");
# echo("<tr style='background-color: $bg; padding: 5px;'><td colspan=3>");
# include("includes/print-interface-graphs.php");
# echo("</td></tr>");
$daily_traffic = "graph.php?if=$if_id&type=" . $_GET['type'] . "&from=$day&to=$now&width=210&height=100";
$daily_url = "graph.php?if=$if_id&type=" . $_GET['type'] . "&from=$day&to=$now&width=500&height=150";
$weekly_traffic = "graph.php?if=$if_id&type=" . $_GET['type'] . "&from=$week&to=$now&width=210&height=100";
$weekly_url = "graph.php?if=$if_id&type=" . $_GET['type'] . "&from=$week&to=$now&width=500&height=150";
$monthly_traffic = "graph.php?if=$if_id&type=" . $_GET['type'] . "&from=$month&to=$now&width=210&height=100";
$monthly_url = "graph.php?if=$if_id&type=" . $_GET['type'] . "&from=$month&to=$now&width=500&height=150";
$yearly_traffic = "graph.php?if=$if_id&type=" . $_GET['type'] . "&from=$year&to=$now&width=210&height=100";
$yearly_url = "graph.php?if=$if_id&type=" . $_GET['type'] . "&from=$year&to=$now&width=500&height=150";
echo("<tr style='background-color: $bg; padding: 5px;'><td colspan=3>");
echo("<a href='?page=interface&id=" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT, BORDER, 0);\"
onmouseout=\"return nd();\"> <img src='$daily_traffic' border=0></a>");
echo("<a href='?page=interface&id=" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT, BORDER, 0);\"
onmouseout=\"return nd();\"> <img src='$weekly_traffic' border=0></a>");
echo("<a href='?page=interface&id=" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT, WIDTH, 350, BORDER, 0);\"
onmouseout=\"return nd();\"> <img src='$monthly_traffic' border=0></a>");
echo("<a href='?page=interface&id=" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT, WIDTH, 350, BORDER, 0);\"
onmouseout=\"return nd();\"> <img src='$yearly_traffic' border=0></a>");
echo("</td></tr>");
# echo("<tr style='background-color: $bg; padding: 5px;'><td colspan=3>");
# echo("<img src='$daily_traffic'> <img src='$weekly_traffic'> ");
# echo("<img src='$monthly_traffic'> <img src='$yearly_traffic'>");
# echo("</td></tr>");
}

View File

@ -19,6 +19,7 @@
unset($this_alert);
}
?>
<div class="menu2">
@ -28,7 +29,10 @@
<table><tr><td>
<ul>
<li><a href="?page=overview"><img src='/images/16/zoom.png' border=0 align=absmiddle> Overview</a></li>
<li><a href="?page=eventlog"><img src='/images/16/information.png' border=0 align=absmiddle> Eventlog</a></li>
<li><a href="?page=eventlog"><img src='/images/16/report.png' border=0 align=absmiddle> Eventlog</a></li>
<?php if($enable_syslog) {
echo("<li><a href='?page=syslog'><img src='/images/16/page.png' border=0 align=absmiddle> Syslog</a></li>");
} ?>
<li><a href="?page=alerts"><img src='/images/16/exclamation.png' border=0 align=absmiddle> Alerts</a></li>
</ul>
</td></tr></table>
@ -42,17 +46,25 @@
<table><tr><td>
<ul>
<li><a href='?page=devices'><img src='/images/16/server.png' border=0 align=absmiddle> All Devices</a></li>
<li><hr width=140 /></li>
<li><a href="?page=devices&type=server"><img src='/images/16/server.png' border=0 align=absmiddle> Servers</a></li>
<li><a href="?page=devices&type=network"><img src='/images/16/arrow_switch.png' border=0 align=absmiddle> Network</a></li>
<li><a href="?page=devices&type=firewall"><img src='/images/16/shield.png' border=0 align=absmiddle> Firewalls</a></li>
<?php
echo(" <li><hr width=140 /></li>
<li><a href='?page=devices&status=alerted'><img src='/images/16/server_error.png' border=0 align=absmiddle> Alerts ($device_alerts)</a></li>");
?>
echo("
<li><hr width=140 /></li>
<li><a href="?page=addhost"><img src='/images/16/server_add.png' border=0 align=absmiddle> Add Device</a></li>
<li><a href="?page=delhost"><img src='/images/16/server_delete.png' border=0 align=absmiddle> Delete Device</a></li>
<li><a href='?page=devices&type=server'><img src='/images/16/server.png' border=0 align=absmiddle> Servers</a></li>
<li><a href='?page=devices&type=network'><img src='/images/16/arrow_switch.png' border=0 align=absmiddle> Network</a></li>
<li><a href='?page=devices&type=firewall'><img src='/images/16/shield.png' border=0 align=absmiddle> Firewalls</a></li>");
echo(" <li><hr width=140 /></li>
<li><a href='?page=devices&status=alerted'><img src='/images/16/server_error.png' border=0 align=absmiddle> Alerts ($device_alerts)</a></li>");
if($_SESSION['userlevel'] > '5') {
echo("
<li><hr width=140 /></li>
<li><a href='?page=addhost'><img src='/images/16/server_add.png' border=0 align=absmiddle> Add Device</a></li>
<li><a href='?page=delhost'><img src='/images/16/server_delete.png' border=0 align=absmiddle> Delete Device</a></li>");
}
?>
</ul>
</td></tr></table>
<!--[if lte IE 6]></a><![endif]-->
@ -66,10 +78,16 @@ echo(" <li><hr width=140 /></li>
echo(" <li><hr width=140 /></li>
<li><a href='?page=services&status=0'><img src='/images/16/cog_error.png' border=0 align=absmiddle> Alerts ($service_alerts)</a></li>");
} ?>
<li><hr width=140 /></li>
<li><a href="?page=addsrv"><img src='/images/16/cog_add.png' border=0 align=absmiddle> Add Service</a></li>
<li><a href="?page=delsrv"><img src='/images/16/cog_delete.png' border=0 align=absmiddle> Delete Service</a></li>
<?php
if($_SESSION['userlevel'] > '5') {
echo("
<li><hr width=140 /></li>
<li><a href='?page=addsrv'><img src='/images/16/cog_add.png' border=0 align=absmiddle> Add Service</a></li>
<li><a href='?page=delsrv'><img src='/images/16/cog_delete.png' border=0 align=absmiddle> Delete Service</a></li>");
}
?>
</ul>
</td></tr></table>
<!--[if lte IE 6]></a><![endif]-->
@ -84,13 +102,16 @@ echo(" <li><hr width=140 /></li>
<li><a href='?page=interfaces'><img src='/images/16/connect.png' border=0 align=absmiddle> All Ports</a></li>
<li><hr width=140 /></li>
<?php
if($show_if_customers) { echo("<li><a href='?page=customers'><img src='/images/16/group_link.png' border=0 align=absmiddle> Customers</a></li>"); $ifbreak = 1;}
if($show_if_transit) { echo("<li><a href='?page=iftype&type=transit'><img src='/images/16/world_link.png' border=0 align=absmiddle> Transit</a></li>"); $ifbreak = 1; }
if($show_if_peering) { echo("<li><a href='?page=iftype&type=peering'><img src='/images/16/brick_link.png' border=0 align=absmiddle> Peering</a></li>"); $ifbreak = 1; }
if($_SESSION['userlevel'] > '5') {
echo("<li><hr width=140 /></li>");
if($show_if_customers) { echo("<li><a href='?page=customers'><img src='/images/16/group_link.png' border=0 align=absmiddle> Customers</a></li>"); $ifbreak = 1;}
if($show_if_transit) { echo("<li><a href='?page=iftype&type=transit'><img src='/images/16/world_link.png' border=0 align=absmiddle> Transit</a></li>"); $ifbreak = 1; }
if($show_if_peering) { echo("<li><a href='?page=iftype&type=peering'><img src='/images/16/bug_link.png' border=0 align=absmiddle> Peering</a></li>"); $ifbreak = 1; }
if($show_if_core) { echo("<li><a href='?page=iftype&type=core'><img src='/images/16/brick_link.png' border=0 align=absmiddle> Core</a></li>"); $ifbreak = 1;}
}
if($ifbreak && $interface_alerts) { echo("<li><hr width=140 /></li>"); }

View File

@ -3,8 +3,12 @@
if($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; }
$hostname = gethostbyid($entry['host']);
$interface = fixifname(getifbyid($entry['interface']));
# if($entry['interface']) {
# $interface = fixifname(getifbyid($entry['interface']));
# }
$entry['device_id'] = $entry['host'];
$entry['hostname'] = gethostbyid($entry['host']);
unset($icon);
@ -12,15 +16,20 @@ if($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; }
if($icon) {$icon = "<img src='/images/16/$icon'>"; }
echo("<tr style=\"background-color: $bg\">
<td width=0></td>
<td class=syslog width=150>
" . $entry['datetime'] . "
<td class=syslog width=175>");
if($page == "syslog") {
echo("" . generatedevicelink($entry) . "<br />");
}
echo($entry['datetime'] . "
</td>
<td class=list-bold width=75>
<td class=syslog width=100>
" . $entry['priority'] . "
</td>
<td class=syslog width=175>
<br />
" . $entry['program'] . "
</td>
<td class=syslog>

View File

@ -1,5 +1,13 @@
<?php
if($_SESSION['userlevel'] < 10) {
echo("<span class='alert'>You are not permitted to perform this function</span>");
exit;
}
if($_POST['hostname'] && $_POST['community']) {
if($_SESSION['userlevel'] > '5') {
$hostname = $_POST['hostname'];

View File

@ -1,11 +1,11 @@
<?php
if($_SESSION[userlevel] < '5') {
print_error("Insufficient Privileges");
if($_SESSION['userlevel'] < '10') {
echo("<span class='alert'>Insufficient privileges to perform this function.</span>");
} else {
if($_POST['addsrv']) {
if($userlevel > "5") {
if($userlevel == '10') {
include("includes/add-srv.inc");
}
}

View File

@ -1,9 +1,12 @@
<?php
if($_POST['id'] && $_SESSION['userlevel'] > '9') {
if($_SESSION['userlevel'] < 10) {
echo("<span class='alert'>You are not permitted to perform this function</span>");
exit;
}
if($_POST['id'] {
delHost($id);
} elseif ($_POST['id']) {
echo("<p class='errorbox'><b>Error:</b> You don't have the necessary privileges to remove hosts.</p>");
}
?>

View File

@ -1,7 +1,16 @@
<?php
echo("
<div style='float: right; text-align: right;'>
<a href='/?page=device&id=" . $_GET['id'] . "&section=dev-ifgraphs&type=bits'>Bits</a> |
<a href='/?page=device&id=" . $_GET['id'] . "&section=dev-ifgraphs&type=pkts'>Packets</a> |
<a href='/?page=device&id=" . $_GET['id'] . "&section=dev-ifgraphs&type=nupkts'>NU Packets</a> |
<a href='/?page=device&id=" . $_GET['id'] . "&section=dev-ifgraphs&type=errors'>Errors</a>
</div>");
$dographs = 1;
if(!$_GET['type']) { $_GET['type'] = "bits"; }
include("pages/device/dev-ifs.inc");
?>

View File

@ -24,12 +24,13 @@ echo("
<tr><td width=50% valign=top>");
if(file_exists("includes/dev-data-" . strtolower($device[os]) . ".inc")) {
#if(file_exists("includes/dev-data-" . strtolower($device[os]) . ".inc.php")) {
echo("<div style='background-color: #eeeeee; margin: 5px; padding: 5px;'>");
echo("<p class=sectionhead>Device Data</p><div style='height: 5px;'></div>");
include("includes/dev-data-" . strtolower($device[os]) . ".inc");
# echo("<p class=sectionhead>Device Data</p><div style='height: 5px;'></div>");
# include("includes/dev-data-" . strtolower($device[os]) . ".inc.php");
include("includes/dev-overview-data.inc.php");
echo("</div>");
}
#}
if(mysql_result(mysql_query("SELECT count(storage_id) from storage WHERE host_id = '" . $device['device_id'] . "'"),0)) {
@ -38,22 +39,22 @@ if(mysql_result(mysql_query("SELECT count(storage_id) from storage WHERE host_id
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>
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'];
$perc = round($drive['storage_perc'], 0);
$total = formatStorage($total);
$used = formatStorage($used);
$store_url = "graph.php?id=" . $drive['storage_id'] . "&type=unixfs&from=$month&to=$now&width=400&height=125";
$store_popup = "onmouseover=\"return overlib('<img src=\'$store_url\'>', LEFT);\" onmouseout=\"return nd();\"";
if($perc > '80') { $drv_class='red'; } else { $drvclass=''; }
if($perc > '80') { $drv_colour='#cc0000'; } else { $drvclass='#0000cc'; }
echo("<tr><td class=tablehead>" . $drive['hrStorageDescr'] . "</td><td><a href='#' $store_popup><img src='percentage.php?per=" . $perc . "'></a>
</td><td>" . $perc . "%</td><td>" . $total . "</td><td>" . $used . "</td></tr>");
</td><td style='font-weight: bold; color: $drv_colour'>" . $perc . "%</td><td>" . $total . "</td><td>" . $used . "</td></tr>");
$i++;
}
echo("</table>");
@ -74,14 +75,12 @@ if(mysql_result(mysql_query("SELECT count(temp_id) from temperature WHERE temp_h
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_perc = $temp['temp_current'] / $temp['temp_limit'] * 100;
$temp_colour = percent_colour($temp_perc);
$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'] . "&deg;C</span></td></tr>");
echo("<tr bgcolor='$row_colour'><td>" . $temp['temp_descr'] . "</td><td width=40 class=tablehead><span style='color: $temp_colour'>" . $temp['temp_current'] . "&deg;C</span></td></tr>");
if($i == $rows) { echo("</table></td><td valign=top><table width=100% cellspacing=0 cellpadding=2>"); }
$i++;
}
@ -112,7 +111,7 @@ echo("</td><td width=50% valign=top>");
if($interfaces['total']) {
echo("<div style='background-color: #eeeeee; margin: 5px; padding: 5px;'>
<p class=sectionhead>Total Traffic</p>" . device_traffic_image($device['device_id'], 490, 100, $day, $now) . "</div>");
<p class=sectionhead>Total Traffic</p>" . device_traffic_image($device['device_id'], 490, 100, $day, '-300s') . "</div>");
}
if($interfaces['total']) {

View File

@ -1,13 +1,13 @@
<?
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";
}
$query = "SELECT *, DATE(datetime) AS date, TIME(datetime) AS time ";
$query .= "FROM `syslog` WHERE `host` = '" . $_GET['id'] . "'";
if($search) { $query .= " AND `msg` LIKE '%" . $_POST['search'] . "%'"; }
$query .= " ORDER BY `datetime` 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' />
@ -18,10 +18,9 @@ echo("<div align=right><form id='form1' name='form1' method='post' action='" . $
echo("<table cellspacing=0 cellpadding=2 width=100%>");
while($entry = mysql_fetch_array($data)) {
include("includes/print-syslog.inc");
include("includes/print-syslog.inc");
}
echo("</table>");
?>
?>

View File

@ -1,21 +1,23 @@
<?php
if($_GET['location']) { $where = "WHERE location = '$_GET[location]'"; }
if($_GET['location'] == "Unset") { $where = "WHERE location = ''"; }
if($_GET['type']) { $where = "WHERE type = '$_GET[type]'"; }
if($_GET['location']) { $where = "AND location = '$_GET[location]'"; }
if($_GET['location'] == "Unset") { $where = "AND location = ''"; }
if($_GET['type']) { $where = "AND type = '$_GET[type]'"; }
$sql = "select * from devices $where ORDER BY `ignore`, `status`, `os`, `hostname`";
if($_GET['status'] == "alerted") { $sql = "select * from devices " . $device_alert_sql . " GROUP BY `device_id` ORDER BY `ignore`, `status`, `os`, `hostname`"; }
$sql = "select * from devices WHERE 1 $where ORDER BY `ignore`, `status`, `os`, `hostname`";
if($_GET['status'] == "alerted") {
$sql = "select * from devices " . $device_alert_sql . " GROUP BY `device_id` ORDER BY `ignore`, `status`, `os`, `hostname`";
}
$device_query = mysql_query($sql);
echo("<table cellpadding=7 cellspacing=0 class=devicetable width=100%>");
while($device = mysql_fetch_array($device_query)) {
$device['uptime'] = @mysql_result(mysql_query("SELECT `attrib_value` FROM `devices_attribs` WHERE `device_id` = '" . $device['device_id'] ."' AND `attrib_type` = 'uptime'"), 0);
include("includes/hostbox.inc");
if( devicepermitted($device['device_id']) || $_SESSION['userlevel'] == 10 ) {
$device['uptime'] = @mysql_result(mysql_query("SELECT `attrib_value` FROM `devices_attribs` WHERE `device_id` = '" . $device['device_id'] ."' AND `attrib_type` = 'uptime'"), 0);
include("includes/hostbox.inc");
}
}
echo("</table>");

View File

@ -1,6 +1,11 @@
<?
$query = "SELECT *,DATE_FORMAT(datetime, '%D %b %Y %T') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,250";
if($_SESSION['userlevel'] == '10') {
$query = "SELECT *,DATE_FORMAT(datetime, '%D %b %Y %T') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,250";
} else {
$query = "SELECT *,DATE_FORMAT(datetime, '%D %b %Y %T') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,250";
}
$data = mysql_query($query);

View File

@ -1,6 +1,11 @@
<?php
$sql = "SELECT * FROM `interfaces` AS I, `devices` AS D WHERE I.device_id = D.device_id ORDER BY D.hostname, I.ifDescr";
if ($_SESSION['userlevel'] == '10') {
$sql = "SELECT * FROM `interfaces` AS I, `devices` AS D WHERE I.device_id = D.device_id ORDER BY D.hostname, I.ifDescr";
} else {
$sql = "SELECT * FROM `interfaces` AS I, `devices` AS D, `devices_perms` AS P WHERE I.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, I.ifDescr";
}
$query = mysql_query($sql);
echo("<table cellspacing=0 cellpadding=2 width=100%>");
@ -16,9 +21,14 @@ while($interface = mysql_fetch_array($query)) {
$speed = humanspeed($interface['ifSpeed']);
$type = humanmedia($interface['ifType']);
if($interface['in_errors'] > 0 || $interface['out_errors'] > 0) {
$error_img = generateiflink($interface,"<img src='/images/16/chart_curve_error.png' alt='Interface Errors' border=0>",errors);
} else { $error_img = ""; }
echo("<tr bgcolor=$row_colour>
<td class=list-bold>" . generatedevicelink($interface) . "</td>
<td class=list-bold>" . generateiflink($interface, makeshortif(fixifname($interface['ifDescr']))) . "</td>
<td class=list-bold>" . generateiflink($interface, makeshortif(fixifname($interface['ifDescr']))) . " $error_img</td>
<td>$speed</td>
<td>$type</td>
<td>" . $interface[ifAlias] . "</td>

View File

@ -1,17 +1,32 @@
<?
echo("<table cellpadding=7 cellspacing=0 class=devicetable width=100%>");
$device_query = mysql_query("select location from devices GROUP BY location ORDER BY location");
if($_SESSION['userlevel'] == '10') {
$sql = "SELECT `location` FROM `devices` GROUP BY `location` ORDER BY `location`";
} else {
$sql = "SELECT `location` FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' GROUP BY `location` ORDER BY `location`";
}
$device_query = mysql_query($sql);
while($device = mysql_fetch_array($device_query)) {
if($bg == "#ffffff") { $bg = "#eeeeee"; } else { $bg="#ffffff"; }
$num = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '$device[location]'"),0);
$net = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '$device[location]' AND type = 'network'"),0);
$srv = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '$device[location]' AND type = 'server'"),0);
$fwl = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '$device[location]' AND type = 'firewall'"),0);
if($_SESSION['userlevel'] == '10') {
$num = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $device['location'] . "'"),0);
$net = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $device['location'] . "' AND type = 'network'"),0);
$srv = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $device['location'] . "' AND type = 'server'"),0);
$fwl = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $device['location'] . "' AND type = 'firewall'"),0);
$hostalerts = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $device['location'] . "' AND status = '0'"),0);
} else {
$num = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $device['location'] . "'"),0);
$net = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $device['location'] . "' AND D.type = 'network'"),0);
$srv = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $device['location'] . "' AND type = 'server'"),0);
$fwl = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $device['location'] . "' AND type = 'firewall'"),0);
$hostalerts = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices AS D, devices_perms AS P WHERE location = '" . $device['location'] . "' AND status = '0'"),0);
}
$hostalerts = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '$device[location]' AND status = '0'"),0);
if($hostalerts) { $alert = "<img src='/images/16/flag_red.png'>"; }
$loc = $device[location];

View File

@ -1,12 +1,15 @@
<?php
if($_GET['status'] == '0') { $where = " AND service_status = '0'"; }
if($_GET['status'] == '0') { $where = " AND service_status = '0'"; } else { unset ($where); }
echo("<div style='margin: 5px;'><table cellpadding=7 border=0 cellspacing=0 width=100%>");
//echo("<tr class=interface-desc bgcolor='#e5e5e5'><td>Device</td><td>Service</td><td>Status</td><td>Changed</td><td>Checked</td><td>Message</td></tr>");
if ($_SESSION['userlevel'] == '10') {
$host_sql = "SELECT * FROM devices AS D, services AS S WHERE D.device_id = S.service_host GROUP BY D.hostname ORDER BY D.hostname";
} else {
$host_sql = "SELECT * FROM devices AS D, services AS S, devices_perms AS P WHERE D.device_id = S.service_host AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' $where GROUP BY D.hostname ORDER BY D.hostname";
}
$host_query = mysql_query($host_sql);
while($host_data = mysql_fetch_array($host_query)) {
$device_id = $host_data['device_id'];

View File

@ -1,121 +1,18 @@
<meta http-equiv="refresh" content="60">
<?
$sql = "select *,DATE_FORMAT(datetime, '%D %M %Y %T') as humandate from syslog ORDER BY datetime DESC LIMIT 1000";
echo("
<table cellspacing=0 cellpadding=2>
<tr class=interface align=center>
<td width=4>
</td>
<td>
Time
</td>
<td width=5>
</td>
<td>
Hostname
</td>
<td width=5>
</td>
<td>
Type
</td>
<td width=5>
</td>
<td>
Message
</td>
<td width=10>
</td>
</tr>");
$sql = "select * from syslog ORDER BY datetime DESC LIMIT 1000";
$query = mysql_query($sql);
while($event = mysql_fetch_array($query))
echo("<table cellspacing=0 cellpadding=2 width=100%>");
while($entry = mysql_fetch_array($query))
{
unset($class);
unset($argh);
$event[msg] = preg_replace("/.*%/", "", $event[msg]);
$event[msg] = preg_replace("/[0-9]+:\ /", "", $event[msg]);
$prefix = preg_replace ("/(.+):\ .*/", "\\1", $event[msg]);
$event[msg] = preg_replace ("/.+:\ /", "", $event[msg]);
if($prefix == $event[msg]) { unset ($prefix); }
$prefix = str_replace("CRYPTO-4-RECVD_PKT_INV_SPI: decaps", "Crypto Invalid SPI", $prefix);
$prefix = str_replace("LINEPROTO-5-UPDOWN", "Lineproto Up/Down", $prefix);
$prefix = str_replace("LINK-3-UPDOWN", "Link Up/Down", $prefix);
$prefix = str_replace("LINEPROTO-SP-5-UPDOWN", "Lineproto Up/Down", $prefix);
$prefix = str_replace("LINK-SP-3-UPDOWN", "Link Up/Down", $prefix);
$prefix = str_replace("PIM-6-INVALID_RP_JOIN", "PIM Invalid RP Join", $prefix);
$prefix = str_replace("BGP-3-NOTIFICATION", "BGP Notification", $prefix);
$prefix = str_replace("LINK-3-UPDOWN", "Link Up/Down", $prefix);
$prefix = str_replace("DIALER-6-UNBIND", "Dialer Unbound", $prefix);
$prefix = str_replace("DIALER-6-BIND", "Dialer Bound", $prefix);
$prefix = str_replace("SYS-5-CONFIG_I", "System Configured", $prefix);
$prefix = str_replace("VPDN-6-CLOSED", "VPDN Closed", $prefix);
$prefix = str_replace("DIALER-6-BIND", "Dialer Bound", $prefix);
$prefix = str_replace("PCMCIAFS-5-DIBERR", "PCMCIA FS Error", $prefix);
$prefix = str_replace("BGP-5-ADJCHANGE", "BGP Adj Change", $prefix);
$prefix = str_replace("MSDP-5-PEER_UPDOWN", "MSDP Peer UP/Down", $prefix);
$prefix = str_replace("SYS-5-CONFIG_I", "System Configured", $prefix);
$prefix = preg_replace("/.*ETHER-3-UNDERFLO/", "Ethernet Underflow", $prefix);
if(strstr($event[msg], "BGP authentication failure") !== false) { $class = "pinkbg"; }
if(strstr($event[msg], "Down BGP Notification received") !== false) { $class = "redbg"; }
if(strstr($event[msg], "DOWN on interface") !== false) { $class = "redbg"; }
if(strstr($event[msg], "from FULL to DOWN") !== false) { $class = "redbg"; }
if(strstr($event[msg], "changed state to down") !== false) { $class = "redbg"; }
if(strstr($event[msg], "(cease)") !== false) { $class = "redbg"; }
if(strstr($event[msg], "(hold time expired)") !== false) { $class = "redbg"; }
if(strstr($event[msg], "Configured from console") !== false) { $class = "bluebg"; }
if(strstr($event[msg], "DR change ") !== false) { $class = "bluebg"; }
if(strstr($event[msg], "Up") !== false) { $class = "greenbg"; }
if(strstr($event[msg], "from LOADING to FULL") !== false) { $class = "greenbg"; }
if(strstr($event[msg], "UP on interface ") !== false) { $class = "greenbg"; }
if(strstr($event[msg], "changed state to up") !== false) { $class = "greenbg"; }
if(strstr($event[msg], "A format in this router is required") !== false) { $class = "greybg"; }
if(strstr($event[msg], "bytes failed from") !== false) { $class = "greybg"; }
if($event[msg] == "Attempted to connect to RSHELL from 195.74.96.24" ) { $argh = 1; }
$event[msg] = str_replace("PCMCIA disk 0 is formatted from a different router or PC. A format in this router is required before an image can be booted from this device", "PCMCIA diak 0 is incorrectly formatted", $event[msg]);
if(!$argh) {
echo ("
<tr class='$class'>
<td width=4>
</td>
<td class=syslog>
$event[humandate]
</td>
<td width=5>
</td>
<td class=syslog>
$event[host]
</td>
<td width=5>
</td>
<td class=syslog>
$prefix
</td>
<td width=5>
</td>
<td class=syslog>
$event[msg]
</td>
<td width=4>
</td>
</tr>
");
include("includes/print-syslog.inc");
}
}
echo("</table>");
?>
</table>

View File

@ -1,6 +1,11 @@
<?php
$sql = "SELECT * FROM `temperature` AS T, `devices` AS D WHERE T.temp_host = D.device_id ORDER BY D.hostname, T.temp_descr";
if($_SESSION['userlevel'] == '10') {
$sql = "SELECT * FROM `temperature` AS T, `devices` AS D WHERE T.temp_host = D.device_id ORDER BY D.hostname, T.temp_descr";
} else {
$sql = "SELECT * FROM `temperature` AS T, `devices` AS D, devices_perms as P WHERE T.temp_host = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, T.temp_descr";
}
$query = mysql_query($sql);
echo("<table cellspacing=0 cellpadding=2 width=100%>");
@ -28,11 +33,15 @@ while($temp = mysql_fetch_array($query)) {
" . $temp['temp_descr'] . "</a> ";
$temp_perc = $temp['temp_current'] / $temp['temp_limit'] * 100;
$temp_colour = percent_colour($temp_perc);
echo("<tr bgcolor=$row_colour>
<td class=list-bold>" . generatedevicelink($temp) . "</td>
<td>$temp_popup</td>
<td>" . print_temperature($temp['temp_current'], $temp['temp_limit']) . "</td>
<td style='color: $temp_colour; font-weight: bold;'>" . $temp['temp_current'] . "</td>
<td>" . $temp['temp_limit'] . "</td>
<td>" . $temp['temp_notes'] . "</td>
</tr>\n");

View File

@ -9,45 +9,97 @@ include("snom.php");
include("graphing.php");
include("print-functions.php");
function devicepermitted($device_id) {
global $_SESSION;
if($_SESSION['level'] > "5") { $allowed = true;
} elseif ( @mysql_result(mysql_query("SELECT * FROM devices_perms WHERE `user_id` = '" . $_SESSION['user_id'] . "' AND `device_id` = $device_id"), 0) > '0' ) {
$allowed = true;
} else { $allowed = false; }
return $allowed;
}
function formatRates($rate) {
$sizes = Array('bps', 'Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps');
$round = Array('0','0','0','2','2','2','2','2','2');
$ext = $sizes[0];
for ($i=1; (($i < count($sizes)) && ($rate >= 1000)); $i++) { $rate = $rate / 1000; $ext = $sizes[$i]; }
return round($rate, $round[$i]).$ext;
}
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];
}
for ($i=1; (($i < count($sizes)) && ($size >= 1024)); $i++) { $size = $size / 1024; $ext = $sizes[$i]; }
return round($size, 2).$ext;
}
function percent_colour($perc)
{
$r = min(255, 5 * ($perc - 50));
$b = max(0, 255 - (5 * $perc));
return sprintf('#%02x%02x%02x', $r, 0, $b);
}
function percent_colour_old($perc) {
$red = round(5 * $perc);
$blue = round(255 - (5 * $perc));
if($red > '255') { $red = "255"; }
if($blue < '0') { $blue = "0"; }
$red = dechex($red);
$blue = dechex($blue);
if(strlen($red) == 1) { $red = "0$red"; }
if(strlen($blue) == 1) { $blue = "0$blue"; }
$colour = "#$red" . "00" . "$blue";
return $colour;
}
function print_error($text){
echo("<table class=errorbox cellpadding=3><tr><td><img src='/images/15/exclamation.png' align=absmiddle> $text</td></tr></table>");
echo("<table class=errorbox cellpadding=3><tr><td><img src='/images/15/exclamation.png' align=absmiddle> $text</td></tr></table>");
}
function print_message($text){
echo("<table class=messagebox cellpadding=3><tr><td><img src='/images/16/tick.png' align=absmiddle> $text</td></tr></table>");
echo("<table class=messagebox cellpadding=3><tr><td><img src='/images/16/tick.png' align=absmiddle> $text</td></tr></table>");
}
function truncate($substring, $max = 50, $rep = '...') {
if(strlen($substring) < 1){
$string = $rep;
}else{
$string = $substring;
}
$leave = $max - strlen ($rep);
if(strlen($string) > $max){
return substr_replace($string, $rep, $leave);
}else{
return $string;
}
if(strlen($substring) < 1){ $string = $rep; } else { $string = $substring; }
$leave = $max - strlen ($rep);
if(strlen($string) > $max){ return substr_replace($string, $rep, $leave); } else { return $string; }
}
function interface_rates ($interface) {
global $rrdtool;
$rrdfile = "rrd/" . $interface['hostname'] . "." . $interface['ifIndex'] . ".rrd";
$data = trim(`$rrdtool fetch -s -600s -e now $rrdfile AVERAGE | grep : | cut -d" " -f 2,3 | grep e`);
# $data = trim(`$rrdtool fetch -s -301s -e -300s $rrdfile AVERAGE | grep : | cut -d" " -f 2,3`);
foreach( explode("\n", $data) as $entry) {
list($in, $out) = split(" ", $entry);
$rate['in'] = $in * 8;
$rate['out'] = $out * 8;
}
return $rate;
}
function interface_errors ($interface) {
global $rrdtool;
$rrdfile = "rrd/" . $interface['hostname'] . "." . $interface['ifIndex'] . ".rrd";
$data = trim(`$rrdtool fetch -s -1d -e -300s $rrdfile AVERAGE | grep : | cut -d" " -f 4,5`);
foreach( explode("\n", $data) as $entry) {
list($in, $out) = explode(" ", $entry);
$in_errors += ($in * 300);
$out_errors += ($out * 300);
}
$errors['in'] = round($in_errors);
$errors['out'] = round($out_errors);
return $errors;
}
function geteventicon ($message) {
if($message == "Device status changed to Down") { $icon = "server_connect.png"; }
if($message == "Device status changed to Up") { $icon = "server_go.png"; }
@ -58,14 +110,15 @@ function geteventicon ($message) {
if($icon) { return $icon; } else { return false; }
}
function generateiflink($interface, $text=0) {
function generateiflink($interface, $text=0,$type=bits) {
global $twoday;
global $now;
if(!$text) { $text = fixIfName($interface['ifDescr']); }
if(!$type) { $type = 'bits'; }
$class = ifclass($interface['ifOperStatus'], $interface['ifAdminStatus']);
$graph_url = "graph.php?if=" . $interface['interface_id'] . "&from=$twoday&to=$now&width=400&height=120&type=bits";
$link = "<a class=$class href='?page=interface&id=" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$graph_url\'>');\" onmouseout=\"return nd();\">$text</a>";
$graph_url = "graph.php?if=" . $interface['interface_id'] . "&from=$twoday&to=$now&width=400&height=120&type=" . $type;
$link = "<a class=$class href='?page=interface&id=" . $interface['interface_id'] . "' ";
$link .= "onmouseover=\"return overlib('<img src=\'$graph_url\'>');\" onmouseout=\"return nd();\">$text</a>";
return $link;
}
@ -95,30 +148,23 @@ function devclass($device) {
function getImage($host) {
$sql = "SELECT * FROM `devices` WHERE `device_id` = '$host'";
$data = mysql_fetch_array(mysql_query($sql));
$type = strtolower($data['os']);
if(file_exists("images/os/$type" . ".png")){ $image = "<img src='images/os/$type.png'>";
} elseif(file_exists("images/os/$type" . ".gif")){ $image = "<img src='images/os/$type.gif'>"; }
if($device['monowall']) {$image = "<img src='images/os/m0n0wall.png'>";}
if($type == "linux") {
$features = strtolower(trim($data[features]));
list($distro) = split(" ", $features);
if(file_exists("images/os/$distro" . ".png")){ $image = "<img src='images/os/$distro" . ".png'>";
} elseif(file_exists("images/os/$distro" . ".gif")){ $image = "<img src='images/os/$distro" . ".gif'>"; }
}
return $image;
}
function delHost($id) {
$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 `interfaces` WHERE `device_id` = '$id'");
@ -167,18 +213,15 @@ function scanUDP ($host, $port, $timeout) {
$handle = fsockopen($host, $port, &$errno, &$errstr, 2);
if (!$handle) {
}
socket_set_timeout ($handle, $timeout);
$write = fwrite($handle,"\x00");
if (!$write) {
next;
}
$startTime = time();
$header = fread($handle, 1);
$endTime = time();
$timeDiff = $endTime - $startTime;
if ($timeDiff >= $timeout) {
fclose($handle);
return 1;
@ -225,10 +268,8 @@ function humanspeed($speed) {
function netmask2cidr($netmask) {
list ($network, $cidr) = explode("/", trim(`ipcalc $address/$mask | grep Network | cut -d" " -f 4`));
return $cidr;
}
function cidr2netmask() {
@ -297,7 +338,6 @@ function isValidInterface($if) {
function ifclass($ifOperStatus, $ifAdminStatus) {
$ifclass = "interface-upup";
if ($ifAdminStatus == "down") { $ifclass = "interface-admindown"; }
if ($ifAdminStatus == "up" && $ifOperStatus== "down") { $ifclass = "interface-updown"; }
if ($ifAdminStatus == "up" && $ifOperStatus== "up") { $ifclass = "interface-upup"; }
@ -330,16 +370,13 @@ function utime() {
}
function fixiftype ($type) {
$type = str_replace("ethernetCsmacd", "Ethernet", $type);
$type = str_replace("tunnel", "Tunnel", $type);
$type = str_replace("softwareLoopback", "Software Loopback", $type);
$type = str_replace("propVirtual", "Ethernet VLAN", $type);
$type = str_replace("ethernetCsmacd", "Ethernet", $type);
$type = str_replace("l2vlan", "Ethernet VLAN", $type);
$type = str_replace("l2vlan", "Ethernet VLAN", $type);
return ($type);
}
function fixifName ($inf) {
@ -400,7 +437,6 @@ function fixIOSHardware($hardware){
$hardware = str_replace("C3200XL", "Cisco Catalyst 3200XL", $hardware);
$hardware = str_replace("C3550", "Cisco Catalyst 3550", $hardware);
$hardware = str_replace("C2950", "Cisco Catalyst 2950", $hardware);
return $hardware;
}

View File

@ -1,37 +1,22 @@
-- MySQL dump 10.10
--
-- Host: localhost Database: vostron_network
-- ------------------------------------------------------
-- Server version 5.0.22-Debian_0ubuntu6.06.2-log
-- --------------------------------------------------------
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
--
-- Table structure for table `adjacencies`
--
--
DROP TABLE IF EXISTS `adjacencies`;
CREATE TABLE `adjacencies` (
`adj_id` int(11) NOT NULL auto_increment,
`network_id` int(11) NOT NULL default '0',
`interface_id` int(11) NOT NULL default '0',
PRIMARY KEY (`adj_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
--
-- --------------------------------------------------------
--
-- Table structure for table `alerts`
--
--
DROP TABLE IF EXISTS `alerts`;
CREATE TABLE `alerts` (
`id` int(11) NOT NULL auto_increment,
`importance` int(11) NOT NULL default '0',
@ -40,37 +25,30 @@ CREATE TABLE `alerts` (
`time_logged` timestamp NOT NULL default CURRENT_TIMESTAMP,
`alerted` smallint(6) NOT NULL default '0',
KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
--
-- --------------------------------------------------------
--
-- Table structure for table `customers`
--
--
DROP TABLE IF EXISTS `customers`;
CREATE TABLE `customers` (
`customer_id` int(11) NOT NULL auto_increment,
`username` char(64) NOT NULL,
`password` char(32) NOT NULL,
`string` char(64) NOT NULL,
`level` tinyint(4) NOT NULL default '0',
PRIMARY KEY (`customer_id`),
UNIQUE KEY `username` (`username`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
--
-- Table structure for table `device_uptime`
--
-- --------------------------------------------------------
DROP TABLE IF EXISTS `device_uptime`;
CREATE TABLE `device_uptime` (
`device_id` int(11) NOT NULL default '0',
`device_uptime` int(11) NOT NULL default '0',
UNIQUE KEY `device_id` (`device_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
--
-- Table structure for table `devices`
--
--
DROP TABLE IF EXISTS `devices`;
CREATE TABLE `devices` (
`device_id` int(11) NOT NULL auto_increment,
`hostname` text NOT NULL,
@ -93,26 +71,39 @@ CREATE TABLE `devices` (
`postfix` tinyint(4) NOT NULL default '0',
`type` varchar(8) NOT NULL default 'other',
PRIMARY KEY (`device_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
--
-- --------------------------------------------------------
--
-- Table structure for table `devices_attribs`
--
--
DROP TABLE IF EXISTS `devices_attribs`;
CREATE TABLE `devices_attribs` (
`attrib_id` int(11) NOT NULL auto_increment,
`device_id` int(11) NOT NULL,
`attrib_type` varchar(32) NOT NULL,
`attrib_value` varchar(256) NOT NULL,
PRIMARY KEY (`attrib_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
-- --------------------------------------------------------
--
-- Table structure for table `devices_perms`
--
CREATE TABLE `devices_perms` (
`user_id` int(11) NOT NULL,
`device_id` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table `eventlog`
--
-- --------------------------------------------------------
--
-- Table structure for table `eventlog`
--
DROP TABLE IF EXISTS `eventlog`;
CREATE TABLE `eventlog` (
`id` int(11) NOT NULL default '0',
`host` int(11) NOT NULL default '0',
@ -123,11 +114,28 @@ CREATE TABLE `eventlog` (
KEY `host` (`host`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Table structure for table `interfaces`
--
-- --------------------------------------------------------
--
-- Table structure for table `interface_measurements`
--
CREATE TABLE `interface_measurements` (
`interface_id` int(11) NOT NULL,
`timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`period` int(11) NOT NULL,
`delta_in` int(11) NOT NULL,
`delta_out` int(11) NOT NULL,
`rate_in` int(11) NOT NULL,
`rate_out` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `interfaces`
--
DROP TABLE IF EXISTS `interfaces`;
CREATE TABLE `interfaces` (
`interface_id` int(11) NOT NULL auto_increment,
`device_id` int(11) NOT NULL default '0',
@ -145,18 +153,26 @@ CREATE TABLE `interfaces` (
`ifLastChange` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`ifVlan` int(11) default NULL,
`ifTrunk` varchar(8) default '',
`in_rate` int(11) NOT NULL,
`out_rate` int(11) NOT NULL,
`counter_in` int(11) default NULL,
`counter_out` int(11) default NULL,
`in_errors` int(11) NOT NULL,
`out_errors` int(11) NOT NULL,
`ignore` tinyint(1) NOT NULL default '0',
`detailed` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`interface_id`),
KEY `host` (`device_id`),
KEY `snmpid` (`ifIndex`),
KEY `if_2` (`ifDescr`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
--
-- --------------------------------------------------------
--
-- Table structure for table `ipaddr`
--
--
DROP TABLE IF EXISTS `ipaddr`;
CREATE TABLE `ipaddr` (
`id` int(11) NOT NULL auto_increment,
`addr` varchar(32) NOT NULL default '',
@ -165,13 +181,14 @@ CREATE TABLE `ipaddr` (
`interface_id` int(11) NOT NULL default '0',
PRIMARY KEY (`id`),
KEY `addr` (`addr`,`cidr`,`interface_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
--
-- --------------------------------------------------------
--
-- Table structure for table `links`
--
--
DROP TABLE IF EXISTS `links`;
CREATE TABLE `links` (
`id` int(11) NOT NULL auto_increment,
`src_if` int(11) default NULL,
@ -179,13 +196,14 @@ CREATE TABLE `links` (
`active` tinyint(4) NOT NULL default '1',
`cdp` int(11) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
--
-- --------------------------------------------------------
--
-- Table structure for table `logs`
--
--
DROP TABLE IF EXISTS `logs`;
CREATE TABLE `logs` (
`host` varchar(32) default NULL,
`facility` varchar(10) default NULL,
@ -193,7 +211,7 @@ CREATE TABLE `logs` (
`level` varchar(10) default NULL,
`tag` varchar(10) default NULL,
`datetime` datetime default NULL,
`program` varchar(15) default NULL,
`program` varchar(32) default NULL,
`msg` text,
`seq` bigint(20) unsigned NOT NULL auto_increment,
PRIMARY KEY (`seq`),
@ -201,27 +219,30 @@ CREATE TABLE `logs` (
KEY `program` (`program`),
KEY `datetime` (`datetime`),
KEY `priority` (`priority`),
KEY `facility` (`facility`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
KEY `facility` (`facility`),
KEY `seq` (`seq`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
--
-- --------------------------------------------------------
--
-- Table structure for table `networks`
--
--
DROP TABLE IF EXISTS `networks`;
CREATE TABLE `networks` (
`id` int(11) NOT NULL auto_increment,
`cidr` varchar(32) NOT NULL default '',
PRIMARY KEY (`id`),
UNIQUE KEY `cidr_2` (`cidr`),
FULLTEXT KEY `cidr` (`cidr`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
--
-- --------------------------------------------------------
--
-- Table structure for table `services`
--
--
DROP TABLE IF EXISTS `services`;
CREATE TABLE `services` (
`service_id` int(11) NOT NULL auto_increment,
`service_host` int(11) NOT NULL,
@ -236,13 +257,14 @@ CREATE TABLE `services` (
`service_message` text NOT NULL,
PRIMARY KEY (`service_id`),
KEY `service_host` (`service_host`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
--
-- --------------------------------------------------------
--
-- Table structure for table `storage`
--
--
DROP TABLE IF EXISTS `storage`;
CREATE TABLE `storage` (
`storage_id` int(11) NOT NULL auto_increment,
`host_id` int(11) NOT NULL,
@ -250,22 +272,25 @@ CREATE TABLE `storage` (
`hrStorageDescr` text NOT NULL,
`hrStorageSize` int(11) NOT NULL,
`hrStorageAllocationUnits` int(11) NOT NULL,
`hrStorageUsed` int(11) NOT NULL,
`storage_perc` text NOT NULL,
PRIMARY KEY (`storage_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
--
-- --------------------------------------------------------
--
-- Table structure for table `syslog`
--
--
DROP TABLE IF EXISTS `syslog`;
CREATE TABLE `syslog` (
`host` varchar(32) default NULL,
`host` int(11) default NULL,
`facility` varchar(10) default NULL,
`priority` varchar(10) default NULL,
`level` varchar(10) default NULL,
`tag` varchar(10) default NULL,
`datetime` datetime default NULL,
`program` varchar(20) default NULL,
`program` varchar(32) default NULL,
`msg` text,
`seq` bigint(20) unsigned NOT NULL auto_increment,
PRIMARY KEY (`seq`),
@ -273,42 +298,49 @@ CREATE TABLE `syslog` (
KEY `program` (`program`),
KEY `datetime` (`datetime`),
KEY `priority` (`priority`),
KEY `facility` (`facility`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
KEY `facility` (`facility`),
KEY `seq` (`seq`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
--
-- --------------------------------------------------------
--
-- Table structure for table `temperature`
--
--
DROP TABLE IF EXISTS `temperature`;
CREATE TABLE `temperature` (
`temp_id` int(11) NOT NULL auto_increment,
`temp_host` int(11) NOT NULL default '0',
`temp_oid` varchar(32) NOT NULL default '',
`temp_oid` varchar(64) NOT NULL,
`temp_descr` varchar(32) NOT NULL default '',
`temp_tenths` int(1) NOT NULL default '0',
`temp_current` tinyint(4) NOT NULL default '0',
`temp_limit` tinyint(4) NOT NULL default '70',
PRIMARY KEY (`temp_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
--
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
--
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`user_id` int(11) NOT NULL auto_increment,
`username` char(30) NOT NULL,
`password` char(32) NOT NULL,
`descr` char(30) NOT NULL,
`level` tinyint(4) NOT NULL default '0',
PRIMARY KEY (`user_id`),
UNIQUE KEY `username` (`username`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;
--
-- --------------------------------------------------------
--
-- Table structure for table `vlans`
--
--
DROP TABLE IF EXISTS `vlans`;
CREATE TABLE `vlans` (
`vlan_id` int(11) NOT NULL auto_increment,
`device_id` int(11) default NULL,
@ -317,14 +349,5 @@ CREATE TABLE `vlans` (
`vlan_descr` text,
PRIMARY KEY (`vlan_id`),
KEY `device_id` (`device_id`,`vlan_vlan`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;

View File

@ -192,7 +192,14 @@ while ($device = mysql_fetch_array($device_query)) {
if ($uptime) {
echo("Uptime : $uptime\n");
$old_uptime = mysql_result(mysql_query("SELECT `attrib_value` FROM `devices_attribs` WHERE `device_id` = '" . $device['device_id'] . "' AND `attrib_type` = 'uptime'"), 0);
if( $uptime < $old_uptime ) {
mail($notify_email, "Rebooted: " . $device['hostname'], "Device " . $device['hostname'] . " rebooted at " . date('l dS F Y h:i:s A'));
}
$uptimerrd = "rrd/" . $device['hostname'] . "-uptime.rrd";
if(!is_file($uptimerrd)) {
@ -209,6 +216,7 @@ while ($device = mysql_fetch_array($device_query)) {
if(mysql_affected_rows() == '0') {
$insert_uptime_attrib = mysql_query("INSERT INTO devices_attribs (`device_id`, `attrib_type`, `attrib_value`) VALUES ('" . $device['device_id'] . "', 'uptime', '$uptime')");
}
}

View File

@ -10,6 +10,11 @@ $interface_query = mysql_query("SELECT * FROM `interfaces` $where");
while ($interface = mysql_fetch_array($interface_query)) {
$device = mysql_fetch_array(mysql_query("SELECT * FROM `devices` WHERE device_id = '" . $interface['device_id'] . "'"));
unset($ifAdminStatus, $ifOperStatus, $ifAlias, $ifDescr);
$interface['hostname'] = $device['hostname'];
$interface['device_id'] = $device['device_id'];
if($device['status'] == '1') {
unset($update);
@ -105,29 +110,36 @@ while ($interface = mysql_fetch_array($interface_query)) {
echo("Interface " . $device['hostname'] . " " . $interface['ifDescr'] . " is down\n");
}
}
$rates = interface_rates ($interface);
mysql_query("UPDATE `interfaces` SET in_rate = '" . $rates['in'] . "', out_rate = '" . $rates['out'] . "' WHERE interface_id= '" . $interface['interface_id'] . "'");
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);
}
# 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);
# }
}

View File

@ -4,11 +4,12 @@
include("config.php");
include("includes/functions.php");
if(!$enable_syslog) { exit(); }
$add = 0;
$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]:%'");
@ -26,7 +27,7 @@ while($l = mysql_fetch_array($q)){
$host = $maybehost;
} elseif($perhapshost) {
$host = $perhapshost;
}
} else { `echo Failed log entry from $l[host] > /var/log/observer.log`; }
if($host) {
@ -36,13 +37,10 @@ while($l = mysql_fetch_array($q)){
$l[msg] = preg_replace("/^%(.+):\ /", "\\1||", $l[msg]);
list($l[program], $l[msg]) = explode("||", $l[msg]);
} else {
$l[msg] = preg_replace("/^" . $l[program] . ":\ /", "", $l[msg]);
}
$x = "INSERT INTO syslog (`host` , `facility` , `priority` , `level` , `tag` , `datetime` , `program` , `msg` )";
$x .= " VALUES ( '$host', '$l[facility]', '$l[priority]', '$l[level]', '$l[tag]', '$l[datetime]', '$l[program]', '$l[msg]' );";