mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
remove dead map.php code, rename some .inc to .inc.php files, general trailing space cleanup part 1, some reindent. No expected functionality change whatsoever ;)
git-svn-id: http://www.observium.org/svn/observer/trunk@1824 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
2
README
2
README
@@ -18,7 +18,7 @@ Please see COPYING for usage requirements and restrictions.
|
||||
Introduction
|
||||
------------
|
||||
|
||||
Observium is an auto-discovering network monitoring system.
|
||||
Observium is an auto-discovering network monitoring system.
|
||||
|
||||
It's designed to be an easily-navigable interface to the health of your network.
|
||||
|
||||
|
||||
@@ -3,57 +3,66 @@
|
||||
include("includes/defaults.inc.php");
|
||||
include("config.php");
|
||||
include("includes/functions.php");
|
||||
|
||||
|
||||
$sql = "SELECT * FROM devices AS D, services AS S WHERE S.device_id = D.device_id ORDER by D.device_id DESC";
|
||||
$query = mysql_query($sql);
|
||||
while ($service = mysql_fetch_array($query)) {
|
||||
while ($service = mysql_fetch_array($query))
|
||||
{
|
||||
if ($service['status'] = "1")
|
||||
{
|
||||
unset($check, $service_status, $time, $status);
|
||||
$service_status = $service['service_status'];
|
||||
$service_type = strtolower($service['service_type']);
|
||||
$service_param = $service['service_param'];
|
||||
$checker_script = $config['install_dir'] . "/includes/services/" . $service_type . "/check.inc";
|
||||
|
||||
if($service['status'] = "1") {
|
||||
unset($check, $service_status, $time, $status);
|
||||
$service_status = $service['service_status'];
|
||||
$service_type = strtolower($service['service_type']);
|
||||
$service_param = $service['service_param'];
|
||||
$checker_script = $config['install_dir'] . "/includes/services/" . $service_type . "/check.inc";
|
||||
if(is_file($checker_script)) {
|
||||
include($checker_script);
|
||||
} else {
|
||||
$status = "2";
|
||||
$check = "Error : Script not found ($checker_script)";
|
||||
}
|
||||
if($service_status != $status) {
|
||||
$updated = ", `service_changed` = '" . time() . "' ";
|
||||
if($service['sysContact']) { $email = $service['sysContact']; } else { $email = $config['email_default']; }
|
||||
if($status == "1") {
|
||||
if (is_file($checker_script))
|
||||
{
|
||||
include($checker_script);
|
||||
}
|
||||
else
|
||||
{
|
||||
$status = "2";
|
||||
$check = "Error : Script not found ($checker_script)";
|
||||
}
|
||||
|
||||
if ($service_status != $status)
|
||||
{
|
||||
$updated = ", `service_changed` = '" . time() . "' ";
|
||||
if ($service['sysContact']) { $email = $service['sysContact']; } else { $email = $config['email_default']; }
|
||||
if ($status == "1")
|
||||
{
|
||||
$msg = "Service Up: " . $service['service_type'] . " on " . $service['hostname'];
|
||||
$msg .= " at " . date($config['timestamp_format']);
|
||||
notify($device, "Service Up: " . $service['service_type'] . " on " . $service['hostname'], $msg);
|
||||
} elseif ($status == "0") {
|
||||
$msg = "Service Down: " . $service['service_type'] . " on " . $service['hostname'];
|
||||
}
|
||||
elseif ($status == "0")
|
||||
{
|
||||
$msg = "Service Down: " . $service['service_type'] . " on " . $service['hostname'];
|
||||
$msg .= " at " . date($config['timestamp_format']);
|
||||
notify($device, "Service Down: " . $service['service_type'] . " on " . $service['hostname'], $msg);
|
||||
}
|
||||
}
|
||||
} else { unset($updated); }
|
||||
|
||||
$update_sql = "UPDATE `services` SET `service_status` = '$status', `service_message` = '" . addslashes($check) . "', `service_checked` = '" . time() . "' $updated WHERE `service_id` = '" . $service['service_id']. "'";
|
||||
mysql_query($update_sql);
|
||||
} else {
|
||||
$status = "0";
|
||||
}
|
||||
|
||||
} else { unset($updated); }
|
||||
$update_sql = "UPDATE `services` SET `service_status` = '$status', `service_message` = '" . addslashes($check) . "', `service_checked` = '" . time() . "' $updated WHERE `service_id` = '" . $service['service_id']. "'";
|
||||
mysql_query($update_sql);
|
||||
} else {
|
||||
$status = "0";
|
||||
}
|
||||
|
||||
|
||||
$rrd = $config['rrd_dir'] . "/" . $service['hostname'] . "/" . safename("service-" . $service['service_type'] . "-" . $service['service_id'] . ".rrd");
|
||||
|
||||
if (!is_file($rrd)) {
|
||||
$create = $config['rrdtool'] . " create $rrd \
|
||||
--step 300 \
|
||||
if (!is_file($rrd))
|
||||
{
|
||||
rrdtool_create($rrd,"--step 300 \
|
||||
DS:status:GAUGE:600:0:1 \
|
||||
RRA:AVERAGE:0.5:1:1200 \
|
||||
RRA:AVERAGE:0.5:12:2400";
|
||||
shell_exec($create);
|
||||
RRA:AVERAGE:0.5:12:2400");
|
||||
}
|
||||
|
||||
if($status == "1" || $status == "0") {
|
||||
if ($status == "1" || $status == "0")
|
||||
{
|
||||
rrdtool_update($rrd,"N:".$status);
|
||||
}
|
||||
}
|
||||
} # while
|
||||
?>
|
||||
|
||||
@@ -4,18 +4,18 @@ function authenticate($username,$password)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if(isset($_SERVER['REMOTE_USER']))
|
||||
if(isset($_SERVER['REMOTE_USER']))
|
||||
{
|
||||
$_SESSION['username'] = mres($_SERVER['REMOTE_USER']);
|
||||
|
||||
|
||||
$sql = "SELECT username FROM `users` WHERE `username`='".$_SESSION['username'] . "'";;
|
||||
$query = mysql_query($sql);
|
||||
$row = @mysql_fetch_array($query);
|
||||
if($row['username'] && $row['username'] == $_SESSION['username'])
|
||||
if($row['username'] && $row['username'] == $_SESSION['username'])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
$_SESSION['username'] = $config['http_auth_guest'];
|
||||
return 1;
|
||||
@@ -33,19 +33,19 @@ function changepassword($username,$newpassword)
|
||||
{
|
||||
# Not supported
|
||||
}
|
||||
|
||||
|
||||
function auth_usermanagement()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
function adduser($username, $password, $level, $email = "", $realname = "")
|
||||
{
|
||||
mysql_query("INSERT INTO `users` (`username`,`password`,`level`, `email`, `realname`) VALUES ('".mres($username)."',MD5('".mres($password)."'),'".mres($level)."','".mres($email)."','".mres($realname)."')");
|
||||
|
||||
|
||||
return mysql_affected_rows();
|
||||
}
|
||||
|
||||
|
||||
function user_exists($username)
|
||||
{
|
||||
return mysql_result(mysql_query("SELECT * FROM users WHERE username = '".mres($username)."'"),0);
|
||||
|
||||
@@ -58,12 +58,12 @@ function adduser($username, $password, $level, $email = "", $realname = "")
|
||||
# Not supported
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
function user_exists($username)
|
||||
{
|
||||
return 0; # FIXME to be implemented
|
||||
}
|
||||
|
||||
|
||||
function get_userlevel($username)
|
||||
{
|
||||
# FIXME should come from LDAP
|
||||
|
||||
@@ -6,7 +6,7 @@ function authenticate($username,$password)
|
||||
$sql = "SELECT username FROM `users` WHERE `username`='".$username."' AND `password`='".$encrypted."'";
|
||||
$query = mysql_query($sql);
|
||||
$row = @mysql_fetch_array($query);
|
||||
if($row['username'] && $row['username'] == $username)
|
||||
if($row['username'] && $row['username'] == $username)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -29,11 +29,11 @@ function auth_usermanagement()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
function adduser($username, $password, $level, $email = "", $realname = "")
|
||||
{
|
||||
mysql_query("INSERT INTO `users` (`username`,`password`,`level`, `email`, `realname`) VALUES ('".mres($username)."',MD5('".mres($password)."'),'".mres($level)."','".mres($email)."','".mres($realname)."')");
|
||||
|
||||
|
||||
return mysql_affected_rows();
|
||||
}
|
||||
|
||||
@@ -41,19 +41,19 @@ function user_exists($username)
|
||||
{
|
||||
return mysql_result(mysql_query("SELECT * FROM users WHERE username = '".mres($username)."'"),0);
|
||||
}
|
||||
|
||||
|
||||
function get_userlevel($username)
|
||||
{
|
||||
$sql = "SELECT level FROM `users` WHERE `username`='".mres($username)."'";
|
||||
$row = mysql_fetch_array(mysql_query($sql));
|
||||
return $row['level'];
|
||||
}
|
||||
|
||||
|
||||
function get_userid($username)
|
||||
{
|
||||
$sql = "SELECT user_id FROM `users` WHERE `username`='".mres($username)."'";
|
||||
$row = mysql_fetch_array(mysql_query($sql));
|
||||
return $row['user_id'];
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -5,31 +5,40 @@
|
||||
$device = device_by_id_cache($id);
|
||||
|
||||
$query = mysql_query("SELECT * FROM `ports` WHERE `device_id` = '".$id."'");
|
||||
while($int = mysql_fetch_assoc($query)) {
|
||||
while ($int = mysql_fetch_assoc($query))
|
||||
{
|
||||
$ignore = 0;
|
||||
if(is_array($config['device_traffic_iftype'])) {
|
||||
foreach($config['device_traffic_iftype'] as $iftype) {
|
||||
if (preg_match($iftype ."i", $int['ifType'])) {
|
||||
if (is_array($config['device_traffic_iftype']))
|
||||
{
|
||||
foreach ($config['device_traffic_iftype'] as $iftype)
|
||||
{
|
||||
if (preg_match($iftype ."i", $int['ifType']))
|
||||
{
|
||||
$ignore = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(is_array($config['device_traffic_descr'])) {
|
||||
foreach($config['device_traffic_descr'] as $ifdescr) {
|
||||
if (preg_match($ifdescr."i", $int['ifDescr']) || preg_match($ifdescr."i", $int['ifName']) || preg_match($ifdescr."i", $int['portName'])) {
|
||||
if (is_array($config['device_traffic_descr']))
|
||||
{
|
||||
foreach ($config['device_traffic_descr'] as $ifdescr)
|
||||
{
|
||||
if (preg_match($ifdescr."i", $int['ifDescr']) || preg_match($ifdescr."i", $int['ifName']) || preg_match($ifdescr."i", $int['portName']))
|
||||
{
|
||||
$ignore = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(is_file($config['rrd_dir'] . "/" . $device['hostname'] . "/port-" . safename($int['ifIndex'] . ".rrd")) && $ignore != 1) {
|
||||
if (is_file($config['rrd_dir'] . "/" . $device['hostname'] . "/port-" . safename($int['ifIndex'] . ".rrd")) && $ignore != 1)
|
||||
{
|
||||
$rrd_filenames[] = $config['rrd_dir'] . "/" . $device['hostname'] . "/port-" . safename($int['ifIndex'] . ".rrd");
|
||||
}
|
||||
|
||||
unset($ignore);
|
||||
}
|
||||
|
||||
$rra_in = "INOCTETS";
|
||||
$rra_out = "OUTOCTETS";
|
||||
$rra_out = "OUTOCTETS";
|
||||
|
||||
$colour_line_in = "006600";
|
||||
$colour_line_out = "000099";
|
||||
@@ -38,4 +47,4 @@ $colour_area_out = "C3D9FF";
|
||||
|
||||
include ("includes/graphs/generic_multi_bits.inc.php");
|
||||
|
||||
?>
|
||||
?>
|
||||
@@ -8,37 +8,37 @@ $rrd_options .= " -l 0 -E ";
|
||||
$iter = "1";
|
||||
$sql = mysql_query("SELECT * FROM sensors WHERE sensor_class='current' AND device_id = '$id'");
|
||||
$rrd_options .= " COMMENT:' Cur Min Max\\n'";
|
||||
while($current = mysql_fetch_array($sql))
|
||||
while($current = mysql_fetch_array($sql))
|
||||
{
|
||||
switch ($iter)
|
||||
{
|
||||
case "1":
|
||||
$colour= "CC0000";
|
||||
break;
|
||||
$colour= "CC0000";
|
||||
break;
|
||||
case "2":
|
||||
$colour= "008C00";
|
||||
break;
|
||||
$colour= "008C00";
|
||||
break;
|
||||
case "3":
|
||||
$colour= "4096EE";
|
||||
break;
|
||||
$colour= "4096EE";
|
||||
break;
|
||||
case "4":
|
||||
$colour= "73880A";
|
||||
$colour= "73880A";
|
||||
break;
|
||||
case "5":
|
||||
$colour= "D01F3C";
|
||||
$colour= "D01F3C";
|
||||
break;
|
||||
case "6":
|
||||
$colour= "36393D";
|
||||
break;
|
||||
case "7":
|
||||
$colour= "36393D";
|
||||
break;
|
||||
case "7":
|
||||
default:
|
||||
$colour= "FF0084";
|
||||
$colour= "FF0084";
|
||||
unset($iter);
|
||||
break;
|
||||
}
|
||||
|
||||
$hostname = gethostbyid($current['device_id']);
|
||||
|
||||
|
||||
$descr = substr(str_pad($current['sensor_descr'], 15),0,15);
|
||||
$rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("current-" . $current['sensor_descr'] . ".rrd");
|
||||
|
||||
|
||||
@@ -9,31 +9,31 @@ $rrd_options .= " -l 0 -E ";
|
||||
$iter = "1";
|
||||
$sql = mysql_query("SELECT * FROM sensors WHERE sensor_class='fanspeed' AND device_id = '$id'");
|
||||
$rrd_options .= " COMMENT:'RPM Cur Min Max\\n'";
|
||||
while($fanspeed = mysql_fetch_array($sql))
|
||||
while($fanspeed = mysql_fetch_array($sql))
|
||||
{
|
||||
switch ($iter)
|
||||
{
|
||||
case "1":
|
||||
$colour= "CC0000";
|
||||
break;
|
||||
$colour= "CC0000";
|
||||
break;
|
||||
case "2":
|
||||
$colour= "008C00";
|
||||
break;
|
||||
$colour= "008C00";
|
||||
break;
|
||||
case "3":
|
||||
$colour= "4096EE";
|
||||
break;
|
||||
$colour= "4096EE";
|
||||
break;
|
||||
case "4":
|
||||
$colour= "73880A";
|
||||
$colour= "73880A";
|
||||
break;
|
||||
case "5":
|
||||
$colour= "D01F3C";
|
||||
$colour= "D01F3C";
|
||||
break;
|
||||
case "6":
|
||||
$colour= "36393D";
|
||||
break;
|
||||
case "7":
|
||||
$colour= "36393D";
|
||||
break;
|
||||
case "7":
|
||||
default:
|
||||
$colour= "FF0084";
|
||||
$colour= "FF0084";
|
||||
unset($iter);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -8,37 +8,37 @@ $rrd_options .= " -l 0 -E ";
|
||||
$iter = "1";
|
||||
$sql = mysql_query("SELECT * FROM sensors WHERE sensor_class='freq' AND device_id = '$id'");
|
||||
$rrd_options .= " COMMENT:' Cur Min Max\\n'";
|
||||
while($frequency = mysql_fetch_array($sql))
|
||||
while($frequency = mysql_fetch_array($sql))
|
||||
{
|
||||
switch ($iter)
|
||||
{
|
||||
case "1":
|
||||
$colour= "CC0000";
|
||||
break;
|
||||
$colour= "CC0000";
|
||||
break;
|
||||
case "2":
|
||||
$colour= "008C00";
|
||||
break;
|
||||
$colour= "008C00";
|
||||
break;
|
||||
case "3":
|
||||
$colour= "4096EE";
|
||||
break;
|
||||
$colour= "4096EE";
|
||||
break;
|
||||
case "4":
|
||||
$colour= "73880A";
|
||||
$colour= "73880A";
|
||||
break;
|
||||
case "5":
|
||||
$colour= "D01F3C";
|
||||
$colour= "D01F3C";
|
||||
break;
|
||||
case "6":
|
||||
$colour= "36393D";
|
||||
break;
|
||||
case "7":
|
||||
$colour= "36393D";
|
||||
break;
|
||||
case "7":
|
||||
default:
|
||||
$colour= "FF0084";
|
||||
$colour= "FF0084";
|
||||
unset($iter);
|
||||
break;
|
||||
}
|
||||
|
||||
$hostname = gethostbyid($frequency['device_id']);
|
||||
|
||||
|
||||
$descr = substr(str_pad($frequency['sensor_descr'], 15),0,15);
|
||||
$rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("freq-" . $frequency['sensor_descr'] . ".rrd");
|
||||
$sensor_id = $frequency['sensor_id'];
|
||||
|
||||
@@ -8,35 +8,35 @@ $rrd_options .= " -l 0 -E ";
|
||||
$iter = "1";
|
||||
$sql = mysql_query("SELECT * FROM sensors WHERE sensor_class='humidity' AND device_id = '$id' ORDER BY sensor_index");
|
||||
$rrd_options .= " COMMENT:' Cur Min Max\\n'";
|
||||
while($humidity = mysql_fetch_array($sql))
|
||||
while($humidity = mysql_fetch_array($sql))
|
||||
{
|
||||
switch ($iter)
|
||||
{
|
||||
case "1":
|
||||
$colour= "CC0000";
|
||||
break;
|
||||
$colour= "CC0000";
|
||||
break;
|
||||
case "2":
|
||||
$colour= "008C00";
|
||||
break;
|
||||
$colour= "008C00";
|
||||
break;
|
||||
case "3":
|
||||
$colour= "4096EE";
|
||||
break;
|
||||
$colour= "4096EE";
|
||||
break;
|
||||
case "4":
|
||||
$colour= "73880A";
|
||||
$colour= "73880A";
|
||||
break;
|
||||
case "5":
|
||||
$colour= "D01F3C";
|
||||
$colour= "D01F3C";
|
||||
break;
|
||||
case "6":
|
||||
$colour= "36393D";
|
||||
break;
|
||||
case "7":
|
||||
$colour= "36393D";
|
||||
break;
|
||||
case "7":
|
||||
default:
|
||||
$colour= "FF0084";
|
||||
$colour= "FF0084";
|
||||
unset($iter);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$humidity['sensor_descr_fixed'] = substr(str_pad($humidity['sensor_descr'], 22),0,22);
|
||||
$humidityrrd = $config['rrd_dir'] . "/".$device['hostname']."/".safename("humidity-" . safename($humidity['sensor_type']."-".$humidity['sensor_index']) . ".rrd");
|
||||
$rrd_options .= " DEF:sensor" . $humidity['sensor_id'] . "=$humidityrrd:sensor:AVERAGE ";
|
||||
|
||||
@@ -9,35 +9,35 @@ $rrd_options .= " -l 0 -E ";
|
||||
$iter = "1";
|
||||
$sql = mysql_query("SELECT * FROM sensors WHERE sensor_class='temperature' AND device_id = '$id' ORDER BY sensor_index");
|
||||
$rrd_options .= " COMMENT:'".str_pad('',$descr_len)." Cur Min Max\\n'";
|
||||
while($temperature = mysql_fetch_array($sql))
|
||||
while($temperature = mysql_fetch_array($sql))
|
||||
{
|
||||
switch ($iter)
|
||||
{
|
||||
case "1":
|
||||
$colour= "CC0000";
|
||||
break;
|
||||
$colour= "CC0000";
|
||||
break;
|
||||
case "2":
|
||||
$colour= "008C00";
|
||||
break;
|
||||
$colour= "008C00";
|
||||
break;
|
||||
case "3":
|
||||
$colour= "4096EE";
|
||||
break;
|
||||
$colour= "4096EE";
|
||||
break;
|
||||
case "4":
|
||||
$colour= "73880A";
|
||||
$colour= "73880A";
|
||||
break;
|
||||
case "5":
|
||||
$colour= "D01F3C";
|
||||
$colour= "D01F3C";
|
||||
break;
|
||||
case "6":
|
||||
$colour= "36393D";
|
||||
break;
|
||||
case "7":
|
||||
$colour= "36393D";
|
||||
break;
|
||||
case "7":
|
||||
default:
|
||||
$colour= "FF0084";
|
||||
$colour= "FF0084";
|
||||
unset($iter);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$temperature['sensor_descr_fixed'] = substr(str_pad($temperature['sensor_descr'], $descr_len),0,$descr_len);
|
||||
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/temperature-" . safename($temperature['sensor_type']."-".$temperature['sensor_index']) . ".rrd";
|
||||
$rrd_options .= " DEF:sensor" . $temperature['sensor_id'] . "=$rrd_file:sensor:AVERAGE ";
|
||||
|
||||
@@ -8,41 +8,42 @@ $rrd_options .= " -l 0 -E ";
|
||||
$iter = "1";
|
||||
$sql = mysql_query("SELECT * FROM toner where device_id = '$id'");
|
||||
$rrd_options .= " COMMENT:'Toner level Cur Min Max\\n'";
|
||||
while($toner = mysql_fetch_array($sql))
|
||||
while($toner = mysql_fetch_array($sql))
|
||||
{
|
||||
switch ($iter)
|
||||
{
|
||||
case "1":
|
||||
$colour= "000000";
|
||||
break;
|
||||
$colour= "000000";
|
||||
break;
|
||||
case "2":
|
||||
$colour= "008C00";
|
||||
break;
|
||||
$colour= "008C00";
|
||||
break;
|
||||
case "3":
|
||||
$colour= "4096EE";
|
||||
break;
|
||||
$colour= "4096EE";
|
||||
break;
|
||||
case "4":
|
||||
$colour= "73880A";
|
||||
$colour= "73880A";
|
||||
break;
|
||||
case "5":
|
||||
$colour= "D01F3C";
|
||||
$colour= "D01F3C";
|
||||
break;
|
||||
case "6":
|
||||
$colour= "36393D";
|
||||
break;
|
||||
case "7":
|
||||
$colour= "36393D";
|
||||
break;
|
||||
case "7":
|
||||
default:
|
||||
$colour= "FF0000";
|
||||
$colour= "FF0000";
|
||||
unset($iter);
|
||||
break;
|
||||
}
|
||||
|
||||
if (stripos($toner['toner_descr'],"cyan" ) !== false || substr($toner['toner_descr'],-1) == 'C') { $colour = "55D6D3"; }
|
||||
if (stripos($toner['toner_descr'],"magenta") !== false || substr($toner['toner_descr'],-1) == 'M') { $colour = "F24AC8"; }
|
||||
if (stripos($toner['toner_descr'],"yellow" ) !== false || substr($toner['toner_descr'],-1) == 'Y') { $colour = "FFF200"; }
|
||||
if (stripos($toner['toner_descr'],"black" ) !== false || substr($toner['toner_descr'],-1) == 'K') { $colour = "000000"; }
|
||||
|
||||
|
||||
$hostname = gethostbyid($toner['device_id']);
|
||||
|
||||
|
||||
$descr = substr(str_pad($toner['toner_descr'], 16),0,16);
|
||||
$rrd_filename = $config['rrd_dir'] . "/".$device['hostname']."/" . safename("toner-" . $toner['toner_descr'] . ".rrd");
|
||||
$toner_id = $toner['toner_id'];
|
||||
@@ -56,5 +57,4 @@ while($toner = mysql_fetch_array($sql))
|
||||
$iter++;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -10,36 +10,36 @@ $rrd_options .= " COMMENT:'".str_pad('',$descr_len)." Cur Min Max\\
|
||||
|
||||
$iter = "1";
|
||||
$sql = mysql_query("SELECT * FROM sensors WHERE sensor_class='voltage' AND device_id = '$id'");
|
||||
while($sensor = mysql_fetch_array($sql))
|
||||
while($sensor = mysql_fetch_array($sql))
|
||||
{
|
||||
switch ($iter)
|
||||
{
|
||||
case "1":
|
||||
$colour= "CC0000";
|
||||
break;
|
||||
$colour= "CC0000";
|
||||
break;
|
||||
case "2":
|
||||
$colour= "008C00";
|
||||
break;
|
||||
$colour= "008C00";
|
||||
break;
|
||||
case "3":
|
||||
$colour= "4096EE";
|
||||
break;
|
||||
$colour= "4096EE";
|
||||
break;
|
||||
case "4":
|
||||
$colour= "73880A";
|
||||
$colour= "73880A";
|
||||
break;
|
||||
case "5":
|
||||
$colour= "D01F3C";
|
||||
$colour= "D01F3C";
|
||||
break;
|
||||
case "6":
|
||||
$colour= "36393D";
|
||||
break;
|
||||
case "7":
|
||||
$colour= "36393D";
|
||||
break;
|
||||
case "7":
|
||||
default:
|
||||
$colour= "FF0084";
|
||||
$colour= "FF0084";
|
||||
unset($iter);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], $descr_len),0,$descr_len);
|
||||
$sensor['sensor_descr_fixed'] = str_replace(':','\:',str_replace('\*','*',$sensor['sensor_descr_fixed']));
|
||||
|
||||
|
||||
@@ -1,54 +1,60 @@
|
||||
<?php
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
include("includes/graphs/common.inc.php");
|
||||
|
||||
$units_descr = substr(str_pad($units_descr, 18),0,18);
|
||||
$units_descr = substr(str_pad($units_descr, 18),0,18);
|
||||
|
||||
$i = 0;
|
||||
$rrd_options .= " COMMENT:'$units_descr Current Average Maximum\\n'";
|
||||
if(!$nototal) {$rrd_options .= " COMMENT:' Tot'";}
|
||||
$rrd_options .= " COMMENT:'\\n'";
|
||||
$i = 0;
|
||||
$rrd_options .= " COMMENT:'$units_descr Current Average Maximum\\n'";
|
||||
if(!$nototal) {$rrd_options .= " COMMENT:' Tot'";}
|
||||
$rrd_options .= " COMMENT:'\\n'";
|
||||
|
||||
|
||||
foreach($rrd_list as $rrd)
|
||||
{
|
||||
if(!$config['graph_colours'][$colours_in][$iter] || !$config['graph_colours'][$colours_out][$iter]) { $iter = 0; }
|
||||
|
||||
foreach($rrd_list as $rrd) {
|
||||
if(!$config['graph_colours'][$colours_in][$iter] || !$config['graph_colours'][$colours_out][$iter]) { $iter = 0; }
|
||||
$colour_in=$config['graph_colours'][$colours_in][$iter];
|
||||
$colour_out=$config['graph_colours'][$colours_out][$iter];
|
||||
|
||||
$colour_in=$config['graph_colours'][$colours_in][$iter];
|
||||
$colour_out=$config['graph_colours'][$colours_out][$iter];
|
||||
if($rrd['colour_area_in']) { $colour_in = $rrd['colour_area_in']; }
|
||||
if($rrd['colour_area_out']) {$colour_out = $rrd['colour_area_out']; }
|
||||
|
||||
if($rrd['colour_area_in']) { $colour_in = $rrd['colour_area_in']; }
|
||||
if($rrd['colour_area_out']) {$colour_out = $rrd['colour_area_out']; }
|
||||
|
||||
$rrd_options .= " DEF:in".$i."=".$rrd['filename'].":".$rrd['rra_in'].":AVERAGE ";
|
||||
$rrd_options .= " DEF:out".$i."=".$rrd['filename'].":".$rrd['rra_out'].":AVERAGE ";
|
||||
$rrd_options .= " CDEF:inB".$i."=in".$i.",$multiplier,* ";
|
||||
$rrd_options .= " CDEF:outB".$i."=out".$i.",$multiplier,*";
|
||||
$rrd_options .= " CDEF:outB".$i."_neg=outB".$i.",-1,*";
|
||||
$rrd_options .= " CDEF:octets".$i."=inB".$i.",outB".$i.",+";
|
||||
if(!$args['nototal']) {
|
||||
$rrd_options .= " VDEF:totin".$i."=inB".$i.",TOTAL";
|
||||
$rrd_options .= " VDEF:totout".$i."=outB".$i.",TOTAL";
|
||||
$rrd_options .= " VDEF:tot".$i."=octets".$i.",TOTAL";
|
||||
}
|
||||
if($i) {$stack="STACK";}
|
||||
$rrd_options .= " AREA:inB".$i."#" . $colour_in . ":'" . substr(str_pad($rrd['descr'], 10),0,10) . "In ':$stack";
|
||||
$rrd_options .= " GPRINT:inB".$i.":LAST:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:inB".$i.":AVERAGE:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:inB".$i.":MAX:%6.2lf%s";
|
||||
|
||||
if(!$nototal) { $rrd_options .= " GPRINT:totin".$i.":%6.2lf%s$total_units"; }
|
||||
$rrd_options .= " COMMENT:'\\n'";
|
||||
$rrd_optionsb .= " AREA:outB".$i."_neg#" . $colour_out . "::$stack";
|
||||
$rrd_options .= " HRULE:999999999999999#" . $colour_out . ":'" . substr(str_pad('', 10),0,10) . "Out':";
|
||||
$rrd_options .= " GPRINT:outB".$i.":LAST:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:outB".$i.":AVERAGE:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:outB".$i.":MAX:%6.2lf%s";
|
||||
if(!$nototal) { $rrd_options .= " GPRINT:totout".$i.":%6.2lf%s$total_unit"; }
|
||||
$rrd_options .= " COMMENT:'\\n'";
|
||||
$i++; $iter++;
|
||||
$rrd_options .= " DEF:in".$i."=".$rrd['filename'].":".$rrd['rra_in'].":AVERAGE ";
|
||||
$rrd_options .= " DEF:out".$i."=".$rrd['filename'].":".$rrd['rra_out'].":AVERAGE ";
|
||||
$rrd_options .= " CDEF:inB".$i."=in".$i.",$multiplier,* ";
|
||||
$rrd_options .= " CDEF:outB".$i."=out".$i.",$multiplier,*";
|
||||
$rrd_options .= " CDEF:outB".$i."_neg=outB".$i.",-1,*";
|
||||
$rrd_options .= " CDEF:octets".$i."=inB".$i.",outB".$i.",+";
|
||||
if(!$args['nototal'])
|
||||
{
|
||||
$rrd_options .= " VDEF:totin".$i."=inB".$i.",TOTAL";
|
||||
$rrd_options .= " VDEF:totout".$i."=outB".$i.",TOTAL";
|
||||
$rrd_options .= " VDEF:tot".$i."=octets".$i.",TOTAL";
|
||||
}
|
||||
$rrd_options .= $rrd_optionsb;
|
||||
$rrd_options .= " HRULE:0#999999";
|
||||
|
||||
if($i) {$stack="STACK";}
|
||||
|
||||
$rrd_options .= " AREA:inB".$i."#" . $colour_in . ":'" . substr(str_pad($rrd['descr'], 10),0,10) . "In ':$stack";
|
||||
$rrd_options .= " GPRINT:inB".$i.":LAST:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:inB".$i.":AVERAGE:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:inB".$i.":MAX:%6.2lf%s";
|
||||
|
||||
if(!$nototal) { $rrd_options .= " GPRINT:totin".$i.":%6.2lf%s$total_units"; }
|
||||
|
||||
$rrd_options .= " COMMENT:'\\n'";
|
||||
$rrd_optionsb .= " AREA:outB".$i."_neg#" . $colour_out . "::$stack";
|
||||
$rrd_options .= " HRULE:999999999999999#" . $colour_out . ":'" . substr(str_pad('', 10),0,10) . "Out':";
|
||||
$rrd_options .= " GPRINT:outB".$i.":LAST:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:outB".$i.":AVERAGE:%6.2lf%s";
|
||||
$rrd_options .= " GPRINT:outB".$i.":MAX:%6.2lf%s";
|
||||
|
||||
if(!$nototal) { $rrd_options .= " GPRINT:totout".$i.":%6.2lf%s$total_unit"; }
|
||||
|
||||
$rrd_options .= " COMMENT:'\\n'";
|
||||
$i++; $iter++;
|
||||
}
|
||||
|
||||
$rrd_options .= $rrd_optionsb;
|
||||
$rrd_options .= " HRULE:0#999999";
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,22 +1,32 @@
|
||||
<?php
|
||||
|
||||
$iftype = fixiftype($interface[ifType]);
|
||||
$iftype = fixiftype($interface[ifType]);
|
||||
|
||||
echo("<p class=interface-header>$inf</p>");
|
||||
if($ifalias && $ifalias != "") { echo("<span class=box-desc>$ifalias</span><br />"); }
|
||||
if($iftype && $iftype != "") { echo("<span class=box-desc>$iftype</span> ");
|
||||
if($mac && $mac != "") { echo("<span class=box-desc>$mac</span><br />");
|
||||
} else { echo("<br />"); }
|
||||
echo("<p class=interface-header>$inf</p>");
|
||||
|
||||
if (isset($ifalias) && $ifalias != "") { echo('<span class="box-desc">'.$ifalias.'</span><br />'); }
|
||||
if (isset($iftype) && $iftype != "")
|
||||
{
|
||||
echo('<span class="box-desc">'.$iftype.'</span> ');
|
||||
if ($mac && $mac != "")
|
||||
{
|
||||
echo("<span class=box-desc>$mac</span><br />");
|
||||
}
|
||||
|
||||
if($interface[ifType] != "softwareLoopback") {
|
||||
if($speed == '0') { $speed = "0bps"; }
|
||||
echo("<span class=box-desc>$speed");
|
||||
if($interface[ifDuplex] != unknown) { echo(" / $interface[ifDuplex]-duplex"); }
|
||||
if($interface[ifMtu] && $interface[ifMtu] != "") { echo(" / $interface[ifMtu]MTU</span>"); }
|
||||
echo("</span>");
|
||||
else
|
||||
{
|
||||
echo("<br />");
|
||||
}
|
||||
}
|
||||
|
||||
echo("<span class=box-desc><b>$status</b></span>");
|
||||
if ($interface[ifType] != "softwareLoopback")
|
||||
{
|
||||
if ($speed == '0') { $speed = "0bps"; }
|
||||
echo('<span class="box-desc">'.$speed);
|
||||
if ($interface[ifDuplex] != unknown) { echo(" / $interface[ifDuplex]-duplex"); }
|
||||
if ($interface[ifMtu] && $interface[ifMtu] != "") { echo(" / $interface[ifMtu]MTU</span>"); }
|
||||
echo('</span>');
|
||||
}
|
||||
|
||||
echo('<span class="box-desc"><b>'.$status.'</b></span>');
|
||||
|
||||
?>
|
||||
|
||||
@@ -20,7 +20,7 @@ if (isset($config['enable_bgp']) && $config['enable_bgp'])
|
||||
if ($this_alert) {
|
||||
$device_alerts++;
|
||||
$device_alert_sql .= " OR `device_id` = '" . $device['device_id'] . "'";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -272,7 +272,7 @@ echo(' <li><hr /></li>
|
||||
<?php if ($_SESSION['userlevel'] >= '10') {
|
||||
echo('
|
||||
<li><hr width="140" /></li>');
|
||||
|
||||
|
||||
if (auth_usermanagement())
|
||||
{
|
||||
echo('
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
if(!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
|
||||
if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
|
||||
|
||||
echo("<tr bgcolor='$bg_colour'>");
|
||||
|
||||
@@ -9,13 +9,14 @@ echo("<td width=200 class=box-desc>" . $vlan['vlan_descr'] . "</td>");
|
||||
|
||||
echo("<td class=list-bold>");
|
||||
$ports_query = mysql_query("SELECT * FROM ports WHERE `device_id` = '" . $device['device_id'] . "' AND `ifVlan` = '" . $vlan['vlan_vlan'] . "' ");
|
||||
while($port = mysql_fetch_array($ports_query)) {
|
||||
while($port = mysql_fetch_array($ports_query))
|
||||
{
|
||||
if ($_GET['opta'])
|
||||
{
|
||||
$graph_type = $_GET['opta'];
|
||||
|
||||
if($_GET['opta']) {
|
||||
$graph_type = $_GET['opta'];
|
||||
|
||||
echo("<div style='display: block; padding: 2px; margin: 2px; min-width: 139px; max-width:139px; min-height:85px; max-height:85px; text-align: center; float: left; background-color: ".$list_colour_b_b.";'>
|
||||
<div style='font-weight: bold;'>".makeshortif($port['ifDescr'])."</div>
|
||||
echo("<div style='display: block; padding: 2px; margin: 2px; min-width: 139px; max-width:139px; min-height:85px; max-height:85px; text-align: center; float: left; background-color: ".$list_colour_b_b.";'>
|
||||
<div style='font-weight: bold;'>".makeshortif ($port['ifDescr'])."</div>
|
||||
<a href='device/".$device['device_id']."/interface/".$port['interface_id']."/' onmouseover=\"return overlib('\
|
||||
<div style=\'font-size: 16px; padding:5px; font-weight: bold; color: #e5e5e5;\'>".$device['hostname']." - ".$port['ifDescr']."</div>\
|
||||
".$port['ifAlias']." \
|
||||
@@ -25,15 +26,14 @@ while($port = mysql_fetch_array($ports_query)) {
|
||||
</a>
|
||||
<div style='font-size: 9px;'>".truncate(short_port_descr($port['ifAlias']), 22, '')."</div>
|
||||
</div>");
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
echo($vlan['port_sep'] . generate_port_link($port, makeshortif($port['ifDescr'])));
|
||||
}
|
||||
else
|
||||
{
|
||||
echo($vlan['port_sep'] . generate_port_link($port, makeshortif ($port['ifDescr'])));
|
||||
$vlan['port_sep'] = ", ";
|
||||
}
|
||||
}
|
||||
echo("</td>");
|
||||
echo("</tr>");
|
||||
|
||||
?>
|
||||
echo('</td></tr>');
|
||||
|
||||
?>
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
$updated = '1';
|
||||
|
||||
$sql = "INSERT INTO `services` (`device_id`,`service_ip`,`service_type`,`service_desc`,`service_param`,`service_ignore`)
|
||||
$sql = "INSERT INTO `services` (`device_id`,`service_ip`,`service_type`,`service_desc`,`service_param`,`service_ignore`)
|
||||
VALUES ('" . mres($_POST['device']). "','" . mres($_POST['ip']) . "','" . mres($_POST['type']) . "',
|
||||
'" . mres($_POST['descr']) . "','" . mres($_POST['params']) . "','0')";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
if($_SESSION['userlevel'] == 10)
|
||||
if($_SESSION['userlevel'] == 10)
|
||||
{
|
||||
$devices['count'] = mysql_result(mysql_query("SELECT count(*) FROM devices"),0);
|
||||
$devices['up'] = mysql_result(mysql_query("SELECT count(*) FROM devices WHERE status = '1' AND `ignore` = '0'"),0);
|
||||
@@ -20,8 +20,8 @@ if($_SESSION['userlevel'] == 10)
|
||||
$services['down'] = mysql_result(mysql_query("SELECT count(service_id) FROM services WHERE service_status = '0' AND service_ignore = '0'"),0);
|
||||
$services['ignored'] = mysql_result(mysql_query("SELECT count(service_id) FROM services WHERE service_ignore = '1'"),0);
|
||||
$services['disabled'] = mysql_result(mysql_query("SELECT count(service_id) FROM services WHERE service_disabled = '1'"),0);
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
$devices['count'] = mysql_result(mysql_query("SELECT count(D.device_id) FROM devices AS D, devices_perms AS P WHERE P.user_id = '" . $_SESSION['user_id'] . "' AND P.device_id = D.device_id"),0);
|
||||
$devices['up'] = mysql_result(mysql_query("SELECT count(D.device_id) FROM devices AS D, devices_perms AS P WHERE P.user_id = '" . $_SESSION['user_id'] . "' AND P.device_id = D.device_id AND D.status = '1' AND D.ignore = '0'"),0);
|
||||
|
||||
@@ -16,7 +16,7 @@ print_optionbar_end();
|
||||
$i = "1";
|
||||
$vlan_query = mysql_query("select * from vlans WHERE device_id = '".$_GET['id']."' ORDER BY 'vlan_vlan'");
|
||||
while($vlan = mysql_fetch_array($vlan_query)) {
|
||||
include("includes/print-vlan.inc");
|
||||
include("includes/print-vlan.inc.php");
|
||||
$i++;
|
||||
}
|
||||
echo("</table>");
|
||||
|
||||
@@ -122,7 +122,7 @@ echo('<table cellpadding="7" cellspacing="0" class="devicetable" width="100%">
|
||||
$device_query = mysql_query($sql);
|
||||
while ($device = mysql_fetch_array($device_query)) {
|
||||
if ( device_permitted($device['device_id']) ) {
|
||||
include("includes/hostbox.inc");
|
||||
include("includes/hostbox.inc.php");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ echo("<tr class=interface-desc bgcolor=#e5e5e5 style='font-weight:bold;'>
|
||||
|
||||
while($device = mysql_fetch_array($device_query)) {
|
||||
|
||||
include("includes/hostbox.inc");
|
||||
include("includes/hostbox.inc.php");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ function snmp_get($device, $oid, $options = NULL, $mib = NULL, $mibdir = NULL)
|
||||
|
||||
if (is_numeric($device['timeout'])) { $timeout = $device['timeout']; } elseif (isset($config['snmp']['timeout'])) { $timeout = $config['snmp']['timeout']; }
|
||||
if (is_numeric($device['retries'])) { $retries = $device['retries']; } elseif (isset($config['snmp']['retries'])) { $retries = $config['snmp']['retries']; }
|
||||
|
||||
|
||||
if (strstr($oid,' '))
|
||||
{
|
||||
echo "BUG: snmp_get called for multiple OIDs: $oid\n";
|
||||
@@ -124,7 +124,7 @@ function snmp_get($device, $oid, $options = NULL, $mib = NULL, $mibdir = NULL)
|
||||
function snmp_walk($device, $oid, $options = NULL, $mib = NULL, $mibdir = NULL)
|
||||
{
|
||||
global $debug,$config,$runtime_stats;
|
||||
|
||||
|
||||
if (is_numeric($device['timeout'])) { $timeout = $device['timeout']; } elseif (isset($config['snmp']['timeout'])) { $timeout = $config['snmp']['timeout']; }
|
||||
if (is_numeric($device['retries'])) { $retries = $device['retries']; } elseif (isset($config['snmp']['retries'])) { $retries = $config['snmp']['retries']; }
|
||||
|
||||
@@ -172,10 +172,10 @@ function snmp_walk($device, $oid, $options = NULL, $mib = NULL, $mibdir = NULL)
|
||||
function snmpwalk_cache_cip($device, $oid, $array, $mib = 0)
|
||||
{
|
||||
global $config;
|
||||
|
||||
|
||||
if (is_numeric($device['timeout'])) { $timeout = $device['timeout']; } elseif (isset($config['snmp']['timeout'])) { $timeout = $config['snmp']['timeout']; }
|
||||
if (is_numeric($device['retries'])) { $retries = $device['retries']; } elseif (isset($config['snmp']['retries'])) { $retries = $config['snmp']['retries']; }
|
||||
|
||||
|
||||
if ($device['snmpver'] == 'v1' || $config['os'][$device['os']]['nobulk'])
|
||||
{
|
||||
$snmpcommand = $config['snmpwalk'];
|
||||
@@ -184,19 +184,19 @@ function snmpwalk_cache_cip($device, $oid, $array, $mib = 0)
|
||||
{
|
||||
$snmpcommand = $config['snmpbulkwalk'];
|
||||
}
|
||||
|
||||
|
||||
$cmd = $snmpcommand . " -O snQ -" . $device['snmpver'] . " -c " . $device['community'] . " ";
|
||||
if ($mib) { $cmd .= " -m $mib"; }
|
||||
$cmd .= " -M ".$config['install_dir']."/mibs/";
|
||||
if (isset($timeout)) { $cmd .= " -t " . $timeout; }
|
||||
if (isset($retries)) { $cmd .= " -r " . $retries; }
|
||||
|
||||
|
||||
$cmd .= " ".$device['hostname'].":".$device['port']." ".$oid;
|
||||
|
||||
|
||||
if (!$debug) { $cmd .= " 2>/dev/null"; }
|
||||
$data = trim(shell_exec($cmd));
|
||||
$device_id = $device['device_id'];
|
||||
|
||||
|
||||
#echo("Caching: $oid\n");
|
||||
foreach(explode("\n", $data) as $entry)
|
||||
{
|
||||
@@ -226,10 +226,10 @@ function snmp_cache_ifIndex($device)
|
||||
{
|
||||
// FIXME: this has no internal version, and is not yet using our own snmp_*
|
||||
global $config;
|
||||
|
||||
|
||||
if (is_numeric($device['timeout'])) { $timeout = $device['timeout']; } elseif (isset($config['snmp']['timeout'])) { $timeout = $config['snmp']['timeout']; }
|
||||
if (is_numeric($device['retries'])) { $retries = $device['retries']; } elseif (isset($config['snmp']['retries'])) { $retries = $config['snmp']['retries']; }
|
||||
|
||||
|
||||
if ($device['snmpver'] == 'v1' || $config['os'][$device['os']]['nobulk'])
|
||||
{
|
||||
$snmpcommand = $config['snmpwalk'];
|
||||
@@ -238,17 +238,17 @@ function snmp_cache_ifIndex($device)
|
||||
{
|
||||
$snmpcommand = $config['snmpbulkwalk'];
|
||||
}
|
||||
|
||||
|
||||
$cmd = $snmpcommand . " -O Qs -" . $device['snmpver'] . " -c " . $device['community'] . " ";
|
||||
$cmd .= " -M ".$config['install_dir']."/mibs/";
|
||||
$cmd .= " -m IF-MIB ifIndex";
|
||||
|
||||
|
||||
if (isset($timeout)) { $cmd .= " -t " . $timeout; }
|
||||
if (isset($retries)) { $cmd .= " -r " . $retries; }
|
||||
if (!$debug) { $cmd .= " 2>/dev/null"; }
|
||||
$data = trim(shell_exec($cmd));
|
||||
$device_id = $device['device_id'];
|
||||
|
||||
|
||||
foreach(explode("\n", $data) as $entry)
|
||||
{
|
||||
list ($this_oid, $this_value) = preg_split("/=/", $entry);
|
||||
@@ -316,7 +316,7 @@ function snmpwalk_cache_multi_oid($device, $oid, $array, $mib = NULL, $mibdir =
|
||||
function snmpwalk_cache_double_oid($device, $oid, $array, $mib = NULL, $mibdir = NULL)
|
||||
{
|
||||
$data = snmp_walk($device, $oid, "-OQUs", $mib, $mibdir);
|
||||
|
||||
|
||||
foreach(explode("\n", $data) as $entry)
|
||||
{
|
||||
list($oid,$value) = explode("=", $entry);
|
||||
@@ -354,10 +354,10 @@ function snmpwalk_cache_triple_oid($device, $oid, $array, $mib = NULL, $mibdir =
|
||||
function snmpwalk_cache_twopart_oid($device, $oid, $array, $mib = 0)
|
||||
{
|
||||
global $config;
|
||||
|
||||
|
||||
if (is_numeric($device['timeout'])) { $timeout = $device['timeout']; } elseif (isset($config['snmp']['timeout'])) { $timeout = $config['snmp']['timeout']; }
|
||||
if (is_numeric($device['retries'])) { $retries = $device['retries']; } elseif (isset($config['snmp']['retries'])) { $retries = $config['snmp']['retries']; }
|
||||
|
||||
|
||||
if ($device['snmpver'] == 'v1' || $config['os'][$device['os']]['nobulk'])
|
||||
{
|
||||
$snmpcommand = $config['snmpwalk'];
|
||||
@@ -488,7 +488,7 @@ function snmp_cache_port_oids($oids, $port, $device, $array, $mib=0)
|
||||
{
|
||||
$string .= " $oid.$port";
|
||||
}
|
||||
|
||||
|
||||
$cmd = $config['snmpget'] . " -O vq -" . $device['snmpver'] . " -c " . $device['community'] . " ";
|
||||
if (isset($timeout)) { $cmd .= " -t " . $timeout; }
|
||||
if (isset($retries)) { $cmd .= " -r " . $retries; }
|
||||
|
||||
@@ -767,18 +767,18 @@ if (isset($config['enable_printers']) && $config['enable_printers'])
|
||||
|
||||
$config['version'] = "0.10";
|
||||
|
||||
if(isset($config['rrdgraph_def_text']))
|
||||
if(isset($config['rrdgraph_def_text']))
|
||||
{
|
||||
$config['rrdgraph_def_text'] = str_replace(" ", " ", $config['rrdgraph_def_text']);
|
||||
$config['rrd_opts_array'] = explode(" ", trim($config['rrdgraph_def_text']));
|
||||
}
|
||||
|
||||
if(!isset($config['log_file']))
|
||||
if(!isset($config['log_file']))
|
||||
{
|
||||
$config['log_file'] = $config['install_dir'] . "/observium.log";
|
||||
}
|
||||
|
||||
if(!isset($config['mibdir']))
|
||||
if(!isset($config['mibdir']))
|
||||
{
|
||||
$config['mibdir'] = $config['install_dir']."/mibs/";
|
||||
}
|
||||
@@ -794,14 +794,14 @@ $nagios_db = mysql_select_db($config['nagios_db_name'], $nagios_link);
|
||||
}
|
||||
|
||||
# If we're on SSL, let's properly detect it
|
||||
if(isset($_SERVER['HTTPS']))
|
||||
if(isset($_SERVER['HTTPS']))
|
||||
{
|
||||
$config['base_url'] = preg_replace('/^http:/','https:', $config['base_url']);
|
||||
}
|
||||
|
||||
### Connect to database
|
||||
$observium_link = mysql_pconnect($config['db_host'], $config['db_user'], $config['db_pass']);
|
||||
if (!$observium_link)
|
||||
if (!$observium_link)
|
||||
{
|
||||
echo("<h2>Observer MySQL Error</h2>");
|
||||
echo(mysql_error());
|
||||
|
||||
35
irc.php
35
irc.php
@@ -8,42 +8,37 @@ include("includes/discovery/functions.inc.php");
|
||||
|
||||
include_once('Net/SmartIRC.php');
|
||||
|
||||
|
||||
class observiumbot
|
||||
{
|
||||
|
||||
function device_info (&$irc, &$data)
|
||||
function device_info(&$irc, &$data)
|
||||
{
|
||||
$hostname = $data->messageex[1];
|
||||
$hostname = $data->messageex[1];
|
||||
|
||||
$device = mysql_fetch_array(mysql_query("SELECT * FROM `devices` WHERE `hostname` = '".mres($hostname)."'"));
|
||||
$device = mysql_fetch_array(mysql_query("SELECT * FROM `devices` WHERE `hostname` = '".mres($hostname)."'"));
|
||||
|
||||
if($device['status'] == 1) { $status = "Up " . formatUptime($device['uptime'] . " "); } else { $status = "Down "; }
|
||||
if($device['ignore']) { $status = "*Ignored*"; }
|
||||
if($device['disabled']) { $status = "*Disabled*"; }
|
||||
if($device['status'] == 1) { $status = "Up " . formatUptime($device['uptime'] . " "); } else { $status = "Down "; }
|
||||
if($device['ignore']) { $status = "*Ignored*"; }
|
||||
if($device['disabled']) { $status = "*Disabled*"; }
|
||||
|
||||
$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, 'id'.$device['device_id'] . " " . $device['os'] . " " . $device['version'] . " " .
|
||||
$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, 'id'.$device['device_id'] . " " . $device['os'] . " " . $device['version'] . " " .
|
||||
$device['features'] . " " . $status);
|
||||
|
||||
}
|
||||
|
||||
function port_info (&$irc, &$data)
|
||||
{
|
||||
|
||||
function port_info(&$irc, &$data)
|
||||
{
|
||||
$hostname = $data->messageex[1];
|
||||
$ifname = $data->messageex[2];
|
||||
|
||||
$device = mysql_fetch_array(mysql_query("SELECT * FROM `devices` WHERE `hostname` = '".mres($hostname)."'"));
|
||||
$port = mysql_fetch_Array(mysql_query("SELECT * FROM `ports` WHERE `ifName` = '".$ifname."' OR `ifDescr` = '".$ifname."' AND device_id = '".$device['device_id']."'"));
|
||||
|
||||
$bps_in = formatRates($port['ifInOctets_rate']);
|
||||
$bps_out = formatRates($port['ifOutOctets_rate']);
|
||||
$pps_in = format_bi($port['ifInUcastPkts_rate']);
|
||||
$pps_out = format_bi($port['ifOutUcastPkts_rate']);
|
||||
$bps_in = formatRates($port['ifInOctets_rate']);
|
||||
$bps_out = formatRates($port['ifOutOctets_rate']);
|
||||
$pps_in = format_bi($port['ifInUcastPkts_rate']);
|
||||
$pps_out = format_bi($port['ifOutUcastPkts_rate']);
|
||||
|
||||
$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, 'id' . $port['interface_id'] . " " . $port['ifAdminStatus'] . "/" . $port['ifOperStatus'] . " " .
|
||||
$irc->message(SMARTIRC_TYPE_CHANNEL, $data->channel, 'id' . $port['interface_id'] . " " . $port['ifAdminStatus'] . "/" . $port['ifOperStatus'] . " " .
|
||||
$bps_in. " > bps > " . $bps_out . " | " . $pps_in. "pps > PPS > " . $pps_out ."pps");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,4 +60,4 @@ $irc->join( array( $chan ) );
|
||||
$irc->listen( );
|
||||
$irc->disconnect( );
|
||||
|
||||
?>
|
||||
?>
|
||||
115
map.php
115
map.php
@@ -1,115 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
include("config.php");
|
||||
include("includes/functions.php");
|
||||
|
||||
echo("digraph G { sep=0.6; size=\"40,20\"; pack=10; bgcolor=transparent;splines=true;
|
||||
node [ fontname=\"helvetica\", fontsize=38, fontstyle=bold, shape=box, style=bold];
|
||||
edge [ labelfontsize=10, labelfontname=\"helvetica\", overlap=false, fontstyle=bold];
|
||||
graph [bgcolor=transparent, remincross=true];
|
||||
|
||||
");
|
||||
|
||||
$linkdone = array();
|
||||
|
||||
$x = 1;
|
||||
|
||||
$loc_sql = "SELECT * FROM devices GROUP BY location";
|
||||
$loc_result = mysql_query($loc_sql);
|
||||
while($loc_data = mysql_fetch_array($loc_result)) {
|
||||
|
||||
echo("subgraph \"". $loc_data['location'] ."\" {\n
|
||||
label = \"". $loc_data['location'] ."\";
|
||||
style=filled;
|
||||
color=lightgrey;\n\n");
|
||||
|
||||
$dev_sql = "SELECT * FROM devices WHERE location = '" . $loc_data['location'] . "' and (`os` LIKE '%ios%' OR `os` LIKE '%catos%') AND disabled = 0";
|
||||
$dev_result = mysql_query($dev_sql);
|
||||
while($dev_data = mysql_fetch_array($dev_result)) {
|
||||
$device_id = $dev_data['device_id'];
|
||||
|
||||
# if(mysql_result(mysql_query("SELECT count(*) from links WHERE local_interface_id = '$device_id' OR remote_interface_id = '$device_id'"),0)) {
|
||||
$host = $dev_data['hostname'];
|
||||
unset($hostinfo);
|
||||
if(strpos($host, "cust." . $config['mydomain'])) { $hostinfo = "shape=egg style=filled fillcolor=pink"; }
|
||||
if(strpos($host, "bas")) { $hostinfo = "shape=rectangle style=filled fillcolor=skyblue"; }
|
||||
if(strpos($host, "crs")) { $hostinfo = "shape=box3d style=filled fillcolor=skyblue"; }
|
||||
if(strpos($host, "lcr")) { $hostinfo = "shape=tripleoctagon style=filled fillcolor=darkolivegreen4"; }
|
||||
if(strpos($host, "ler")) { $hostinfo = "shape=octagon style=filled fillcolor=darkolivegreen1"; }
|
||||
if(strpos($host, "pbr")) { $hostinfo = "shape=ellipse style=filled fillcolor=orange"; }
|
||||
if(strpos($host, "tbr")) { $hostinfo = "shape=ellipse style=filled fillcolor=orange"; }
|
||||
if(strstr($host, "gwr")) { $hostinfo = "shape=ellipse style=filled fillcolor=orange"; }
|
||||
if(strpos($host, "bgw")) { $hostinfo = "shape=ellipse style=filled fillcolor=orange"; }
|
||||
if(strpos($host, "vax")) { $hostinfo = "shape=rect style=filled fillcolor=skyblue"; }
|
||||
if(strpos($host, "vsx")) { $hostinfo = "shape=box3d style=filled fillcolor=skyblue"; }
|
||||
|
||||
$host = $dev_data['hostname'];
|
||||
$host = str_replace("." . $config['mydomain'],"", $host);
|
||||
echo("\"$host\" [$hostinfo]
|
||||
");
|
||||
# }
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
echo("\n}\n");
|
||||
|
||||
}
|
||||
|
||||
$links_sql = "SELECT *, X.ifDescr AS sif, I.ifDescr AS dif FROM links AS L, ports AS I, ports AS X, devices as D, devices as Y WHERE I.device_id = D.device_id AND X.device_id = Y.device_id AND L.local_interface_id = I.interface_id AND X.interface_id = L.remote_interface_id";
|
||||
|
||||
$links_result = mysql_query($links_sql);
|
||||
while($link_data = mysql_fetch_array($links_result)) {
|
||||
|
||||
$local_interface_id = $link_data['local_interface_id'];
|
||||
$remote_interface_id = $link_data['remote_interface_id'];
|
||||
|
||||
$sq = mysql_fetch_row(mysql_query("SELECT `hostname`,`ifSpeed` FROM ports AS I, devices as D where I.device_id = D.device_id and I.interface_id = '$local_interface_id'"));
|
||||
$dq = mysql_fetch_row(mysql_query("SELECT `hostname`,`ifSpeed` FROM ports AS I, devices as D where I.device_id = D.device_id and I.interface_id = '$remote_interface_id'"));
|
||||
|
||||
$src = $sq[0];
|
||||
$dst = $dq[0];
|
||||
|
||||
$src_speed = $sq[1];
|
||||
$dst_speed = $dq[1];
|
||||
|
||||
$src = str_replace("." . $config['mydomain'], "", $src);
|
||||
$dst = str_replace("." . $config['mydomain'], "", $dst);
|
||||
|
||||
$info = "";
|
||||
|
||||
if($src_speed >= "10000000000") {
|
||||
$info .= "color=lightred weight=10 style=\"setlinewidth(8)\"";
|
||||
} elseif ($src_speed >= "1000000000") {
|
||||
$info .= "color=lightblue weight=5 style=\"setlinewidth(4)\"";
|
||||
} elseif ($src_speed >= "100000000") {
|
||||
$info .= "color=lightgrey weight=1 style=\"setlinewidth(2)\"";
|
||||
} elseif ($src_speed >= "10000000") {
|
||||
$info .= "style=\"setlinewidth(1)\" weight=1";
|
||||
}
|
||||
|
||||
unset($die);
|
||||
|
||||
$i = 0;
|
||||
while ($i < count($linkdone)) {
|
||||
$thislink = "$dst ".$link_data['dif']." $src ".$link_data['sif'];
|
||||
if ($linkdone[$i] == $thislink) { $die = "yes"; }
|
||||
$i++;
|
||||
}
|
||||
|
||||
$sif = makeshortif($link_data['sif']);
|
||||
$dif = makeshortif($link_data['dif']);
|
||||
|
||||
if(!$die){
|
||||
echo("\"$src\" -> \"$dst\" [taillabel=\"$dif\" headlabel=\"$sif\" arrowhead=dot arrowtail=dot $info];\n");
|
||||
# echo("\"$src\" -> \"$dst\" [ arrowhead=none arrowtail=none $info];\n");
|
||||
$linkdone[] = "$src ".$link_data['sif']." $dst ".$link_data['dif'];
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
|
||||
echo("}");
|
||||
|
||||
?>
|
||||
@@ -106,7 +106,7 @@ function CollectData($bill_id)
|
||||
$prev_in_delta = '0';
|
||||
$prev_out_delta = '0';
|
||||
}
|
||||
|
||||
|
||||
if ($delta < '0' )
|
||||
{
|
||||
$delta = $prev_delta;
|
||||
|
||||
@@ -15,10 +15,10 @@ while ($device = mysql_fetch_array($device_query)) {
|
||||
if( isPingable($device['hostname']) ) {
|
||||
$pos = snmp_get($device, "sysDescr.0", "-Oqv", "SNMPv2-MIB");
|
||||
echo($device['protocol'].":".$device['hostname'].":".$device['port']." - ".$device['community']." ".$device['snmpver'].": ");
|
||||
if($pos == '') {
|
||||
if($pos == '') {
|
||||
$status='0';
|
||||
} else {
|
||||
$status='1';
|
||||
} else {
|
||||
$status='1';
|
||||
}
|
||||
} else {
|
||||
$status='0';
|
||||
@@ -34,15 +34,15 @@ while ($device = mysql_fetch_array($device_query)) {
|
||||
if($status != $device['status']) {
|
||||
|
||||
mysql_query("UPDATE `devices` SET `status`= '$status' WHERE `device_id` = '" . $device['device_id'] . "'");
|
||||
if ($status == '1') {
|
||||
$stat = "Up";
|
||||
if ($status == '1') {
|
||||
$stat = "Up";
|
||||
mysql_query("INSERT INTO alerts (importance, device_id, message) VALUES ('0', '" . $device['device_id'] . "', 'Device is up\n')");
|
||||
if($config['alerts']['email']['enable'])
|
||||
{
|
||||
notify($device, "Device Up: " . $device['hostname'], "Device Up: " . $device['hostname'] . " at " . date($config['timestamp_format']));
|
||||
}
|
||||
} else {
|
||||
$stat = "Down";
|
||||
$stat = "Down";
|
||||
mysql_query("INSERT INTO alerts (importance, device_id, message) VALUES ('9', '" . $device['device_id'] . "', 'Device is down\n')");
|
||||
if($config['alerts']['email']['enable'])
|
||||
{
|
||||
|
||||
@@ -117,10 +117,10 @@ while ($device = mysql_fetch_assoc($device_query))
|
||||
|
||||
$graphs = array();
|
||||
$oldgraphs = array();
|
||||
|
||||
|
||||
$snmpdata = snmp_get_multi($device, "sysUpTime.0 sysLocation.0 sysContact.0 sysName.0", "-OQUs", "SNMPv2-MIB");
|
||||
foreach (array_keys($snmpdata[0]) as $key) { $$key = $snmpdata[0][$key]; }
|
||||
|
||||
|
||||
$sysDescr = snmp_get($device, "sysDescr.0", "-Oqv", "SNMPv2-MIB");
|
||||
|
||||
$sysName = strtolower($sysName);
|
||||
|
||||
@@ -7,17 +7,21 @@ include("includes/functions.php");
|
||||
|
||||
# Remove a host and all related data from the system
|
||||
|
||||
if($argv[1] && $argv[2]) {
|
||||
if($argv[1] && $argv[2])
|
||||
{
|
||||
$host = strtolower($argv[1]);
|
||||
$id = getidbyname($host);
|
||||
if($id) {
|
||||
if($id)
|
||||
{
|
||||
renamehost($id, $argv[2]);
|
||||
echo("Renamed $host\n");
|
||||
} else {
|
||||
echo("Host doesn't exist!\n");
|
||||
}
|
||||
} else {
|
||||
echo("Host Rename Tool\nUsage: ./renamehost.php <old hostname> <new hostname>\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
echo("Host Rename Tool\nUsage: ./renamehost.php <old hostname> <new hostname>\n");
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -5,40 +5,38 @@ include("includes/defaults.inc.php");
|
||||
include("config.php");
|
||||
include("includes/functions.php");
|
||||
|
||||
$ports = mysql_result(mysql_query("SELECT count(*) FROM ports"),0);
|
||||
$ports = mysql_result(mysql_query("SELECT count(*) FROM ports"),0);
|
||||
$devices = mysql_result(mysql_query("SELECT count(*) FROM devices"),0);
|
||||
|
||||
$dataHandle = fopen("http://www.observium.org/latest.php?i=$ports&d=$devices&v=".$config['version'], r);
|
||||
|
||||
if($dataHandle)
|
||||
if ($dataHandle)
|
||||
{
|
||||
while (!feof($dataHandle))
|
||||
{
|
||||
$data.= fread($dataHandle, 4096);
|
||||
}
|
||||
if($data)
|
||||
if ($data)
|
||||
{
|
||||
list($major, $minor, $release) = explode(".", $data);
|
||||
list($cur, $tag) = explode("-", $config['version']);
|
||||
list($cur_major, $cur_minor, $cur_release) = explode(".", $cur);
|
||||
|
||||
if($argv[1] == "--cron")
|
||||
if ($argv[1] == "--cron")
|
||||
{
|
||||
$fd = fopen('vrrd/version.txt','w');
|
||||
fputs($fd, "$major.$minor.$release");
|
||||
fclose($fd);
|
||||
|
||||
} else {
|
||||
|
||||
echo("Current Version $cur_major.$cur_minor.$cur_release \n");
|
||||
|
||||
if($major > $cur_major) {
|
||||
if ($major > $cur_major) {
|
||||
echo("New major release : $major.$minor.$release");
|
||||
} elseif ($major == $cur_major && $minor > $cur_minor) {
|
||||
echo("New minor release : $major.$minor.$release");
|
||||
} elseif ($major == $cur_major && $minor == $cur_minor && $release > $cur_release) {
|
||||
echo("New trivial release : $major.$minor.$release");
|
||||
} elseif($major < $cur_major || ($major == $cur_major && $minor < $cur_minor) || ($major == $cur_major && $minor == $cur_minor && $release < $cur_release)) {
|
||||
} elseif ($major < $cur_major || ($major == $cur_major && $minor < $cur_minor) || ($major == $cur_major && $minor == $cur_minor && $release < $cur_release)) {
|
||||
echo("Your release is newer than the official version!\n");
|
||||
} else {
|
||||
echo("Your release is up to date\n");
|
||||
|
||||
Reference in New Issue
Block a user