more code cleanup (last commit for now)

git-svn-id: http://www.observium.org/svn/observer/trunk@2520 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-09-20 14:37:54 +00:00
parent f87ed09e1b
commit 9a1bee1458
71 changed files with 296 additions and 293 deletions
+24 -24
View File
@@ -1,24 +1,24 @@
Please see http://www.observium.org for up to date installation instructions.
Please also contact us through the mailing list or on IRC if you run into any issues.
-------
Some notes about how to set up your systems, which have not found their way
onto the wiki just yet:
Customer port parsing
=====================
Set your port description to:
Cust: CustomerName {CircuitDesc} (OptionalNotes) [Speed]
Transit/peering/core port parsing
=================================
Set your port description to:
Transit: whateveryoulike
Peering: whateveryoulike
Core: whateveryoulike
Please see http://www.observium.org for up to date installation instructions.
Please also contact us through the mailing list or on IRC if you run into any issues.
-------
Some notes about how to set up your systems, which have not found their way
onto the wiki just yet:
Customer port parsing
=====================
Set your port description to:
Cust: CustomerName {CircuitDesc} (OptionalNotes) [Speed]
Transit/peering/core port parsing
=================================
Set your port description to:
Transit: whateveryoulike
Peering: whateveryoulike
Core: whateveryoulike
+4 -4
View File
@@ -9,14 +9,14 @@ $config['db_pass'] = "PASSWORD";
$config['db_name'] = "observium";
### Locations
$config['install_dir'] = "/opt/observium";
$config['html_dir'] = $config['install_dir'] . "/html";
$config['rrd_dir'] = $config['install_dir'] . "/rrd";
$config['install_dir'] = "/opt/observium";
$config['html_dir'] = $config['install_dir'] . "/html";
$config['rrd_dir'] = $config['install_dir'] . "/rrd";
$config['log_file'] = $config['install_dir'] . "/observium.log";
### Thie should *only* be set if you want to *force* a particular hostname/port
### It will prevent the web interface being usable form any other hostname
#$config['base_url'] = "http://observium.company.com";
#$config['base_url'] = "http://observium.company.com";
### Enable the below to use rrdcached. be sure rrd_dir is within the rrdcached dir
### and that your web server has permission to talk to rrdcached.
+1 -1
View File
@@ -105,7 +105,7 @@ foreach (dbFetch("SELECT *, UNIX_TIMESTAMP(timestamp) AS formatted_date FROM bil
$tot_data[$i] = $out_data[$i] + $in_data[$i];
$tot_data_inv[$i] = $tot_data[$i] * -1;
if($tot_data[$i] > $max_value) { $max_value = $tot_data[$i]; }
if ($tot_data[$i] > $max_value) { $max_value = $tot_data[$i]; }
$ticks[$i] = $timestamp;
$per_data[$i] = $rate_95th / $div;
+8 -6
View File
@@ -5,7 +5,7 @@ function rrdtool_graph($graph_file, $options)
global $config, $debug;
if($debug) { echo("$options"); }
if ($debug) { echo("$options"); }
$command = $config['rrdtool'] . " -";
@@ -39,10 +39,10 @@ function rrdtool_graph($graph_file, $options)
// proc_close in order to avoid a deadlock
$return_value = proc_close($process);
if($debug)
if ($debug)
{
echo("<p>");
if($debug) { echo("graph $graph_file $options"); }
if ($debug) { echo("graph $graph_file $options"); }
echo("</p><p>");
echo "command returned $return_value\n";
echo("</p>");
@@ -66,7 +66,7 @@ function generate_url($vars, $new_vars = array())
foreach($vars as $var => $value)
{
if($value != "")
if ($value != "")
{
$url .= $var ."=".$value."/";
}
@@ -187,6 +187,7 @@ function overlib_link($url, $text, $contents, $class)
function generate_graph_popup($graph_array)
{
global $config;
## Take $graph_array and print day,week,month,year graps in overlib, hovered over graph
$graph = generate_graph_tag($graph_array);
@@ -270,6 +271,7 @@ function port_permitted($interface_id, $device_id = NULL)
function application_permitted($app_id, $device_id = NULL)
{
global $permissions;
if (is_numeric($app_id))
{
if (!$device_id) { $device_id = device_by_id_cache ($app_id); }
@@ -345,7 +347,7 @@ STATE;
function print_percentage_bar($width, $height, $percent, $left_text, $left_colour, $left_background, $right_text, $right_colour, $right_background)
{
if($percent > "100") { $size_percent = "100"; } else { $size_percent = $percent; }
if ($percent > "100") { $size_percent = "100"; } else { $size_percent = $percent; }
$output = '
<div style="font-size:11px;">
@@ -379,7 +381,7 @@ function generate_port_link($args, $text = NULL, $type = NULL)
$graph_array['legend'] = "yes";
$graph_array['height'] = "100";
$graph_array['width'] = "340";
$graph_array['to'] = $config['time']['now'];
$graph_array['to'] = $config['time']['now'];
$graph_array['from'] = $config['time']['day'];
$graph_array['id'] = $args['interface_id'];
$content .= generate_graph_tag($graph_array);
+5 -4
View File
@@ -27,7 +27,7 @@ function makeTextBlock($text, $fontfile, $fontsize, $width) {
$currentLine = 0;
foreach ($words as $word) {
$lineSize = imagettfbbox($fontsize, 0, $fontfile, $lines[$currentLine] . ' ' . $word);
if($lineSize[2] - $lineSize[0] < $width) {
if ($lineSize[2] - $lineSize[0] < $width) {
$lines[$currentLine] .= ' ' . $word;
} else {
$currentLine++;
@@ -47,6 +47,7 @@ function makeTextBlock($text, $fontfile, $fontsize, $width) {
*/
function error($code, $code_msg, $title, $msg) {
global $config;
header(sprintf("HTTP/1.0 %d %s", $code, $code_msg));
header("Pragma: no-cache");
header("Expires: Mon, 01 Jan 2008 00:00:00 CET");
@@ -197,9 +198,9 @@ if (isset($MetaGraphDefs[$type])) {
if(isset($rrd_cmd))
{
if($config['rrdcached']) { $rrd_cmd .= " --daemon ".$config['rrdcached'] . " "; }
if($_GET['from']) { $from = mres($_GET['from']); }
if($_GET['to']) { $to = mres($_GET['to']); }
if ($config['rrdcached']) { $rrd_cmd .= " --daemon ".$config['rrdcached'] . " "; }
if ($_GET['from']) { $from = mres($_GET['from']); }
if ($_GET['to']) { $to = mres($_GET['to']); }
$rrd_cmd .= " -s " . $from . " -e " . $to;
}
@@ -23,7 +23,7 @@ foreach($stats as $stat => $colour)
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = str_replace("icmp", "", $stat);
$rrd_list[$i]['rra'] = $stat;
if(strpos($stat, "Out") !== FALSE)
if (strpos($stat, "Out") !== FALSE)
{
$rrd_list[$i]['invert'] = TRUE;
}
@@ -23,7 +23,7 @@ foreach($stats as $stat => $array)
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = str_replace("icmp", "", $stat);
$rrd_list[$i]['rra'] = $stat;
if(strpos($stat, "Out") !== FALSE)
if (strpos($stat, "Out") !== FALSE)
{
$rrd_list[$i]['invert'] = TRUE;
}
@@ -20,7 +20,7 @@ foreach($stats as $stat => $array)
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = str_replace("ip", "", $stat);
$rrd_list[$i]['rra'] = $stat;
if(strpos($stat, "Out") !== FALSE)
if (strpos($stat, "Out") !== FALSE)
{
$rrd_list[$i]['invert'] = TRUE;
}
@@ -20,7 +20,7 @@ foreach($stats as $stat)
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = str_replace("snmp", "", $stat);
$rrd_list[$i]['rra'] = $stat;
if(strpos($stat, "Out") !== FALSE)
if (strpos($stat, "Out") !== FALSE)
{
$rrd_list[$i]['invert'] = TRUE;
}
@@ -15,7 +15,7 @@ foreach($stats as $stat)
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = str_replace("snmp", "", $stat);
$rrd_list[$i]['rra'] = $stat;
if(strpos($stat, "Out") !== FALSE)
if (strpos($stat, "Out") !== FALSE)
{
$rrd_list[$i]['invert'] = TRUE;
}
@@ -14,7 +14,7 @@ foreach($stats as $stat)
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = str_replace("tcp", "", $stat);
$rrd_list[$i]['rra'] = $stat;
if(strpos($stat, "Out") !== FALSE || strpos($stat, "Retrans") !== FALSE || strpos($stat, "Attempt") !== FALSE)
if (strpos($stat, "Out") !== FALSE || strpos($stat, "Retrans") !== FALSE || strpos($stat, "Attempt") !== FALSE)
{
$rrd_list[$i]['invert'] = TRUE;
}
@@ -14,7 +14,7 @@ foreach($stats as $stat)
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = str_replace("udp", "", $stat);
$rrd_list[$i]['rra'] = $stat;
if(strpos($stat, "Out") !== FALSE || strpos($stat, "Retrans") !== FALSE || strpos($stat, "Attempt") !== FALSE)
if (strpos($stat, "Out") !== FALSE || strpos($stat, "Retrans") !== FALSE || strpos($stat, "Attempt") !== FALSE)
{
$rrd_list[$i]['invert'] = TRUE;
}
+4 -4
View File
@@ -38,8 +38,8 @@ $rrd_options .= " CDEF:inbits=inoctets,8,*";
$rrd_options .= " CDEF:inbits_max=inoctets_max,8,*";
if ($config['rrdgraph_real_95th']) {
$rrd_options .= " CDEF:highbits=inoctets,outoctets,MAX,8,*";
$rrd_options .= " VDEF:95thhigh=highbits,95,PERCENT";
$rrd_options .= " CDEF:highbits=inoctets,outoctets,MAX,8,*";
$rrd_options .= " VDEF:95thhigh=highbits,95,PERCENT";
}
$rrd_options .= " VDEF:totin=inoctets,TOTAL";
@@ -67,8 +67,8 @@ $rrd_options .= " GPRINT:outbits_max:MAX:%6.2lf%s";
$rrd_options .= " GPRINT:95thout:%6.2lf%s\\\\n";
if ($config['rrdgraph_real_95th']) {
$rrd_options .= " HRULE:95thhigh#FF0000:\"Highest\"";
$rrd_options .= " GPRINT:95thhigh:\"%30.2lf%s\\n\"";
$rrd_options .= " HRULE:95thhigh#FF0000:\"Highest\"";
$rrd_options .= " GPRINT:95thhigh:\"%30.2lf%s\\n\"";
}
$rrd_options .= " GPRINT:tot:'Total %6.2lf%s'";
@@ -27,7 +27,7 @@ foreach ($rrd_list as $rrd)
$rrd_options .= " DEF:".$id."=$filename:$rra:AVERAGE";
if(!$basicrrd)
if (!$basicrrd)
{
$rrd_options .= " DEF:".$id."min=$filename:$rra:MIN";
$rrd_options .= " DEF:".$id."max=$filename:$rra:MAX";
@@ -45,7 +45,7 @@ foreach ($rrd_list as $rrd)
}
if(!$basicrrd)
if (!$basicrrd)
{
$rrd_optionsb .= " GPRINT:".$id.":LAST:%5.2lf%s GPRINT:".$id."min:MIN:%5.2lf%s";
$rrd_optionsb .= " GPRINT:".$id."max:MAX:%5.2lf%s GPRINT:".$id.":AVERAGE:'%5.2lf%s\\n'";
@@ -48,7 +48,7 @@ foreach ($rrd_list as $i => $rrd)
}
## Are our text values related to te multiplier/divisor or not?
if(isset($text_orig) && $text_orig)
if (isset($text_orig) && $text_orig)
{
$t_defname = $rrd['rra'];
} else {
@@ -5,7 +5,7 @@ if (is_numeric($id))
$acc = dbFetchRow("SELECT * FROM `mac_accounting` AS M, `ports` AS I, `devices` AS D WHERE M.ma_id = ? AND I.interface_id = M.interface_id AND I.device_id = D.device_id", array($id));
if($debug) {
if ($debug) {
echo("<pre>");
print_r($acc);
echo("</pre>");
@@ -14,13 +14,13 @@ if (is_numeric($id))
if (is_array($acc))
{
if($auth || port_permitted($acc['interface_id']))
if ($auth || port_permitted($acc['interface_id']))
{
if($debug) { echo($config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd")); }
if ($debug) { echo($config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd")); }
if(is_file($config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd")))
if (is_file($config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd")))
{
if($debug) { echo("exists"); }
if ($debug) { echo("exists"); }
$rrd_filename = $config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd");
$port = get_port_by_id($acc['interface_id']);
$device = device_by_id_cache($port['device_id']);
+1 -1
View File
@@ -48,7 +48,7 @@ if (isset($_SESSION['authenticated']) && $_SESSION['authenticated'])
</div>
</div>
<!-- ///// end of gumax-header ///// -->
<!-- ///// end of gumax-header ///// -->
+1 -1
View File
@@ -30,7 +30,7 @@ $device['os_text'] = $config['os'][$device['os']]['text'];
echo(' <tr class="'.$class.'" bgcolor="' . $bg . '" onmouseover="this.style.backgroundColor=\'#fdd\';" onmouseout="this.style.backgroundColor=\'' . $bg . '\';"
onclick="location.href=\'device/'.$device['device_id'].'/\'" style="cursor: pointer;">
<td width="300"><span style="font-size: 15px;">' . generate_device_link($device) . '</span></td>'
);
);
echo(' <td>' . $device['hardware'] . ' ' . $device['features'] . '</td>');
echo(' <td>' . $device['os_text'] . ' ' . $device['version'] . '</td>');
+1 -1
View File
@@ -36,7 +36,7 @@ echo(' <tr class="'.$class.'" bgcolor="' . $bg . '" onmouseover="this.style.bac
<td width="40" align="center" valign="middle">' . $image . '</td>
<td width="300"><span style="font-size: 15px;">' . generate_device_link($device) . '</span>
<br />' . $device['sysName'] . '</td>'
);
);
echo ('<td width="55">');
if ($port_count) { echo(' <img src="images/icons/port.png" align=absmiddle /> '.$port_count); }
@@ -7,12 +7,12 @@ function getInterfaceList(sel)
{
var deviceId = sel.options[sel.selectedIndex].value;
document.getElementById('interface_id').options.length = 0; // Empty city select box
if (deviceId.length>0){
if (deviceId.length>0) {
var index = ajax.length;
ajax[index] = new sack();
ajax[index].requestFile = '<?php echo($config['base_url']); ?>/ajax_listports.php?device_id='+deviceId; // Specifying which file to get
ajax[index].onCompletion = function(){ createInterfaces(index) }; // Specify function that will be executed after file has been found
ajax[index].onCompletion = function() { createInterfaces(index) }; // Specify function that will be executed after file has been found
ajax[index].runAJAX(); // Execute AJAX function
}
}
+2 -2
View File
@@ -223,7 +223,7 @@ if ($port['pagpGroupIfIndex'] && $port['pagpGroupIfIndex'] != $port['ifIndex'])
foreach(dbFetchRows("SELECT * FROM `ports_stack` WHERE `interface_id_low` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $higher_if)
{
if($higher_if['interface_id_high'])
if ($higher_if['interface_id_high'])
{
$this_port = get_port_by_index_cache($device['device_id'], $higher_if['interface_id_high']);
echo("$br<img src='images/16/arrow_divide.png' align=absmiddle> <strong>" . generate_port_link($this_port) . "</strong>");
@@ -233,7 +233,7 @@ foreach(dbFetchRows("SELECT * FROM `ports_stack` WHERE `interface_id_low` = ? an
foreach(dbFetchRows("SELECT * FROM `ports_stack` WHERE `interface_id_high` = ? and `device_id` = ?", array($port['ifIndex'], $device['device_id'])) as $lower_if)
{
if($lower_if['interface_id_low'])
if ($lower_if['interface_id_low'])
{
$this_port = get_port_by_index_cache($device['device_id'], $lower_if['interface_id_low']);
echo("$br<img src='images/16/arrow_join.png' align=absmiddle> <strong>" . generate_port_link($this_port) . "</strong>");
+4 -4
View File
@@ -49,7 +49,7 @@ foreach (dbFetchRows("SELECT * FROM `devices`") as $device)
</div>
<div class="col_1">
<h3>Search</h3>
<h3>Search</h3>
</div>
<div class="col_1">
@@ -98,7 +98,7 @@ if ($_SESSION['userlevel'] >= '10') {
</div>
<script class="code" type="text/javascript">
$(document).ready(function(){
$(document).ready(function() {
var data = [
['Up', <?php echo($devices['up']); ?>],
['Down', <?php echo($devices['down']); ?>],
@@ -162,7 +162,7 @@ if ($_SESSION['userlevel'] >= '10') {
</div>
<script class="code" type="text/javascript">
$(document).ready(function(){
$(document).ready(function() {
var data = [
['Up', <?php echo($services['up']); ?>],
['Down', <?php echo($services['down']); ?>],
@@ -300,7 +300,7 @@ if ($deleted_ports) { echo('<li><a href="deleted-ports/"><img src="images/16/cro
</div>
<script class="code" type="text/javascript">
$(document).ready(function(){
$(document).ready(function() {
var data = [
['Up', <?php echo($ports['up']); ?>],
['Down', <?php echo($ports['down']); ?>],
+4 -4
View File
@@ -3,12 +3,12 @@
global $config;
if($_SESSION['widescreen']) {
if(!$graph_array['height']) { $graph_array['height'] = "110"; }
if(!$graph_array['width']) { $graph_array['width'] = "215"; }
if (!$graph_array['height']) { $graph_array['height'] = "110"; }
if (!$graph_array['width']) { $graph_array['width'] = "215"; }
$periods = array('sixhour', 'day', 'week', 'month', 'year', 'twoyear');
} else {
if(!$graph_array['height']) { $graph_array['height'] = "100"; }
if(!$graph_array['width']) { $graph_array['width'] = "215"; }
if (!$graph_array['height']) { $graph_array['height'] = "100"; }
if (!$graph_array['width']) { $graph_array['width'] = "215"; }
$periods = array('day', 'week', 'month', 'year');
}
+1 -1
View File
@@ -4,7 +4,7 @@
$service_id = dbInsert(array('device_id' => $_POST['device'], 'service_ip' => $_POST['ip'], 'service_type' => $_POST['type'], 'service_desc' => $_POST['descr'], 'service_param' => $_POST['params'], 'service_ignore' => '0'), 'services');
if($service_id) {
if ($service_id) {
$message .= $message_break . "Service added (".$service_id.")!";
$message_break .= "<br />";
}
+1 -1
View File
@@ -4,7 +4,7 @@
$affected = dbDelete('services', '`service_id` = ?', array($_POST['service']));
if($affected)
if ($affected)
{
$message .= $message_break . $rows . " service deleted!";
$message_break .= "<br />";
+8 -8
View File
@@ -28,9 +28,9 @@ include("includes/functions.inc.php");
include("includes/authenticate.inc.php");
foreach($_GET as $key=>$get_var) {
if(strstr($key, "opt")) {
if (strstr($key, "opt")) {
list($name, $value) = explode("|", $get_var);
if(!isset($value)) { $value = "yes"; }
if (!isset($value)) { $value = "yes"; }
$vars[$name] = $value;
}
}
@@ -38,11 +38,11 @@ foreach($_GET as $key=>$get_var) {
$segments = explode('/', trim($_SERVER['PATH_INFO'], '/'));
foreach($segments as $pos => $segment) {
$segment = urldecode($segment);
if($pos == "0")
if ($pos == "0")
{
$vars['page'] = $segment;
} else {
if(TRUE) // do this to keep everything working whilst we fiddle
if (TRUE) // do this to keep everything working whilst we fiddle
{
if ($pos == "1")
{
@@ -70,7 +70,7 @@ foreach($segments as $pos => $segment) {
}
}
list($name, $value) = explode("=", $segment);
if($value == "" || !isset($value))
if ($value == "" || !isset($value))
{
$vars[$name] = yes;
} else {
@@ -81,7 +81,7 @@ foreach($segments as $pos => $segment) {
foreach($_POST as $name => $value)
{
# if($value == "" || !isset($value))
# if ($value == "" || !isset($value))
# {
# } else {
$vars[$name] = $value;
@@ -304,8 +304,8 @@ echo('</div>');
<script class="content_tooltips" type="text/javascript">
$(document).ready(function() { $('#content a[title]').qtip({ content: { text: false }, style: 'light' }); });
$('INPUT.auto-hint, TEXTAREA.auto-hint').focus(function(){
if($(this).val() == $(this).attr('title')){
$('INPUT.auto-hint, TEXTAREA.auto-hint').focus(function() {
if ($(this).val() == $(this).attr('title')) {
$(this).val('');
$(this).removeClass('auto-hint');
}
+5 -5
View File
@@ -73,7 +73,7 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format']))
{
$linkdone[$local_interface_id][$remote_interface_id] = TRUE;
$links++;
$links++;
if ($link['ifSpeed'] >= "10000000000")
{
@@ -94,7 +94,7 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format']))
$dst = dbFetchCell("SELECT `hostname` FROM `devices` AS D, `ports` AS I WHERE I.interface_id = ? AND D.device_id = I.device_id", array($remote_interface_id));
$dst_host = dbFetchCell("SELECT D.device_id FROM `devices` AS D, `ports` AS I WHERE I.interface_id = ? AND D.device_id = I.device_id", array($remote_interface_id));
} else {
unset($dst_host);
unset($dst_host);
$dst = $link['remote_hostname'];
}
@@ -104,8 +104,8 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format']))
$dif = ifNameDescr(dbFetchRow("SELECT * FROM ports WHERE `interface_id` = ?", array($link['remote_interface_id'])), $device);
} else {
$dif['label'] = $link['remote_port'];
$dif['interface_id'] = $link['remote_hostname'] . $link['remote_port'];
}
$dif['interface_id'] = $link['remote_hostname'] . $link['remote_port'];
}
$map .= "\"" . $sif['interface_id'] . "\" [label=\"" . $sif['label'] . "\", fontsize=12, fillcolor=lightblue URL=\"{$config['base_url']}/device/".$device['device_id']."/port/$local_interface_id/\"]\n";
if (!$ifdone[$src][$sif['interface_id']])
@@ -114,7 +114,7 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format']))
$ifdone[$src][$sif['interface_id']] = 1;
}
if($dst_host) {
if ($dst_host) {
$map .= "\"$dst\" [URL=\"{$config['base_url']}/device/$dst_host/map/\" fontsize=20 shape=box3d]\n";
} else {
$map .= "\"$dst\" [ fontsize=20 shape=box3d]\n";
+1 -1
View File
@@ -27,7 +27,7 @@ if ($_GET['query'] && $_GET['cmd'])
switch ($_GET['cmd'])
{
case 'whois':
$cmd = $config['whois'] . " $host | grep -v \%";
$cmd = $config['whois'] . " $host | grep -v \%";
break;
case 'ping':
$cmd = $config['ping'] . " -c 5 $host";
+2 -2
View File
@@ -34,8 +34,8 @@ if (bill_permitted($bill_id))
$datefrom = $day_data['0'];
$dateto = $day_data['1'];
$lastfrom = $day_data['2'];
$lastto = $day_data['3'];
$lastfrom = $day_data['2'];
$lastto = $day_data['3'];
$rate_data = getRates($bill_id,$datefrom,$dateto);
$rate_95th = $rate_data['rate_95th'];
+1 -1
View File
@@ -18,7 +18,7 @@ if ($_SESSION['userlevel'] < '10') { include("includes/error-no-perm.inc.php");
# dbDelete('bill_perms', "`user_id` = ?", array($_GET['user_id']));
# dbDelete('devices_perms', "`user_id` = ?", array($_GET['user_id']));
# dbDelete('ports_perms', "`user_id` = ?", array($_GET['user_id']));
# dbDelete('ports_perms', "`user_id` = ?", array($_GET['user_id']));
# dbDelete('users_prefs', "`user_id` = ?", array($_GET['user_id']));
# dbDelete('users', "`user_id` = ?", array($_GET['user_id']));
+2 -2
View File
@@ -125,7 +125,7 @@ if (device_permitted($vars['device']) || $check_device == $vars['device'])
if ($device_routing_count['cef']) { $routing_tabs[] = 'cef'; }
$device_routing_count['vrf'] = @dbFetchCell("SELECT COUNT(*) FROM `vrfs` WHERE `device_id` = ?", array($device['device_id']));
if($device_routing_count['vrf']) { $routing_tabs[] = 'vrf'; }
if ($device_routing_count['vrf']) { $routing_tabs[] = 'vrf'; }
if (is_array($routing_tabs))
{
@@ -253,7 +253,7 @@ if (device_permitted($vars['device']) || $check_device == $vars['device'])
echo("</ul>");
}
if(device_permitted($device['device_id']) || $check_device == $vars['device']) {
if (device_permitted($device['device_id']) || $check_device == $vars['device']) {
echo('<div class="contentstyle">');
include("pages/device/".mres(basename($tab)).".inc.php");
+20 -20
View File
@@ -2,26 +2,26 @@
global $config;
$graphs = array('mysql_command_counters' => 'Command Counters',
'mysql_connections' => 'Connections',
'mysql_files_tables' => 'Files and Tables',
'mysql_innodb_buffer_pool' => 'InnoDB Buffer Pool',
'mysql_innodb_buffer_pool_activity' => 'InnoDB Buffer Pool Activity',
'mysql_innodb_insert_buffer' => 'InnoDB Insert Buffer',
'mysql_innodb_io' => 'InnoDB IO',
'mysql_innodb_io_pending' => 'InnoDB IO Pending',
'mysql_innodb_log' => 'InnoDB Log',
'mysql_innodb_row_operations' => 'InnoDB Row Operations',
'mysql_innodb_semaphores' => 'InnoDB semaphores',
'mysql_innodb_transactions' => 'InnoDB Transactions',
'mysql_myisam_indexes' => 'MyISAM Indexes',
'mysql_network_traffic' => 'Network Traffic',
'mysql_query_cache' => 'Query Cache',
'mysql_query_cache_memory' => 'Query Cache Memory',
'mysql_select_types' => 'Select Types',
'mysql_slow_queries' => 'Slow Queries',
'mysql_sorts' => 'Sorts',
'mysql_table_locks' => 'Table Locks',
'mysql_temporary_objects' => 'Temporary Objects');
'mysql_connections' => 'Connections',
'mysql_files_tables' => 'Files and Tables',
'mysql_innodb_buffer_pool' => 'InnoDB Buffer Pool',
'mysql_innodb_buffer_pool_activity' => 'InnoDB Buffer Pool Activity',
'mysql_innodb_insert_buffer' => 'InnoDB Insert Buffer',
'mysql_innodb_io' => 'InnoDB IO',
'mysql_innodb_io_pending' => 'InnoDB IO Pending',
'mysql_innodb_log' => 'InnoDB Log',
'mysql_innodb_row_operations' => 'InnoDB Row Operations',
'mysql_innodb_semaphores' => 'InnoDB semaphores',
'mysql_innodb_transactions' => 'InnoDB Transactions',
'mysql_myisam_indexes' => 'MyISAM Indexes',
'mysql_network_traffic' => 'Network Traffic',
'mysql_query_cache' => 'Query Cache',
'mysql_query_cache_memory' => 'Query Cache Memory',
'mysql_select_types' => 'Select Types',
'mysql_slow_queries' => 'Slow Queries',
'mysql_sorts' => 'Sorts',
'mysql_table_locks' => 'Table Locks',
'mysql_temporary_objects' => 'Temporary Objects');
foreach ($graphs as $key => $text)
{
+1 -1
View File
@@ -3,7 +3,7 @@
global $config;
$graphs = array('nginx_connections' => 'nginx Connections',
'nginx_req' => 'nginx requests');
'nginx_req' => 'nginx requests');
foreach ($graphs as $key => $text)
{
+13 -13
View File
@@ -34,16 +34,16 @@ load_graph_definitions();
* @method Name of Javascript method that will be called to process data
*/
function dhtml_response_list(&$items, $method) {
header("Content-Type: text/xml");
header("Content-Type: text/xml");
print('<?xml version="1.0" encoding="utf-8" ?>'."\n");
print("<response>\n");
printf(" <method>%s</method>\n", htmlspecialchars($method));
print(" <result>\n");
foreach ($items as &$item)
printf(' <option>%s</option>'."\n", htmlspecialchars($item));
print(" </result>\n");
print("</response>");
print('<?xml version="1.0" encoding="utf-8" ?>'."\n");
print("<response>\n");
printf(" <method>%s</method>\n", htmlspecialchars($method));
print(" <result>\n");
foreach ($items as &$item)
printf(' <option>%s</option>'."\n", htmlspecialchars($item));
print(" </result>\n");
print("</response>");
}
print_optionbar_start();
@@ -91,12 +91,12 @@ print_optionbar_end();
}
echo("</div>");
$graph_array['type'] = "device_collectd";
$graph_array['id'] = $device['device_id'];
$graph_array['type'] = "device_collectd";
$graph_array['id'] = $device['device_id'];
$graph_array['c_plugin'] = $vars['plugin'];
$graph_array['c_plugin'] = $vars['plugin'];
$graph_array['c_plugin_instance'] = $instance;
$graph_array['c_type'] = $type;
$graph_array['c_type'] = $type;
$graph_array['c_type_instance'] = $tinst;
include("includes/print-quadgraphs.inc.php");
+1 -1
View File
@@ -29,7 +29,7 @@ if ($_POST['device'])
}
}
if(count($enabled)) {
if (count($enabled)) {
$updated += dbDelete('applications', "`device_id` = ? AND `app_type` NOT IN (".implode(",",$replace).")", $param);
} else {
$updated += dbDelete('applications', "`device_id` = ?", array($param));
+2 -2
View File
@@ -45,7 +45,7 @@ foreach($config['poller_modules'] as $module => $module_status)
echo('</td><td>');
if(isset($attribs['poll_'.$module]))
if (isset($attribs['poll_'.$module]))
{
if ($attribs['poll_'.$module]) {echo("<span class=green>enabled</span>");} else { echo('<span class=red>disabled</span>'); }
} else {
@@ -82,7 +82,7 @@ foreach($config['discovery_modules'] as $module => $module_status)
echo('</td><td>');
if(isset($attribs['discover_'.$module]))
if (isset($attribs['discover_'.$module]))
{
if ($attribs['discover_'.$module]) {echo("<span class=green>enabled</span>");} else { echo('<span class=red>disabled</span>'); }
} else {
+46 -46
View File
@@ -45,58 +45,58 @@ echo("<table cellpadding=3 cellspacing=0 width=100%>
?>
<script>
$(document).ready(function(){
$('#disable-toggle').click(function(event){
// invert selection on all disable buttons
event.preventDefault();
$('[name^="disabled_"]').check('toggle');
$(document).ready(function() {
$('#disable-toggle').click(function(event) {
// invert selection on all disable buttons
event.preventDefault();
$('[name^="disabled_"]').check('toggle');
});
$('#ignore-toggle').click(function(event){
// invert selection on all ignore buttons
event.preventDefault();
$('[name^="ignore_"]').check('toggle');
$('#ignore-toggle').click(function(event) {
// invert selection on all ignore buttons
event.preventDefault();
$('[name^="ignore_"]').check('toggle');
});
$('#disable-select').click(function(event){
// select all disable buttons
event.preventDefault();
$('[name^="disabled_"]').check();
$('#disable-select').click(function(event) {
// select all disable buttons
event.preventDefault();
$('[name^="disabled_"]').check();
});
$('#ignore-select').click(function(event){
// select all ignore buttons
event.preventDefault();
$('[name^="ignore_"]').check();
$('#ignore-select').click(function(event) {
// select all ignore buttons
event.preventDefault();
$('[name^="ignore_"]').check();
});
$('#down-select').click(function(event){
// select ignore buttons for all ports which are down
event.preventDefault();
$('[name^="operstatus_"]').each(function(){
var name = $(this).attr('name');
var text = $(this).text();
if (name && text == 'down') {
// get the interface number from the object name
var interface_id = name.split('_')[1];
// find its corresponding checkbox and toggle it
$('[name="ignore_' + interface_id + '"]').check();
}
});
$('#down-select').click(function(event) {
// select ignore buttons for all ports which are down
event.preventDefault();
$('[name^="operstatus_"]').each(function() {
var name = $(this).attr('name');
var text = $(this).text();
if (name && text == 'down') {
// get the interface number from the object name
var interface_id = name.split('_')[1];
// find its corresponding checkbox and toggle it
$('[name="ignore_' + interface_id + '"]').check();
}
});
});
$('#alerted-toggle').click(function(event){
// toggle ignore buttons for all ports which are in class red
event.preventDefault();
$('.red').each(function(){
var name = $(this).attr('name');
if (name) {
// get the interface number from the object name
var interface_id = name.split('_')[1];
// find its corresponding checkbox and toggle it
$('[name="ignore_' + interface_id + '"]').check('toggle');
}
});
$('#alerted-toggle').click(function(event) {
// toggle ignore buttons for all ports which are in class red
event.preventDefault();
$('.red').each(function() {
var name = $(this).attr('name');
if (name) {
// get the interface number from the object name
var interface_id = name.split('_')[1];
// find its corresponding checkbox and toggle it
$('[name="ignore_' + interface_id + '"]').check('toggle');
}
});
});
$('#form-reset').click(function(event){
// reset objects in the form to their previous values
event.preventDefault();
$('#ignoreport')[0].reset();
$('#form-reset').click(function(event) {
// reset objects in the form to their previous values
event.preventDefault();
$('#ignoreport')[0].reset();
});
});
</script>
+1 -1
View File
@@ -19,7 +19,7 @@ function printEntPhysical($ent, $level, $class)
echo("<img src='images/16/contrast.png' style='vertical-align:middle'/> ");
# FIXME /ciscosensors? doesn't exist anymore methinks? or does it?
$sensor = dbFetchRow("SELECT * FROM `sensors` WHERE `device_id` = ? AND `entPhysicalIndex` = ?", array($device['device_id'], $ent['entPhysicalIndex']));
if(count($sensor))
if (count($sensor))
{
$link = " href='device/".$device['device_id']."/health/".$sensor['sensor_class']."/' onmouseover=\"return overlib('<img src=\'graph.php?id=".$sensor['sensor_id']."&amp;type=sensor_".$sensor['sensor_class']."&amp;from=-2d&amp;to=now&amp;width=400&amp;height=150&amp;a=".$ent['entPhysical_id']."\'><img src=\'graph.php?id=".$sensor['sensor_id']."&amp;type=sensor_".$sensor['sensor_class']."&amp;from=-2w&amp;to=now&amp;width=400&amp;height=150&amp;a=".$ent['entPhysical_id']."\'>', LEFT,FGCOLOR,'#e5e5e5', BGCOLOR, '#c0c0c0', BORDER, 5, CELLPAD, 4, CAPCOLOR, '#050505');\" onmouseout=\"return nd();\"";
}
@@ -1,6 +1,6 @@
<?
if(is_file($config['rrd_dir'] . "/" . $device['hostname'] ."/ipSystemStats-ipv6.rrd")) {
if (is_file($config['rrd_dir'] . "/" . $device['hostname'] ."/ipSystemStats-ipv6.rrd")) {
$graph_title = "IPv6 IP Packet Statistics";
$graph_type = "device_ipSystemStats_v6";
include ("includes/print-device-graph.php");
@@ -11,7 +11,7 @@
}
if(is_file($config['rrd_dir'] . "/" . $device['hostname'] ."/ipSystemStats-ipv4.rrd")) {
if (is_file($config['rrd_dir'] . "/" . $device['hostname'] ."/ipSystemStats-ipv4.rrd")) {
$graph_title = "IPv4 IP Packet Statistics";
$graph_type = "device_ipSystemStats_v4";
include ("includes/print-device-graph.php");
@@ -18,7 +18,7 @@ if (count($sensors))
$graph_colour = str_replace("#", "", $row_colour);
$graph_array = array();
$graph_array = array();
$graph_array['height'] = "100";
$graph_array['width'] = "210";
$graph_array['to'] = $now;
+1 -1
View File
@@ -7,7 +7,7 @@ if ($ports['total'])
$graph_array['height'] = "100";
$graph_array['width'] = "485";
$graph_array['to'] = $now;
$graph_array['id'] = $device['device_id'];
$graph_array['id'] = $device['device_id'];
$graph_array['type'] = "device_bits";
$graph_array['from'] = $day;
$graph_array['legend'] = "no";
+2 -2
View File
@@ -25,8 +25,8 @@ echo("<div style='clear: both;'>");
if ($vars['subview'] == "top10")
{
if(!isset($vars['sort'])) { $vars['sort'] = "in"; }
if(!isset($vars['period'])) { $vars['period'] = "1day"; }
if (!isset($vars['sort'])) { $vars['sort'] = "in"; }
if (!isset($vars['period'])) { $vars['period'] = "1day"; }
$from = "-" . $vars['period'];
+1 -1
View File
@@ -3,7 +3,7 @@
### FIXME - do this in a function and/or do it in graph-realtime.php
if(!isset($vars['interval'])) {
if($device['os'] == "linux") {
if ($device['os'] == "linux") {
$vars['interval'] = "15";
} else {
$vars['interval'] = "2";
+1 -1
View File
@@ -18,7 +18,7 @@ foreach(dbFetchRows("SELECT * FROM links AS L, ports AS I WHERE I.device_id = ?
echo('<tr bgcolor="'.$bg_colour.'">');
echo('<td><span style="font-weight: bold;">'.generate_port_link($neighbour).'</span><br />'.$neighbour['ifAlias'].'</td>');
if(is_numeric($neighbour['remote_interface_id']) && $neighbour['remote_interface_id'])
if (is_numeric($neighbour['remote_interface_id']) && $neighbour['remote_interface_id'])
{
$remote_port = get_port_by_id($neighbour['remote_interface_id']);
$remote_device = device_by_id_cache($remote_port['device_id']);
+1 -1
View File
@@ -43,7 +43,7 @@ if (is_file("pages/device/routing/".mres($vars['proto']).".inc.php"))
{
if ($type != "overview")
{
if(is_file("pages/device/routing/overview/".mres($type).".inc.php")) {
if (is_file("pages/device/routing/overview/".mres($type).".inc.php")) {
$g_i++;
if (!is_integer($g_i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
+2 -2
View File
@@ -134,7 +134,7 @@ foreach (dbFetchRows("SELECT * FROM `bgpPeers` WHERE `device_id` = ? ORDER BY `b
echo(" <td width=20><span class=list-large>".$i."</span></td>
<td>" . $peeraddresslink . "<br />".generate_device_link($peer, shorthost($peer['hostname']), 'bgp/')."</td>
<td>$peer_type</td>
<td>$peer_type</td>
<td style='font-size: 10px; font-weight: bold; line-height: 10px;'>" . (isset($peer['afi']) ? $peer['afi'] : '') . "</td>
<td><strong>AS" . $peer['bgpPeerRemoteAs'] . "</strong><br />" . $peer['astext'] . "</td>
<td><strong><span style='color: $admin_col;'>" . $peer['bgpPeerAdminStatus'] . "<span><br /><span style='color: $col;'>" . $peer['bgpPeerState'] . "</span></strong></td>
@@ -177,7 +177,7 @@ foreach (dbFetchRows("SELECT * FROM `bgpPeers` WHERE `device_id` = ? ORDER BY `b
if ($vars['view'] == 'updates') { $peer['graph'] = 1; }
if($peer['graph'])
if ($peer['graph'])
{
$graph_array['height'] = "100";
$graph_array['width'] = "216";
+6 -6
View File
@@ -3,7 +3,7 @@
print_optionbar_start();
$menu_options = array('basic' => 'Basic',
'graphs' => 'Graphs',
'graphs' => 'Graphs',
);
if (!$_GET['optb']) { $_GET['optb'] = "basic"; }
@@ -48,7 +48,7 @@ foreach (dbFetchRows("SELECT * FROM `cef_switching` WHERE `device_id` = ? ORDER
$interval = $cef['updated'] - $cef['updated_prev'];
if(!$entity['entPhysicalModelName'] && $entity['entPhysicalContainedIn'])
if (!$entity['entPhysicalModelName'] && $entity['entPhysicalContainedIn'])
{
$parent_entity = dbFetchRow("SELECT * FROM `entPhysical` WHERE device_id = ? AND `entPhysicalIndex` = ?", array($device['device_id'], $entity['entPhysicalContainedIn']));
$entity_descr = $entity['entPhysicalName'] . " (" . $parent_entity['entPhysicalModelName'] .")";
@@ -77,19 +77,19 @@ foreach (dbFetchRows("SELECT * FROM `cef_switching` WHERE `device_id` = ? ORDER
echo("</td>");
echo("<td>".format_si($cef['drop']));
if($cef['drop'] > $cef['drop_prev']) { echo(" <span style='color:red;'>(".round(($cef['drop']-$cef['drop_prev'])/$interval,2)."/sec)</span>"); }
if ($cef['drop'] > $cef['drop_prev']) { echo(" <span style='color:red;'>(".round(($cef['drop']-$cef['drop_prev'])/$interval,2)."/sec)</span>"); }
echo("</td>");
echo("<td>".format_si($cef['punt']));
if($cef['punt'] > $cef['punt_prev']) { echo(" <span style='color:red;'>(".round(($cef['punt']-$cef['punt_prev'])/$interval,2)."/sec)</span>"); }
if ($cef['punt'] > $cef['punt_prev']) { echo(" <span style='color:red;'>(".round(($cef['punt']-$cef['punt_prev'])/$interval,2)."/sec)</span>"); }
echo("</td>");
echo("<td>".format_si($cef['punt2host']));
if($cef['punt2host'] > $cef['punt2host_prev']) { echo(" <span style='color:red;'>(".round(($cef['punt2host']-$cef['punt2host_prev'])/$interval,2)."/sec)</span>"); }
if ($cef['punt2host'] > $cef['punt2host_prev']) { echo(" <span style='color:red;'>(".round(($cef['punt2host']-$cef['punt2host_prev'])/$interval,2)."/sec)</span>"); }
echo("</td>");
echo("</tr>
");
if($_GET['optb'] == "graphs")
if ($_GET['optb'] == "graphs")
{
$graph_array['height'] = "100";
$graph_array['width'] = "215";
+1 -1
View File
@@ -109,7 +109,7 @@ foreach (dbFetchRows("SELECT * FROM `ospf_instances` WHERE `device_id` = ?", arr
$host = @dbFetchRow("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D WHERE A.ipv4_address = ?
AND I.interface_id = A.interface_id AND D.device_id = I.device_id", array($nbr['ospfNbrRtrId']));
if(is_array($host)) { $rtr_id = generate_dev_link($host, $nbr['ospfNbrRtrId']); } else { $rtr_id = "unknown"; }
if (is_array($host)) { $rtr_id = generate_dev_link($host, $nbr['ospfNbrRtrId']); } else { $rtr_id = "unknown"; }
echo('<tr bgcolor="'.$nbr_bg.'">');
echo(' <td width=5></td>');
+4 -4
View File
@@ -203,7 +203,7 @@ foreach ($menu_options as $option => $text)
<?php
if($vars['searchbar'] == "hide")
if ($vars['searchbar'] == "hide")
{
echo('<a href="'. generate_url($vars, array('searchbar' => '')).'">Restore Search</a>');
} else {
@@ -212,7 +212,7 @@ foreach ($menu_options as $option => $text)
echo(" | ");
if($vars['bare'] == "yes")
if ($vars['bare'] == "yes")
{
echo('<a href="'. generate_url($vars, array('bare' => '')).'">Restore Header</a>');
} else {
@@ -262,7 +262,7 @@ if($format == "graph")
} else {
echo('<table cellpadding="7" cellspacing="0" class="devicetable sortable" width="100%">');
if($subformat = "detail")
if ($subformat = "detail")
{
echo('<tr class="tablehead"><th></th><th>Device</th><th></th><th>Operating System</th><th>Platform</th><th>Uptime/Location</th></tr>');
}
@@ -274,7 +274,7 @@ if($format == "graph")
if (!$location_filter || ((get_dev_attrib($device,'override_sysLocation_bool') && get_dev_attrib($device,'override_sysLocation_string') == $location_filter)
|| $device['location'] == $location_filter))
{
if($subformat == "detail")
if ($subformat == "detail")
{
include("includes/hostbox.inc.php");
} else {
+1 -1
View File
@@ -15,7 +15,7 @@ $sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` =
} else {
$sql = mysql_query("SELECT * FROM `devices` AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND D.status = '0' AND D.ignore = '0'");
}
while ($device = mysql_fetch_assoc($sql)){
while ($device = mysql_fetch_assoc($sql)) {
generate_front_box("#ffaaaa", "<center><strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
<span style='font-size: 14px; font-weight: bold; margin: 5px; color: #c00;'>Device Down</span> <br />
+3 -3
View File
@@ -69,7 +69,7 @@ $nodes = array();
$sql = mysql_query("SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' AND A.attrib_value < '86400'");
while ($device = mysql_fetch_array($sql)){
while ($device = mysql_fetch_array($sql)) {
unset($already);
$i = 0;
while ($i <= count($nodes)) {
@@ -84,7 +84,7 @@ while ($device = mysql_fetch_array($sql)){
$sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'");
while ($device = mysql_fetch_array($sql)){
while ($device = mysql_fetch_array($sql)) {
if (device_permitted($device['device_id'])) {
echo("<div style='text-align: center; margin: 2px; border: solid 2px #d0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffbbbb;'>
<strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
@@ -157,7 +157,7 @@ if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $c
}
echo("
<div style='clear: both;'>$errorboxes</div> <div style='margin: 0px; clear: both;'>
<div style='clear: both;'>$errorboxes</div> <div style='margin: 0px; clear: both;'>
<h3>Recent Syslog Messages</h3>
");
+6 -6
View File
@@ -28,7 +28,7 @@ while ($device = mysql_fetch_assoc($sql))
}
$sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'");
while ($device = mysql_fetch_assoc($sql)){
while ($device = mysql_fetch_assoc($sql)) {
echo("<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffbbbb; margin: 4px;'>
<center><strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
@@ -39,7 +39,7 @@ while ($device = mysql_fetch_assoc($sql)){
}
$sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
while ($interface = mysql_fetch_assoc($sql)){
while ($interface = mysql_fetch_assoc($sql)) {
echo("<div style='border: solid 2px #D0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>
<center><strong>".generate_device_link($interface, shorthost($interface['hostname']))."</strong><br />
@@ -51,7 +51,7 @@ while ($interface = mysql_fetch_assoc($sql)){
}
$sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'");
while ($service = mysql_fetch_assoc($sql)){
while ($service = mysql_fetch_assoc($sql)) {
echo("<div style='border: solid 2px #D0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>
<center><strong>".generate_device_link($service, shorthost($service['hostname']))."</strong><br />
@@ -63,7 +63,7 @@ while ($service = mysql_fetch_assoc($sql)){
}
$sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerState != 'established' AND B.device_id = D.device_id");
while ($peer = mysql_fetch_assoc($sql)){
while ($peer = mysql_fetch_assoc($sql)) {
echo("<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ffddaa; margin: 4px;'>
<center><strong>".generate_device_link($peer, shorthost($peer['hostname']))."</strong><br />
@@ -77,7 +77,7 @@ while ($peer = mysql_fetch_assoc($sql)){
if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0)
{
$sql = mysql_query("SELECT * FROM `devices` AS D, devices_attribs AS A WHERE A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value < '" . $config['uptime_warning'] . "'");
while ($device = mysql_fetch_assoc($sql)){
while ($device = mysql_fetch_assoc($sql)) {
echo("<div style='border: solid 2px #d0D0D0; float: left; padding: 5px; width: 120px; height: 90px; background: #ddffdd; margin: 4px;'>
<center><strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
@@ -89,7 +89,7 @@ if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $c
echo("
<div style='clear: both;'>$errorboxes</div> <div style='margin: 4px; clear: both;'>
<div style='clear: both;'>$errorboxes</div> <div style='margin: 4px; clear: both;'>
<h3>Recent Syslog Messages</h3>
+7 -7
View File
@@ -14,7 +14,7 @@ if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $c
$sql = mysql_query("SELECT * FROM `devices` AS D, `devices_attribs` AS A WHERE D.status = '1' AND A.device_id = D.device_id AND A.attrib_type = 'uptime' AND A.attrib_value > '0' " . $uptimesql);
while ($device = mysql_fetch_assoc($sql)){
while ($device = mysql_fetch_assoc($sql)) {
unset($already);
$i = 0;
while ($i <= count($nodes)) {
@@ -29,7 +29,7 @@ while ($device = mysql_fetch_assoc($sql)){
$sql = mysql_query("SELECT * FROM `devices` WHERE `status` = '0' AND `ignore` = '0'");
while ($device = mysql_fetch_assoc($sql)){
while ($device = mysql_fetch_assoc($sql)) {
if (device_permitted($device['device_id'])) {
echo("<div style='text-align: center; margin: 2px; border: solid 2px #d0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffbbbb;'>
<strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
@@ -42,7 +42,7 @@ while ($device = mysql_fetch_assoc($sql)){
if ($config['warn']['ifdown']) {
$sql = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id AND ifOperStatus = 'down' AND ifAdminStatus = 'up' AND D.ignore = '0' AND I.ignore = '0'");
while ($interface = mysql_fetch_assoc($sql)){
while ($interface = mysql_fetch_assoc($sql)) {
if (port_permitted($interface['interface_id'])) {
echo("<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>
<strong>".generate_device_link($interface, shorthost($interface['hostname']))."</strong><br />
@@ -56,7 +56,7 @@ while ($interface = mysql_fetch_assoc($sql)){
}
$sql = mysql_query("SELECT * FROM `services` AS S, `devices` AS D WHERE S.device_id = D.device_id AND service_status = 'down' AND D.ignore = '0' AND S.service_ignore = '0'");
while ($service = mysql_fetch_assoc($sql)){
while ($service = mysql_fetch_assoc($sql)) {
if (device_permitted($service['device_id'])) {
echo("<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>
<strong>".generate_device_link($service, shorthost($service['hostname']))."</strong><br />
@@ -68,7 +68,7 @@ while ($service = mysql_fetch_assoc($sql)){
}
$sql = mysql_query("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerAdminStatus = 'start' AND bgpPeerState != 'established' AND B.device_id = D.device_id");
while ($peer = mysql_fetch_assoc($sql)){
while ($peer = mysql_fetch_assoc($sql)) {
if (device_permitted($peer['device_id'])) {
echo("<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ffddaa;'>
<strong>".generate_device_link($peer, shorthost($peer['hostname']))."</strong><br />
@@ -82,7 +82,7 @@ while ($peer = mysql_fetch_assoc($sql)){
if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0)
{
$sql = mysql_query("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < '" . $config['uptime_warning'] . "' AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'");
while ($device = mysql_fetch_assoc($sql)){
while ($device = mysql_fetch_assoc($sql)) {
if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime") {
echo("<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ddffdd;'>
<strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
@@ -96,7 +96,7 @@ if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $c
echo("
<div style='clear: both;'>$errorboxes</div> <div style='margin: 0px; clear: both;'>
<div style='clear: both;'>$errorboxes</div> <div style='margin: 0px; clear: both;'>
<h3>Recent Syslog Messages</h3>
+2 -2
View File
@@ -81,7 +81,7 @@ foreach (dbFetchRows("SELECT * FROM `devices` AS D, bgpPeers AS B WHERE bgpPeerA
if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $config['uptime_warning'] > 0)
{
foreach (dbFetchRows("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < ? AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'", array($config['uptime_warning'])) as $device){
foreach (dbFetchRows("SELECT * FROM devices_attribs AS A, `devices` AS D WHERE A.attrib_value < ? AND A.attrib_type = 'uptime' AND A.device_id = D.device_id AND ignore = '0' AND disabled = '0'", array($config['uptime_warning'])) as $device) {
if (device_permitted($device['device_id']) && $device['attrib_value'] < $config['uptime_warning'] && $device['attrib_type'] == "uptime") {
echo("<div style='text-align: center; margin: 2px; border: solid 2px #D0D0D0; float: left; margin-right: 2px; padding: 3px; width: 118px; height: 85px; background: #ddffdd;'>
<strong>".generate_device_link($device, shorthost($device['hostname']))."</strong><br />
@@ -95,7 +95,7 @@ if (filter_var($config['uptime_warning'], FILTER_VALIDATE_FLOAT) !== FALSE && $c
echo("
<div style='clear: both;'>$errorboxes</div> <div style='margin: 0px; clear: both;'>
<div style='clear: both;'>$errorboxes</div> <div style='margin: 0px; clear: both;'>
<h3>Recent Syslog Messages</h3>
+4 -4
View File
@@ -16,8 +16,8 @@ echo('<table cellspacing="0" cellpadding="6" width="100%">');
echo('<tr class=tablehead>
<th width="280">Device</th>
<th width="180">Sensor</th>
<th></th>
<th></th>
<th></th>
<th></th>
<th width="100">Current</th>
<th width="250">Range limit</th>
<th>Notes</th>
@@ -47,8 +47,8 @@ foreach (dbFetchRows($sql, $param) as $sensor)
echo("<tr bgcolor=$row_colour>
<td class=list-bold>" . generate_device_link($sensor) . "</td>
<td>$sensor_popup</td>
<td width=100>$sensor_minigraph</td>
<td width=50>$alert</td>
<td width=100>$sensor_minigraph</td>
<td width=50>$alert</td>
<td style='text-align: center; font-weight: bold;'>" . $sensor['sensor_current'] . $unit . "</td>
<td style='text-align: center'>" . round($sensor['sensor_limit_low'],2) . $unit . " - " . round($sensor['sensor_limit'],2) . $unit . "</td>
<td>" . (isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '') . "</td>
+1 -1
View File
@@ -38,7 +38,7 @@
?>
</select>
</label>
<input type="text" size=24 name="device_string" id="device_string" value="<?php if($_POST['device_string']) { echo($_POST['device_string']); } ?>" />
<input type="text" size=24 name="device_string" id="device_string" value="<?php if ($_POST['device_string']) { echo($_POST['device_string']); } ?>" />
<input style type=submit class=submit value=Search>
<?php
+2 -2
View File
@@ -59,12 +59,12 @@ foreach (getlocations() as $location)
<td width="100">' . $alert . '</td>
<td width="100">' . $num . ' devices</td>
<td width="100">' . $net . ' network</td>
<td width="100">' . $srv . ' servers</td>
<td width="100">' . $srv . ' servers</td>
<td width="100">' . $fwl . ' firewalls</td>
</tr>
');
if($vars['view'] == "traffic")
if ($vars['view'] == "traffic")
{
echo('<tr bgcolor="' . $bg . '"><td colspan=6>');
+5 -5
View File
@@ -11,7 +11,7 @@ else
echo('<span style="font-weight: bold;">BGP</span> &#187; ');
if(!$_GET['optb']) { $_GET['optb'] = "all"; }
if (!$_GET['optb']) { $_GET['optb'] = "all"; }
if ($_GET['opta'] == "bgp" && $_GET['optb'] == "all") { echo("<span class='pagemenu-selected'>"); }
echo('<a href="routing/bgp/all/'.$graphs.'/">All</a>');
@@ -38,7 +38,7 @@ else
echo('<div style="float: right;">');
if(!$_GET['optc']) { $_GET['optc'] = "nographs"; }
if (!$_GET['optc']) { $_GET['optc'] = "nographs"; }
if ($_GET['opta'] == "bgp" && $_GET['optc'] == "nographs") { echo("<span class='pagemenu-selected'>"); }
echo('<a href="routing/bgp/'.$_GET['optb'].'/nographs/">No Graphs</a>');
@@ -148,9 +148,9 @@ else
echo(" <td></td>
<td width=150>" . $localaddresslink . "<br />".generate_device_link($peer, shorthost($peer['hostname']), 'routing/bgp/')."</td>
<td width=30><b>&#187;</b></td>
<td width=30><b>&#187;</b></td>
<td width=150>" . $peeraddresslink . "</td>
<td width=50><b>$peer_type</b></td>
<td width=50><b>$peer_type</b></td>
<td width=50>".$peer['afi']."</td>
<td><strong>AS" . $peer['bgpPeerRemoteAs'] . "</strong><br />" . $peer['astext'] . "</td>
<td><strong><span style='color: $admin_col;'>" . $peer['bgpPeerAdminStatus'] . "</span><br /><span style='color: $col;'>" . $peer['bgpPeerState'] . "</span></strong></td>
@@ -191,7 +191,7 @@ else
if ($_GET['optc'] == 'updates') { $peer['graph'] = 1; }
if($peer['graph'])
if ($peer['graph'])
{
$graph_array['height'] = "100";
$graph_array['width'] = "220";
+2 -2
View File
@@ -2,9 +2,9 @@
foreach ($datas as $type)
{
if($type != "overview")
if ($type != "overview")
{
if(is_file("pages/routing/overview/".mres($type).".inc.php")) {
if (is_file("pages/routing/overview/".mres($type).".inc.php")) {
$g_i++;
if (!is_integer($g_i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
+2 -2
View File
@@ -2,8 +2,8 @@
if ($_SESSION['userlevel'] >= '5') {
if(!isset($_GET['optb'])) { $_GET['optb'] = "all"; }
if(!isset($_GET['optc'])) { $_GET['optc'] = "basic"; }
if (!isset($_GET['optb'])) { $_GET['optb'] = "all"; }
if (!isset($_GET['optc'])) { $_GET['optc'] = "basic"; }
print_optionbar_start();
+2 -2
View File
@@ -19,8 +19,8 @@ foreach (dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hos
<td width="200" style="padding: 1px;">
<select name="interface" id="interface">
<option value="">All Interfaces</option>
<option value="Loopback%" <?php if ($_POST['interface'] == "Loopback%"){ echo("selected"); } ?> >Loopbacks</option>
<option value="Vlan%" <?php if ($_POST['interface'] == "Vlan%"){ echo("selected"); } ?> >VLANs</option>
<option value="Loopback%" <?php if ($_POST['interface'] == "Loopback%") { echo("selected"); } ?> >Loopbacks</option>
<option value="Vlan%" <?php if ($_POST['interface'] == "Vlan%") { echo("selected"); } ?> >VLANs</option>
</select>
</td>
<td>
+2 -2
View File
@@ -19,8 +19,8 @@ foreach (dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hos
<td width="200">
<select name="interface" id="interface">
<option value="">All Interfaces</option>
<option value="Loopback%" <?php if ($_POST['interface'] == "Loopback%"){ echo("selected"); } ?> >Loopbacks</option>
<option value="Vlan%" <?php if ($_POST['interface'] == "Vlan%"){ echo("selected"); } ?> >VLANs</option>
<option value="Loopback%" <?php if ($_POST['interface'] == "Loopback%") { echo("selected"); } ?> >Loopbacks</option>
<option value="Vlan%" <?php if ($_POST['interface'] == "Vlan%") { echo("selected"); } ?> >VLANs</option>
</select>
</td>
<td>
+2 -2
View File
@@ -19,8 +19,8 @@ foreach (dbFetchRows("SELECT `device_id`,`hostname` FROM `devices` GROUP BY `hos
<td width="200" style="padding: 1px;">
<select name="interface" id="interface">
<option value="">All Interfaces</option>
<option value="Loopback%" <?php if ($_POST['interface'] == "Loopback%"){ echo("selected"); } ?> >Loopbacks</option>
<option value="Vlan%" <?php if ($_POST['interface'] == "Vlan%"){ echo("selected"); } ?> >VLANs</option>
<option value="Loopback%" <?php if ($_POST['interface'] == "Loopback%") { echo("selected"); } ?> >Loopbacks</option>
<option value="Vlan%" <?php if ($_POST['interface'] == "Vlan%") { echo("selected"); } ?> >VLANs</option>
</select>
</td>
<td>
+4 -4
View File
@@ -17,7 +17,7 @@
foreach (dbFetchRows("SELECT `program` FROM `syslog` GROUP BY `program` ORDER BY `program`") as $data)
{
echo("<option value='".$data['program']."'");
if ($data['program'] == $_POST['program']) { echo("selected"); }
if ($data['program'] == $_POST['program']) { echo("selected"); }
echo(">".$data['program']."</option>");
}
?>
@@ -32,7 +32,7 @@
{
echo("<option value='".$data['device_id']."'");
if ($data['device_id'] == $_POST['device']) { echo("selected"); }
if ($data['device_id'] == $_POST['device']) { echo("selected"); }
echo(">".$data['hostname']."</option>");
}
@@ -69,7 +69,7 @@ if (is_numeric($_POST['device']))
if ($_SESSION['userlevel'] >= '5')
{
$sql = "SELECT *, DATE_FORMAT(timestamp, '%Y-%m-%d %T') AS date from syslog AS S";
if(count($array))
if (count($array))
{
$sql .= " WHERE 1 ".$where;
}
@@ -77,7 +77,7 @@ if ($_SESSION['userlevel'] >= '5')
} else {
$sql = "SELECT *, DATE_FORMAT(timestamp, '%Y-%m-%d %T') AS date from syslog AS S, devices_perms AS P";
$sql .= "WHERE S.device_id = P.device_id AND P.user_id = ?";
if(count($array))
if (count($array))
{
$sql .= " WHERE 1 ".$where;
}
+2 -2
View File
@@ -201,9 +201,9 @@ function device_by_id_cache($device_id, $refresh = '0')
function truncate($substring, $max = 50, $rep = '...')
{
if (strlen($substring) < 1){ $string = $rep; } else { $string = $substring; }
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($string) > $max) { return substr_replace($string, $rep, $leave); } else { return $string; }
}
function mres($string)
+23 -23
View File
@@ -27,7 +27,7 @@ function dbQuery($sql, $parameters = array()) {
$fullSql = dbMakeQuery($sql, $parameters);
if ($debug) { echo(" SQL[".$fullSql."] "); }
/*
if($this->logFile)
if ($this->logFile)
$time_start = microtime(true);
*/
@@ -35,13 +35,13 @@ function dbQuery($sql, $parameters = array()) {
$result = mysql_query($fullSql); // sets $this->result
/*
if($this->logFile) {
if ($this->logFile) {
$time_end = microtime(true);
fwrite($this->logFile, date('Y-m-d H:i:s') . "\n" . $fullSql . "\n" . number_format($time_end - $time_start, 8) . " seconds\n\n");
}
*/
if($result === false && (error_reporting() & 1)) {
if ($result === false && (error_reporting() & 1)) {
// aye. this gets triggers on duplicate Contact insert
//trigger_error('QDB - Error in query: ' . $fullSql . ' : ' . mysql_error(), E_USER_WARNING);
}
@@ -61,7 +61,7 @@ function dbInsert($data, $table) {
// it allows the method to work for those that would rather it (or expect it to)
// follow closer with SQL convention:
// insert into the TABLE this DATA
if(is_string($data) && is_array($table)) {
if (is_string($data) && is_array($table)) {
$tmp = $data;
$data = $table;
$table = $tmp;
@@ -73,12 +73,12 @@ function dbInsert($data, $table) {
$time_start = microtime(true);
dbBeginTransaction();
$result = dbQuery($sql, $data);
if($result) {
if ($result) {
$id = mysql_insert_id();
dbCommitTransaction();
#return $id;
} else {
if($table != 'Contact') {
if ($table != 'Contact') {
trigger_error('QDB - Insert failed.', E_USER_WARNING);
}
dbRollbackTransaction();
@@ -108,7 +108,7 @@ function dbUpdate($data, $table, $where = null, $parameters = array()) {
// it allows the method to work for those that would rather it (or expect it to)
// follow closer with SQL convention:
// update the TABLE with this DATA
if(is_string($data) && is_array($table)) {
if (is_string($data) && is_array($table)) {
$tmp = $data;
$data = $table;
$table = $tmp;
@@ -123,13 +123,13 @@ function dbUpdate($data, $table, $where = null, $parameters = array()) {
}
$sql = substr($sql, 0, -1); // strip off last comma
if($where) {
if ($where) {
$sql .= ' WHERE ' . $where;
$data = array_merge($data, $parameters);
}
$time_start = microtime(true);
if(dbQuery($sql, $data)) {
if (dbQuery($sql, $data)) {
$return = mysql_affected_rows();
} else {
#echo("$fullSql");
@@ -146,10 +146,10 @@ function dbUpdate($data, $table, $where = null, $parameters = array()) {
function dbDelete($table, $where = null, $parameters = array()) {
$sql = 'DELETE FROM `' . $table.'`';
if($where) {
if ($where) {
$sql .= ' WHERE ' . $where;
}
if(dbQuery($sql, $parameters)) {
if (dbQuery($sql, $parameters)) {
return mysql_affected_rows();
} else {
return false;
@@ -166,7 +166,7 @@ function dbFetchRows($sql, $parameters = array()) {
$time_start = microtime(true);
$result = dbQuery($sql, $parameters);
if(mysql_num_rows($result) > 0) {
if (mysql_num_rows($result) > 0) {
$rows = array();
while ($row = mysql_fetch_assoc($result)) {
$rows[] = $row;
@@ -194,7 +194,7 @@ function dbFetch($sql, $parameters = array()) {
/*
// for now, don't do the iterator thing
$result = dbQuery($sql, $parameters);
if($result) {
if ($result) {
// return new iterator
return new dbIterator($result);
} else {
@@ -212,7 +212,7 @@ function dbFetchRow($sql = null, $parameters = array()) {
$time_start = microtime(true);
$result = dbQuery($sql, $parameters);
if($result) {
if ($result) {
$row = mysql_fetch_assoc($result);
mysql_free_result($result);
$time_end = microtime(true);
@@ -236,7 +236,7 @@ function dbFetchCell($sql, $parameters = array()) {
$time_start = microtime(true);
$row = dbFetchRow($sql, $parameters);
if($row) {
if ($row) {
return array_shift($row); // shift first field off first row
}
$time_end = microtime(true);
@@ -276,7 +276,7 @@ function dbFetchKeyValue($sql, $parameters = array()) {
$data = array();
foreach(dbFetch($sql, $parameters) as $row) {
$key = array_shift($row);
if(sizeof($row) == 1) { // if there were only 2 fields in the result
if (sizeof($row) == 1) { // if there were only 2 fields in the result
// use the second for the value
$data[ $key ] = array_shift($row);
} else { // if more than 2 fields were fetched
@@ -301,7 +301,7 @@ function dbMakeQuery($sql, $parameters) {
$questionParams = array();
$namedParams = array();
foreach($parameters as $key => $value) {
if(is_numeric($key)) {
if (is_numeric($key)) {
$questionParams[] = $value;
} else {
$namedParams[ ':' . $key ] = $value;
@@ -320,9 +320,9 @@ function dbMakeQuery($sql, $parameters) {
$query .= $result[ $i ];
$j = $i+1;
if(array_key_exists($j, $result)) {
if (array_key_exists($j, $result)) {
$test = $result[ $j ];
if($test == '?') {
if ($test == '?') {
$query .= array_shift($questionParams);
} else {
$query .= $namedParams[ $test ];
@@ -341,7 +341,7 @@ function dbPrepareData($data) {
// don't quote or esc if value is an array, we treat it
// as a "decorator" that tells us not to escape the
// value contained in the array
if(is_array($value) && !is_object($value)) {
if (is_array($value) && !is_object($value)) {
$escape = false;
$value = array_shift($value);
}
@@ -349,7 +349,7 @@ function dbPrepareData($data) {
// that are aliases, or part of other tables through joins
//if(!in_array($key, $columns)) // skip invalid fields
// continue;
if($escape) {
if ($escape) {
$values[$key] = "'" . mysql_real_escape_string($value) . "'";
} else
$values[$key] = $value;
@@ -365,7 +365,7 @@ function dbPrepareData($data) {
function dbPlaceHolders($values) {
$data = array();
foreach($values as $key => $value) {
if(is_numeric($key))
if (is_numeric($key))
$data[] = '?';
else
$data[] = ':' . $key;
@@ -410,7 +410,7 @@ class dbIterator implements Iterator {
public function next() {
$this->i++;
$a = mysql_data_seek($this->result, $this->i);
if($a === false) {
if ($a === false) {
$this->i = 0;
}
return $a;
+1 -1
View File
@@ -71,7 +71,7 @@ if (is_array($oids))
if (is_numeric($entry['entPhySensorPrecision']) && $entry['entPhySensorPrecision'] > "0") { $divisor = $divisor . str_pad('', $entry['entPhySensorPrecision'], "0"); }
$current = $current * $multiplier / $divisor;
if ($type == "temperature") { if ($current > "200"){ $thisisnotbullshit = FALSE; } $descr = preg_replace("/[T|t]emperature[|s]/", "", $descr); }
if ($type == "temperature") { if ($current > "200") { $thisisnotbullshit = FALSE; } $descr = preg_replace("/[T|t]emperature[|s]/", "", $descr); }
#echo($descr . "|" . $index . "|" .$current . "|" . $multiplier . "|" . $divisor ."|" . $entry['entPhySensorScale'] . "|" . $entry['entPhySensorPrecision'] . "\n");
+4 -4
View File
@@ -134,14 +134,14 @@ function getImage($host)
{
$image = '<img src="'.$config['base_url'].'/images/os/'.$config['os'][$type]['icon'].'.gif" />';
} else {
if (file_exists($config['html_dir'] . "/images/os/$type" . ".png")){ $image = '<img src="'.$config['base_url'].'/images/os/'.$type.'.png" />';
} elseif (file_exists($config['html_dir'] . "/images/os/$type" . ".gif")){ $image = '<img src="'.$config['base_url'].'/images/os/'.$type.'.gif" />'; }
if (file_exists($config['html_dir'] . "/images/os/$type" . ".png")) { $image = '<img src="'.$config['base_url'].'/images/os/'.$type.'.png" />';
} elseif (file_exists($config['html_dir'] . "/images/os/$type" . ".gif")) { $image = '<img src="'.$config['base_url'].'/images/os/'.$type.'.gif" />'; }
if ($type == "linux")
{
$features = strtolower(trim($data['features']));
list($distro) = explode(" ", $features);
if (file_exists($config['html_dir'] . "/images/os/$distro" . ".png")){ $image = '<img src="'.$config['base_url'].'/images/os/'.$distro.'.png" />';
} elseif (file_exists($config['html_dir'] . "/images/os/$distro" . ".gif")){ $image = '<img src="'.$config['base_url'].'/images/os/'.$distro.'.gif" />'; }
if (file_exists($config['html_dir'] . "/images/os/$distro" . ".png")) { $image = '<img src="'.$config['base_url'].'/images/os/'.$distro.'.png" />';
} elseif (file_exists($config['html_dir'] . "/images/os/$distro" . ".gif")) { $image = '<img src="'.$config['base_url'].'/images/os/'.$distro.'.gif" />'; }
}
}
+1 -1
View File
@@ -8,7 +8,7 @@
#Cisco Systems, Inc. WS-C4003 Cisco Catalyst Operating System Software, Version 6.4(13) Copyright (c) 1995-2004 by Cisco Systems, Inc.
#Cisco Systems, Inc. WS-C4006 Cisco Catalyst Operating System Software, Version 6.3(9) Copyright (c) 1995-2002 by Cisco Systems, Inc.
if (strstr($ciscomodel, "OID")){ unset($ciscomodel); }
if (strstr($ciscomodel, "OID")) { unset($ciscomodel); }
if (!strstr($ciscomodel, " ") && strlen($ciscomodel) >= '3')
{
+2 -2
View File
@@ -640,7 +640,7 @@ function snmp_cache_port_oids($oids, $port, $device, $array, $mib=0)
$x=0;
$values = explode("\n", $data);
#echo("Caching: ifIndex $port\n");
foreach ($oids as $oid){
foreach ($oids as $oid) {
if (!strstr($values[$x], "at this OID"))
{
$array[$port][$oid] = $values[$x];
@@ -686,7 +686,7 @@ function snmp_cache_portIfIndex($device, $array)
{
$entry = str_replace("CISCO-STACK-MIB::portIfIndex.", "", $entry);
list($slotport, $ifIndex) = explode(" ", $entry);
if ($slotport && $ifIndex){
if ($slotport && $ifIndex) {
$array[$ifIndex]['portIfIndex'] = $slotport;
$array[$slotport]['ifIndex'] = $ifIndex;
}
+15 -15
View File
@@ -6,11 +6,11 @@
# $device_id_ip = @dbFetchCell("SELECT device_id FROM ipv4_addresses AS A, ports AS I WHERE A.ipv4_address = '" . $entry['host']."' AND I.interface_id = A.interface_id");
function get_cache($host, $value){
function get_cache($host, $value) {
global $dev_cache;
if (!isset($dev_cache[$host][$value])){
switch($value){
if (!isset($dev_cache[$host][$value])) {
switch($value) {
case 'device_id':
//Try by hostname
$dev_cache[$host]['device_id'] = dbFetchCell('SELECT `device_id` FROM devices WHERE `hostname` = ? OR `sysName` = ?', array($host, $host));
@@ -39,7 +39,7 @@ function process_syslog ($entry, $update) {
global $dev_cache;
foreach($config['syslog_filter'] as $bi)
if (strpos($entry['msg'], $bi) !== FALSE){
if (strpos($entry['msg'], $bi) !== FALSE) {
print_r($entry);
echo('D-'.$bi);
return $entry;
@@ -49,9 +49,9 @@ function process_syslog ($entry, $update) {
if ($entry['device_id']) {
$os = get_cache($entry['host'], 'os');
if (in_array($os, array('ios', 'iosxe', 'catos'))){
if (in_array($os, array('ios', 'iosxe', 'catos'))) {
$matches = array();
# if (preg_match('#%(?P<program>.*):( ?)(?P<msg>.*)#', $entry['msg'], $matches)){
# if (preg_match('#%(?P<program>.*):( ?)(?P<msg>.*)#', $entry['msg'], $matches)) {
# $entry['msg'] = $matches['msg'];
# $entry['program'] = $matches['program'];
# }
@@ -86,29 +86,29 @@ function process_syslog ($entry, $update) {
if (!$entry['msg']) { $entry['msg'] = $entry['program']; unset ($entry['program']); }
} elseif($os == 'linux' and get_cache($entry['host'], 'version') == 'Point'){
} elseif($os == 'linux' and get_cache($entry['host'], 'version') == 'Point') {
//Cisco WAP200 and similar
$matches = array();
if (preg_match('#Log: \[(?P<program>.*)\] - (?P<msg>.*)#', $entry['msg'], $matches)){
if (preg_match('#Log: \[(?P<program>.*)\] - (?P<msg>.*)#', $entry['msg'], $matches)) {
$entry['msg'] = $matches['msg'];
$entry['program'] = $matches['program'];
}
unset($matches);
} elseif($os == 'linux'){
} elseif($os == 'linux') {
$matches = array();
//User_CommonName/123.213.132.231:39872 VERIFY OK: depth=1, /C=PL/ST=Malopolska/O=VLO/CN=v-lo.krakow.pl/emailAddress=root@v-lo.krakow.pl
if ($entry['facility'] == 'daemon' and preg_match('#/([0-9]{1,3}\.){3}[0-9]{1,3}:[0-9]{4,} ([A-Z]([A-Za-z])+( ?)){2,}:#', $entry['msg'])){
if ($entry['facility'] == 'daemon' and preg_match('#/([0-9]{1,3}\.) {3}[0-9]{1,3}:[0-9]{4,} ([A-Z]([A-Za-z])+( ?)) {2,}:#', $entry['msg'])) {
$entry['program'] = 'OpenVPN';
}
//pop3-login: Login: user=<username>, method=PLAIN, rip=123.213.132.231, lip=123.213.132.231, TLS
//POP3(username): Disconnected: Logged out top=0/0, retr=0/0, del=0/1, size=2802
elseif($entry['facility'] == 'mail' and preg_match('#^(((pop3|imap)\-login)|((POP3|IMAP)\(.*\))):', $entry['msg'])){
elseif($entry['facility'] == 'mail' and preg_match('#^(((pop3|imap)\-login)|((POP3|IMAP)\(.*\))):', $entry['msg'])) {
$entry['program'] = 'Dovecot';
}
//pam_krb5(sshd:auth): authentication failure; logname=root uid=0 euid=0 tty=ssh ruser= rhost=123.213.132.231
//pam_krb5[sshd:auth]: authentication failure; logname=root uid=0 euid=0 tty=ssh ruser= rhost=123.213.132.231
elseif(preg_match('#^(?P<program>(.*((\(|\[).*(\)|\])))):(?P<msg>.*)$#', $entry['msg'], $matches)){
elseif(preg_match('#^(?P<program>(.*((\(|\[).*(\)|\])))):(?P<msg>.*)$#', $entry['msg'], $matches)) {
$entry['msg'] = $matches['msg'];
$entry['program'] = $matches['program'];
}
@@ -117,18 +117,18 @@ function process_syslog ($entry, $update) {
//pam_krb5: authentication failure; logname=root uid=0 euid=0 tty=ssh ruser= rhost=123.213.132.231
## Disabled because broke this:
//diskio.c: don't know how to handle 10 request
#elseif($pos = strpos($entry['msg'], ';') or $pos = strpos($entry['msg'], ':')){
#elseif($pos = strpos($entry['msg'], ';') or $pos = strpos($entry['msg'], ':')) {
# $entry['program'] = substr($entry['msg'], 0, $pos);
# $entry['msg'] = substr($entry['msg'], $pos+1);
#}
//fallback, better than nothing...
elseif(empty($entry['program']) and !empty($entry['facility'])){
elseif(empty($entry['program']) and !empty($entry['facility'])) {
$entry['program'] = $entry['facility'];
}
unset($matches);
}
if (!isset($entry['program'])){
if (!isset($entry['program'])) {
$entry['program'] = $entry['msg'];
unset($entry['msg']);
}