mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
allow disabling of alerting per device, allow override of syscontact, minor cleanups
git-svn-id: http://www.observium.org/svn/observer/trunk@1995 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
BIN
html/images/icons/alerts.png
Executable file
BIN
html/images/icons/alerts.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 678 B |
BIN
html/images/icons/greyscale/alerts.png
Normal file
BIN
html/images/icons/greyscale/alerts.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 567 B |
@@ -53,7 +53,6 @@ $interface['graph_type'] = "port_bits";
|
||||
echo(generate_port_link($interface, "<img src='graph.php?type=".$interface['graph_type']."&id=".$interface['interface_id']."&from=".$from."&to=".$now."&width=".$width."&height=".$height."&legend=no&bg=".
|
||||
str_replace("#","", $row_colour)."'>", $interface['graph_type']));
|
||||
|
||||
|
||||
echo("</td><td width=135>");
|
||||
echo("".formatRates($interface['adslAturChanCurrTxRate']) . "/". formatRates($interface['adslAtucChanCurrTxRate']));
|
||||
echo("<br />");
|
||||
@@ -142,4 +141,4 @@ if ($graph_type && is_file($graph_file))
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
@@ -1,9 +1,5 @@
|
||||
<?php
|
||||
|
||||
#echo("<pre>");
|
||||
#print_r($interface);
|
||||
#echo("</pre>");
|
||||
|
||||
# This file prints a table row for each interface
|
||||
|
||||
$interface['device_id'] = $device['device_id'];
|
||||
@@ -32,12 +28,12 @@ echo("<tr style=\"background-color: $row_colour;\" valign=top onmouseover=\"this
|
||||
<td valign=top width=350>");
|
||||
echo(" <span class=list-large>
|
||||
" . generate_port_link($interface, $interface['ifIndex'] . ". ".$interface['label']) . " $error_img $mac
|
||||
|
||||
</span><br /><span class=interface-desc>".$interface['ifAlias']."</span>");
|
||||
|
||||
if ($interface['ifAlias']) { echo("<br />"); }
|
||||
|
||||
unset ($break);
|
||||
|
||||
if ($port_details)
|
||||
{
|
||||
$ipdata = mysql_query("SELECT * FROM `ipv4_addresses` WHERE `interface_id` = '" . $interface['interface_id'] . "'");
|
||||
@@ -271,7 +267,6 @@ if ($graph_type && is_file($graph_file))
|
||||
# onmouseout=\"return nd();\"> <img src='$yearly_traffic' border=0></a>");
|
||||
|
||||
echo("</td></tr>");
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
@@ -29,7 +29,7 @@ if ($_POST['hostname'] && $_POST['community'])
|
||||
|
||||
?>
|
||||
|
||||
<form name="form1" method="post" action="<?php echo($config['base_url']); ?>/addhost/">
|
||||
<form name="form1" method="post" action="">
|
||||
<p>Devices will be checked for Ping and SNMP reachability before being probed. Only devices with recognised OSes will be added.</p>
|
||||
|
||||
<div style="padding: 10px; background: #f0f0f0;">
|
||||
|
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
[B<?php
|
||||
|
||||
if ($_POST['addbill'] == "yes")
|
||||
{
|
||||
@@ -146,7 +146,7 @@ if ($_GET['opta'] == "add")
|
||||
$allowed = formatRates($bill['bill_cdr'] * 1000);
|
||||
$used = formatRates($rate_data['rate_95th'] * 1000);
|
||||
$percent = round(($rate_data['rate_95th'] / $bill['bill_cdr']) * 100,2);
|
||||
} elseif ($bill['bill_type'] == "quota") {
|
||||
} elseif ($bill['bill_type'] == "quota") {
|
||||
$type = "Quota";
|
||||
$allowed = formatStorage($bill['bill_gb']* 1024 * 1024 * 1024);
|
||||
$used = formatStorage($rate_data['total_data'] * 1024 * 1024);
|
||||
|
@@ -9,6 +9,7 @@ if ($_SESSION['userlevel'] < '7')
|
||||
$panes['snmp'] = 'SNMP';
|
||||
$panes['ports'] = 'Port Settings';
|
||||
$panes['apps'] = 'Applications';
|
||||
$panes['alerts'] = 'Alerts';
|
||||
|
||||
if ($config['enable_services'])
|
||||
{
|
||||
|
63
html/pages/device/edit/alerts.inc.php
Normal file
63
html/pages/device/edit/alerts.inc.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
if ($_POST['editing'])
|
||||
{
|
||||
if ($_SESSION['userlevel'] > "7")
|
||||
{
|
||||
$override_sysContact_bool = mres($_POST['override_sysContact']);
|
||||
if (isset($_POST['sysContact'])) { $override_sysContact_string = mres($_POST['sysContact']); }
|
||||
$disable_notify = mres($_POST['disable_notify']);
|
||||
|
||||
if ($override_sysContact_bool) { set_dev_attrib($device, 'override_sysContact_bool', '1'); } else { del_dev_attrib($device, 'override_sysContact_bool'); }
|
||||
if (isset($override_sysContact_string)) { set_dev_attrib($device, 'override_sysContact_string', $override_sysContact_string); };
|
||||
if ($disable_notify) { set_dev_attrib($device, 'disable_notify', '1'); } else { del_dev_attrib($device, 'disable_notify'); }
|
||||
|
||||
$update_message = "Device alert settings updated.";
|
||||
$updated = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ($updated && $update_message)
|
||||
{
|
||||
print_message($update_message);
|
||||
} elseif ($update_message) {
|
||||
print_error($update_message);
|
||||
}
|
||||
|
||||
$override_sysContact_bool = get_dev_attrib($device,'override_sysContact_bool');
|
||||
$override_sysContact_string = get_dev_attrib($device,'override_sysContact_string');
|
||||
$disable_notify = get_dev_attrib($device,'disable_notify');
|
||||
?>
|
||||
|
||||
<h3>Alert settings</h3>
|
||||
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td>
|
||||
<form id="edit" name="edit" method="post" action="">
|
||||
<input type="hidden" name="editing" value="yes">
|
||||
<table width="500" border="0">
|
||||
<tr>
|
||||
<td width="50"><div style="padding-right: 5px; text-align: right"><input onclick="edit.sysContact.disabled=!edit.override_sysContact.checked" type="checkbox" name="override_sysContact"<?php if ($override_sysContact_bool) { echo(' checked="1"'); } ?> /></div></td>
|
||||
<td width="150">Override sysContact:</td>
|
||||
<td><input name="sysContact" size="32"<?php if (!$override_sysContact_bool) { echo(' disabled="1"'); } ?> value="<?php echo $override_sysContact_string; ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="50"><div style="padding-right: 5px; text-align: right"><input type="checkbox" name="disable_notify"<?php if ($disable_notify) { echo(' checked="1"'); } ?> /></div></td>
|
||||
<td colspan="2">Disable all alerting for this host</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
<br />
|
||||
<input type="submit" name="Submit" value="Save" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
</form>
|
||||
</td>
|
||||
<td width="50"></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
@@ -26,24 +26,26 @@ if ($updated && $update_message)
|
||||
|
||||
?>
|
||||
|
||||
<table cellpadding=0 cellspacing=0>
|
||||
<h3>IPMI settings</h3>
|
||||
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td>
|
||||
<form id="edit" name="edit" method="post" action="">
|
||||
<input type=hidden name="editing" value="yes">
|
||||
<input type="hidden" name="editing" value="yes">
|
||||
<table width="500" border="0">
|
||||
<tr>
|
||||
<td width="150"><div align="right">IPMI/BMC Hostname</div></td>
|
||||
<td colspan="3"><input name="ipmi_hostname" size="32" value="<?php echo get_dev_attrib($device,'ipmi_hostname'); ?>"></input></td>
|
||||
<td colspan="3"><input name="ipmi_hostname" size="32" value="<?php echo get_dev_attrib($device,'ipmi_hostname'); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><div align="right">IPMI/BMC Username</div></td>
|
||||
<td colspan="3"><input name="ipmi_username" size="32" value="<?php echo get_dev_attrib($device,'ipmi_username'); ?>"></input></td>
|
||||
<td colspan="3"><input name="ipmi_username" size="32" value="<?php echo get_dev_attrib($device,'ipmi_username'); ?>" /></td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><div align="right">IPMI/BMC Password</div></td>
|
||||
<td colspan="3"><input name="ipmi_password" type="password" size="32" value="<?php echo get_dev_attrib($device,'ipmi_password'); ?>"></input></td>
|
||||
<td colspan="3"><input name="ipmi_password" type="password" size="32" value="<?php echo get_dev_attrib($device,'ipmi_password'); ?>" /></td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@@ -50,7 +50,7 @@ echo("<table cellpadding=0 cellspacing=0><tr><td>
|
||||
<table width='400' border='0'>
|
||||
<tr>
|
||||
<td width='150'><div align='right'>SNMP Community</div></td>
|
||||
<td><input name='community' size='20' value='" . $device['community'] . "'></input>
|
||||
<td><input name='community' size='20' value='" . $device['community'] . "' />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -63,7 +63,7 @@ echo("<table cellpadding=0 cellspacing=0><tr><td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><div align='right'>SNMP Port</div></td>
|
||||
<td><input name='port' size='20' value='" . $device['port'] . "'></input>
|
||||
<td><input name='port' size='20' value='" . $device['port'] . "' />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -83,13 +83,13 @@ echo(" </select>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><div align='right'>SNMP Timeout</div></td>
|
||||
<td><input name='timeout' size='20' value='" . ($device['timeout'] ? $device['timeout'] : '') . "'></input>
|
||||
<td><input name='timeout' size='20' value='" . ($device['timeout'] ? $device['timeout'] : '') . "' />
|
||||
<em>seconds</em>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><div align='right'>SNMP Retries</div></td>
|
||||
<td colspan='3'><input name='retries' size='20' value='" . ($device['timeout'] ? $device['retries'] : '') . "'></input>
|
||||
<td colspan='3'><input name='retries' size='20' value='" . ($device['timeout'] ? $device['retries'] : '') . "' />
|
||||
</td>
|
||||
</tr>");
|
||||
|
||||
|
@@ -6,7 +6,7 @@ if ($os != $device['os'])
|
||||
{
|
||||
$sql = mysql_query("UPDATE `devices` SET `os` = '$os' WHERE `device_id` = '".$device['device_id']."'");
|
||||
echo("Changed OS! : $os\n");
|
||||
eventlog("Device OS changed ".$device['os']." => $os", $device['device_id']);
|
||||
log_event("Device OS changed ".$device['os']." => $os", $device, 'system');
|
||||
$device['os'] = $os;
|
||||
}
|
||||
|
||||
|
@@ -33,11 +33,11 @@ foreach (explode("\n", $ports) as $entry)
|
||||
{
|
||||
foreach ($config['bad_if_regexp'] as $bi)
|
||||
{
|
||||
if (preg_match($bi ."i", $if))
|
||||
{
|
||||
$nullintf = 1;
|
||||
if (preg_match($bi ."i", $if))
|
||||
{
|
||||
$nullintf = 1;
|
||||
if($debug) { echo("ignored : $bi : $if"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,23 +48,25 @@ foreach (explode("\n", $ports) as $entry)
|
||||
if ($debug) echo("\n $if ");
|
||||
if ($nullintf == 0)
|
||||
{
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) == '0') {
|
||||
mysql_query("INSERT INTO `ports` (`device_id`,`ifIndex`,`ifDescr`) VALUES ('".$device['device_id']."','$ifIndex','".mres($ifDescr)."')");
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) == '0')
|
||||
{
|
||||
mysql_query("INSERT INTO `ports` (`device_id`,`ifIndex`,`ifDescr`) VALUES ('".$device['device_id']."','$ifIndex','".mres($ifDescr)."')");
|
||||
# Add Interface
|
||||
echo("+");
|
||||
echo("+");
|
||||
} else {
|
||||
mysql_query("UPDATE `ports` SET `deleted` = '0' WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'");
|
||||
echo(".");
|
||||
mysql_query("UPDATE `ports` SET `deleted` = '0' WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'");
|
||||
echo(".");
|
||||
}
|
||||
$int_exists[] = "$ifIndex";
|
||||
} else {
|
||||
# Ignored Interface
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) != '0') {
|
||||
mysql_query("UPDATE `ports` SET `deleted` = '1' WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'");
|
||||
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) != '0')
|
||||
{
|
||||
mysql_query("UPDATE `ports` SET `deleted` = '1' WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'");
|
||||
# Delete Interface
|
||||
echo("-"); ## Deleted Interface
|
||||
echo("-"); ## Deleted Interface
|
||||
} else {
|
||||
echo("X"); ## Ignored Interface
|
||||
echo("X"); ## Ignored Interface
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,4 +95,4 @@ while ($test_if = mysql_fetch_array($query))
|
||||
unset($temp_exists);
|
||||
echo("\n");
|
||||
|
||||
?>
|
||||
?>
|
@@ -222,7 +222,7 @@ function renamehost($id, $new, $source = 'console')
|
||||
|
||||
rename($config['rrd_dir']."/$host",$config['rrd_dir']."/$new");
|
||||
mysql_query("UPDATE devices SET hostname = '$new' WHERE device_id = '$id'");
|
||||
eventlog("Hostname changed -> $new ($source)", $id);
|
||||
log_event("Hostname changed -> $new ($source)", $id, 'system');
|
||||
}
|
||||
|
||||
function delete_port($int_id)
|
||||
@@ -650,7 +650,7 @@ function get_astext($asn)
|
||||
}
|
||||
}
|
||||
|
||||
# DEPRECATED
|
||||
# FIXME DEPRECATED -- only used in dead file includes/polling/interfaces.inc.php - if we no longer need that one, this can go too.
|
||||
function eventlog($eventtext,$device_id = "", $interface_id = "")
|
||||
{
|
||||
$event_query = "INSERT INTO eventlog (host, interface, datetime, message) VALUES (" . ($device_id ? $device_id : "NULL");
|
||||
@@ -677,20 +677,27 @@ function notify($device,$title,$message)
|
||||
|
||||
if ($config['alerts']['email']['enable'])
|
||||
{
|
||||
if ($config['alerts']['email']['default_only'])
|
||||
if (!get_dev_attrib($device,'disable_notify'))
|
||||
{
|
||||
$email = $config['alerts']['email']['default'];
|
||||
} else {
|
||||
if ($device['sysContact'])
|
||||
if ($config['alerts']['email']['default_only'])
|
||||
{
|
||||
$email = $device['sysContact'];
|
||||
} else {
|
||||
$email = $config['alerts']['email']['default'];
|
||||
} else {
|
||||
if (get_dev_attrib($device,'override_sysContact_bool'))
|
||||
{
|
||||
$email = get_dev_attrib($device,'override_sysContact_string');
|
||||
}
|
||||
elseif ($device['sysContact'])
|
||||
{
|
||||
$email = $device['sysContact'];
|
||||
} else {
|
||||
$email = $config['alerts']['email']['default'];
|
||||
}
|
||||
}
|
||||
if ($email)
|
||||
{
|
||||
mail($email, $title, $message, $config['email_headers']);
|
||||
}
|
||||
}
|
||||
if ($email)
|
||||
{
|
||||
mail($email, $title, $message, $config['email_headers']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -780,4 +787,4 @@ function include_dir($dir, $regex = "")
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@@ -17,10 +17,10 @@ if ($device['os'] == "linux")
|
||||
$features = str_replace("\"", "", $features);
|
||||
|
||||
if (!$features) // No "extend" support, try "exec" support
|
||||
{
|
||||
$features = snmp_get($device, ".1.3.6.1.4.1.2021.7890.1.101.1", "-Oqv", "UCD-SNMP-MIB");
|
||||
$features = str_replace("\"", "", $features);
|
||||
}
|
||||
{
|
||||
$features = snmp_get($device, ".1.3.6.1.4.1.2021.7890.1.101.1", "-Oqv", "UCD-SNMP-MIB");
|
||||
$features = str_replace("\"", "", $features);
|
||||
}
|
||||
|
||||
// Detect Dell hardware via OpenManage SNMP
|
||||
$hw = snmp_get($device, ".1.3.6.1.4.1.674.10892.1.300.10.1.9.1", "-Oqv", "MIB-Dell-10892");
|
||||
@@ -63,12 +63,9 @@ elseif ($device['os'] == "monowall" || $device['os'] == "Voswall")
|
||||
}
|
||||
elseif ($device['os'] == "qnap")
|
||||
{
|
||||
|
||||
$hardware = snmp_get($device, "ENTITY-MIB::entPhysicalName.1", "-Osqnv");
|
||||
$version = snmp_get($device, "ENTITY-MIB::entPhysicalFirmwareRev.1", "-Osqnv");
|
||||
$serial = snmp_get($device, "ENTITY-MIB::entPhysicalSerial.1", "-Osqnv");
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
@@ -46,8 +46,6 @@ if ($config['enable_ports_adsl'])
|
||||
$device['adsl_count'] = mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifType` = 'adsl'"),0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($device['adsl_count'] > "0")
|
||||
{
|
||||
echo("ADSL ");
|
||||
@@ -321,4 +319,4 @@ while ($port = mysql_fetch_array($port_query))
|
||||
#### Clear Variables Here
|
||||
unset($port_stats);
|
||||
|
||||
?>
|
||||
?>
|
@@ -950,8 +950,6 @@ function array_preg_replace($array, $string)
|
||||
return $string;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function rewrite_adslLineType($adslLineType)
|
||||
{
|
||||
$adslLineTypes = array ('noChannel' => 'No Channel',
|
||||
@@ -967,6 +965,7 @@ function rewrite_adslLineType($adslLineType)
|
||||
$adslLineType = $text;
|
||||
}
|
||||
}
|
||||
|
||||
return($adslLineType);
|
||||
}
|
||||
|
||||
|
@@ -54,7 +54,7 @@ while ($device = mysql_fetch_array($device_query))
|
||||
notify($device, "Device Down: " . $device['hostname'], "Device Down: " . $device['hostname'] . " at " . date($config['timestamp_format']));
|
||||
}
|
||||
}
|
||||
eventlog("Device status changed to $stat", $device['device_id']);
|
||||
log_event("Device status changed to $stat", $device, strtolower($stat)));
|
||||
echo("Status Changed!\n");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user