mirror of
				https://github.com/librenms/librenms.git
				synced 2024-10-07 16:52:45 +00:00 
			
		
		
		
	updated email sending to allow global disabling and sysContact override
git-svn-id: http://www.observium.org/svn/observer/trunk@1344 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
		@@ -30,8 +30,7 @@ if($errored) { ## If there are errored ports
 | 
			
		||||
    $i++;
 | 
			
		||||
  } 
 | 
			
		||||
  ## Send the alert email
 | 
			
		||||
  mail($config['email_default'], "ObserverNMS detected errors on $i interface" . ($i != 1 ? 's' : ''), $msg, $config['email_headers']);
 | 
			
		||||
  echo($msg);
 | 
			
		||||
  notify($device, "ObserverNMS detected errors on $i interface" . ($i != 1 ? 's' : ''), $msg);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
 
 | 
			
		||||
@@ -26,11 +26,11 @@ while ($service = mysql_fetch_array($query)) {
 | 
			
		||||
    if($status == "1") {
 | 
			
		||||
        $msg  = "Service Up: " . $service['service_type'] . " on " . $service['hostname'];
 | 
			
		||||
        $msg .= " at " . date($config['timestamp_format']);
 | 
			
		||||
	mail($email, "Service Up: " . $service['service_type'] . " on " . $service['hostname'], $msg, $config['email_headers']);
 | 
			
		||||
        notify($device, "Service Up: " . $service['service_type'] . " on " . $service['hostname'], $msg);
 | 
			
		||||
    } elseif ($status == "0") {
 | 
			
		||||
	$msg  = "Service Down: " . $service['service_type'] . " on " . $service['hostname'];
 | 
			
		||||
        $msg .= " at " . date($config['timestamp_format']);
 | 
			
		||||
        mail($email, "Service Down: " . $service['service_type'] . " on " . $service['hostname'], $msg, $config['email_headers']);
 | 
			
		||||
        notify($device, "Service Down: " . $service['service_type'] . " on " . $service['hostname'], $msg);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  } else { unset($updated); }
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								html/images/os/zywall.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								html/images/os/zywall.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 1.3 KiB  | 
@@ -41,9 +41,9 @@ $config['snmp']['retries'] = 6; # how many times to retry the query
 | 
			
		||||
 | 
			
		||||
### Alerting Settings
 | 
			
		||||
 | 
			
		||||
#$config['alert']['email']]'default']      = NULL;    ## Default alert recipient
 | 
			
		||||
#$config['alert']['email']['default_only'] = FALSE;   ## Only use default recipient
 | 
			
		||||
#$config['alert']['email']['enable']	  = TRUE;    ## Enable email alerts
 | 
			
		||||
$config['alerts']['email']['default']      = NULL;    ## Default alert recipient
 | 
			
		||||
$config['alerts']['email']['default_only'] = FALSE;   ## Only use default recipient
 | 
			
		||||
$config['alerts']['email']['enable']	   = TRUE;    ## Enable email alerts
 | 
			
		||||
 | 
			
		||||
### Cosmetics
 | 
			
		||||
 | 
			
		||||
@@ -61,7 +61,7 @@ $list_highlight  = "#ffcccc";
 | 
			
		||||
$warn_colour_a = "#ffeeee";
 | 
			
		||||
$warn_colour_b = "#ffcccc";
 | 
			
		||||
 | 
			
		||||
$config['graph_colours']['mixed']  = array("CC0000", "008C00", "4096EE", "73880A", "D01F3C", "36393D", "FF0084");
 | 
			
		||||
$config['graph_colours']['mixed']   = array('CC0000','008C00','4096EE','73880A','D01F3C','36393D','FF0084');
 | 
			
		||||
$config['graph_colours']['greens']  = array('B6D14B','91B13C','6D912D','48721E','24520F','003300');
 | 
			
		||||
$config['graph_colours']['pinks']   = array('D0558F','B34773','943A57','792C38','5C1F1E','401F10');
 | 
			
		||||
$config['graph_colours']['blues']   = array('A0A0E5','8080BD','606096','40406F','202048','000033');
 | 
			
		||||
 
 | 
			
		||||
@@ -627,8 +627,24 @@ function notify($device,$title,$message)
 | 
			
		||||
{
 | 
			
		||||
  global $config;
 | 
			
		||||
 | 
			
		||||
  if ($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
 | 
			
		||||
  mail($email, $title, $message, $config['email_headers']);
 | 
			
		||||
  if($config['alerts']['email']['enable']) 
 | 
			
		||||
  {
 | 
			
		||||
    if($config['alerts']['email']['default_only']) 
 | 
			
		||||
    {
 | 
			
		||||
      $email = $config['alerts']['email']['default'];
 | 
			
		||||
    } else {
 | 
			
		||||
      if ($device['sysContact']) 
 | 
			
		||||
      { 
 | 
			
		||||
        $email = $device['sysContact']; 
 | 
			
		||||
      } else { 
 | 
			
		||||
        $email = $config['alerts']['email']['default']; 
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    if($email) 
 | 
			
		||||
    {
 | 
			
		||||
      mail($email, $title, $message, $config['email_headers']);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function formatCiscoHardware(&$device, $short = false)
 | 
			
		||||
 
 | 
			
		||||
@@ -78,20 +78,19 @@ if ($device['os'] == "junos")
 | 
			
		||||
  {
 | 
			
		||||
    if ($bgpPeerFsmEstablishedTime < $peer['bgpPeerFsmEstablishedTime'] || $bgpPeerState != $peer['bgpPeerState'])
 | 
			
		||||
    {
 | 
			
		||||
      if ($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
 | 
			
		||||
      if ($peer['bgpPeerState'] == $bgpPeerState)
 | 
			
		||||
      {
 | 
			
		||||
        mail($email, "BGP Session flapped: " . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ' - ' . $peer['astext'] . ')', "BGP Session flapped " . formatUptime($bgpPeerFsmEstablishedTime) . " ago.\n\nHostname : " . $device['hostname'] . "\nPeer IP  : " . $peer['bgpPeerIdentifier'] . "\nRemote AS: " . $peer['bgpPeerRemoteAs'] . ' ('.$peer['astext'].')', $config['email_headers']);
 | 
			
		||||
        notify($device, "BGP Session flapped: " . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ' - ' . $peer['astext'] . ')', "BGP Session flapped " . formatUptime($bgpPeerFsmEstablishedTime) . " ago.\n\nHostname : " . $device['hostname'] . "\nPeer IP  : " . $peer['bgpPeerIdentifier'] . "\nRemote AS: " . $peer['bgpPeerRemoteAs'] . ' ('.$peer['astext'].')');
 | 
			
		||||
        log_event('BGP Session Flap: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ')', $device['device_id'], 'bgpPeer', $bgpPeer_id);
 | 
			
		||||
      }
 | 
			
		||||
      else if ($bgpPeerState == "established")
 | 
			
		||||
      {
 | 
			
		||||
        mail($email, "BGP Session up: " . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ' - ' . $peer['astext'] . ')', "BGP Session up since " . formatUptime($bgpPeerFsmEstablishedTime) . ".\n\nHostname : " . $device['hostname'] . "\nPeer IP  : " . $peer['bgpPeerIdentifier'] . "\nRemote AS: " . $peer['bgpPeerRemoteAs'] . ' ('.$peer['astext'].')', $config['email_headers']);
 | 
			
		||||
        notify($device, "BGP Session up: " . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ' - ' . $peer['astext'] . ')', "BGP Session up since " . formatUptime($bgpPeerFsmEstablishedTime) . ".\n\nHostname : " . $device['hostname'] . "\nPeer IP  : " . $peer['bgpPeerIdentifier'] . "\nRemote AS: " . $peer['bgpPeerRemoteAs'] . ' ('.$peer['astext'].')');
 | 
			
		||||
        log_event('BGP Session Up: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ')', $device['device_id'], 'bgpPeer', $bgpPeer_id);
 | 
			
		||||
      }
 | 
			
		||||
      else if ($peer['bgpPeerState'] == "established")
 | 
			
		||||
      {
 | 
			
		||||
        mail($email, "BGP Session down: " . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ' - ' . $peer['astext'] . ')', "BGP Session down since " . formatUptime($bgpPeerFsmEstablishedTime) . ".\n\nHostname : " . $device['hostname'] . "\nPeer IP  : " . $peer['bgpPeerIdentifier'] . "\nRemote AS: " . $peer['bgpPeerRemoteAs'] . ' ('.$peer['astext'].')', $config['email_headers']);
 | 
			
		||||
        notify($device, "BGP Session down: " . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ' - ' . $peer['astext'] . ')', "BGP Session down since " . formatUptime($bgpPeerFsmEstablishedTime) . ".\n\nHostname : " . $device['hostname'] . "\nPeer IP  : " . $peer['bgpPeerIdentifier'] . "\nRemote AS: " . $peer['bgpPeerRemoteAs'] . ' ('.$peer['astext'].')');
 | 
			
		||||
        log_event('BGP Session Down: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ')', $device['device_id'], 'bgpPeer', $bgpPeer_id);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -32,19 +32,17 @@ while($dbcurrent = mysql_fetch_array($current_data)) {
 | 
			
		||||
# FIXME also warn when crossing WARN level!!
 | 
			
		||||
  if($dbcurrent['sensor_current'] > $dbcurrent['sensor_limit_low'] && $current <= $dbcurrent['sensor_limit_low']) 
 | 
			
		||||
  {
 | 
			
		||||
    if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
 | 
			
		||||
    $msg  = "Current Alarm: " . $device['hostname'] . " " . $dbcurrent['sensor_descr'] . " is " . $current . "A (Limit " . $dbcurrent['sensor_limit'];
 | 
			
		||||
    $msg .= "A) at " . date($config['timestamp_format']);
 | 
			
		||||
    mail($email, "Current Alarm: " . $device['hostname'] . " " . $dbcurrent['sensor_descr'], $msg, $config['email_headers']);
 | 
			
		||||
    notify($device, "Current Alarm: " . $device['hostname'] . " " . $dbcurrent['sensor_descr'], $msg);
 | 
			
		||||
    echo("Alerting for " . $device['hostname'] . " " . $dbcurrent['sensor_descr'] . "\n");
 | 
			
		||||
    log_event('Current ' . $dbcurrent['sensor_descr'] . " under threshold: " . $current . " A (< " . $dbcurrent['sensor_limit_low'] . " A)", $device['device_id'], 'current', $current['sensor_id']);
 | 
			
		||||
  }
 | 
			
		||||
  else if($dbcurrent['sensor_current'] < $dbcurrent['sensor_limit'] && $current >= $dbcurrent['sensor_limit']) 
 | 
			
		||||
  {
 | 
			
		||||
    if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
 | 
			
		||||
    $msg  = "Current Alarm: " . $device['hostname'] . " " . $dbcurrent['sensor_descr'] . " is " . $current . "A (Limit " . $dbcurrent['sensor_limit'];
 | 
			
		||||
    $msg .= "A) at " . date($config['timestamp_format']);
 | 
			
		||||
    mail($email, "Current Alarm: " . $device['hostname'] . " " . $dbcurrent['sensor_descr'], $msg, $config['email_headers']);
 | 
			
		||||
    notify($device, "Current Alarm: " . $device['hostname'] . " " . $dbcurrent['sensor_descr'], $msg);
 | 
			
		||||
    echo("Alerting for " . $device['hostname'] . " " . $dbcurrent['sensor_descr'] . "\n");
 | 
			
		||||
    log_event('Current ' . $dbcurrent['sensor_descr'] . " above threshold: " . $current . " A (> " . $dbcurrent['sensor_limit'] . " A)", $device['device_id'], 'current', $current['sensor_id']);
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -6,9 +6,6 @@ while($fanspeed = mysql_fetch_array($fan_data)) {
 | 
			
		||||
 | 
			
		||||
  echo("Checking fan " . $fanspeed['sensor_descr'] . "... ");
 | 
			
		||||
 | 
			
		||||
  #$fan_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m SNMPv2-MIB -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $fanspeed['sensor_oid'] . "|grep -v \"No Such Instance\"";
 | 
			
		||||
  #$fan = trim(str_replace("\"", "", shell_exec($fan_cmd)));
 | 
			
		||||
 | 
			
		||||
  $fan = snmp_get($device, $fanspeed['sensor_oid'], "-OUqnv", "SNMPv2-MIB");
 | 
			
		||||
 | 
			
		||||
  if ($fanspeed['sensor_precision']) { $fan = $fan / $fanspeed['sensor_precision']; }
 | 
			
		||||
@@ -33,7 +30,7 @@ while($fanspeed = mysql_fetch_array($fan_data)) {
 | 
			
		||||
    if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
 | 
			
		||||
    $msg  = "Fan Alarm: " . $device['hostname'] . " " . $fanspeed['sensor_descr'] . " is " . $fan . "rpm (Limit " . $fanspeed['sensor_limit'];
 | 
			
		||||
    $msg .= "rpm) at " . date($config['timestamp_format']);
 | 
			
		||||
    mail($email, "Fan Alarm: " . $device['hostname'] . " " . $fanspeed['sensor_descr'], $msg, $config['email_headers']);
 | 
			
		||||
    notify($device, "Fan Alarm: " . $device['hostname'] . " " . $fanspeed['sensor_descr'], $msg);
 | 
			
		||||
    echo("Alerting for " . $device['hostname'] . " " . $fanspeed['sensor_descr'] . "\n");
 | 
			
		||||
    log_event('Fan speed ' . $fanspeed['sensor_descr'] . " under threshold: " . $fanspeed['sensor_current'] . " rpm (> " . $fanspeed['sensor_limit'] . " rpm)", $device['device_id'], 'fanspeed', $fanspeed['sensor_id']);
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -6,12 +6,8 @@ while($frequency = mysql_fetch_array($freq_data)) {
 | 
			
		||||
 | 
			
		||||
  echo("Checking frequency " . $frequency['freq_descr'] . "... ");
 | 
			
		||||
 | 
			
		||||
  #$freq_cmd = $config['snmpget'] . " -M ".$config['mibdir'] . " -m SNMPv2-MIB -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $frequency['freq_oid'] . "|grep -v \"No Such Instance\"";
 | 
			
		||||
  #$freq = trim(str_replace("\"", "", shell_exec($freq_cmd)));
 | 
			
		||||
 | 
			
		||||
  $freq = snmp_get($device, $frequency['freq_oid'], "-OUqnv", "SNMPv2-MIB");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  if ($frequency['freq_precision']) 
 | 
			
		||||
  {
 | 
			
		||||
    $freq = $freq / $frequency['freq_precision'];
 | 
			
		||||
@@ -38,7 +34,7 @@ while($frequency = mysql_fetch_array($freq_data)) {
 | 
			
		||||
    if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
 | 
			
		||||
    $msg  = "Frequency Alarm: " . $device['hostname'] . " " . $frequency['freq_descr'] . " is " . $freq . "Hz (Limit " . $frequency['freq_limit'];
 | 
			
		||||
    $msg .= "Hz) at " . date($config['timestamp_format']);
 | 
			
		||||
    mail($email, "Frequency Alarm: " . $device['hostname'] . " " . $frequency['freq_descr'], $msg, $config['email_headers']);
 | 
			
		||||
    notify($device, "Frequency Alarm: " . $device['hostname'] . " " . $frequency['freq_descr'], $msg);
 | 
			
		||||
    echo("Alerting for " . $device['hostname'] . " " . $frequency['freq_descr'] . "\n");
 | 
			
		||||
    log_event('Frequency ' . $frequency['freq_descr'] . " under threshold: " . $freq . " Hz (< " . $frequency['freq_limit_low'] . " Hz)", $device['device_id'] , 'frequency', $frequency['freq_id']);
 | 
			
		||||
  }
 | 
			
		||||
@@ -47,7 +43,7 @@ while($frequency = mysql_fetch_array($freq_data)) {
 | 
			
		||||
    if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
 | 
			
		||||
    $msg  = "Frequency Alarm: " . $device['hostname'] . " " . $frequency['freq_descr'] . " is " . $freq . "Hz (Limit " . $frequency['freq_limit'];
 | 
			
		||||
    $msg .= "Hz) at " . date($config['timestamp_format']);
 | 
			
		||||
    mail($email, "Frequency Alarm: " . $device['hostname'] . " " . $frequency['freq_descr'], $msg, $config['email_headers']);
 | 
			
		||||
    notify($device, "Frequency Alarm: " . $device['hostname'] . " " . $frequency['freq_descr'], $msg);
 | 
			
		||||
    echo("Alerting for " . $device['hostname'] . " " . $frequency['freq_descr'] . "\n");
 | 
			
		||||
    log_event('Frequency ' . $frequency['freq_descr'] . " above threshold: " . $freq . " Hz (> " . $frequency['freq_limit'] . " Hz)", $device['device_id'], 'frequency', $frequency['freq_id']);
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -9,6 +9,8 @@ while($humidity = mysql_fetch_array($hum_data)) {
 | 
			
		||||
  $hum_cmd = $config['snmpget'] . " -M ".$config['mibdir']. " -m SNMPv2-MIB -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $humidity['sensor_oid'] . "|grep -v \"No Such Instance\"";
 | 
			
		||||
  $hum = trim(str_replace("\"", "", shell_exec($hum_cmd)));
 | 
			
		||||
 | 
			
		||||
  ## fixme snmp_get()
 | 
			
		||||
 | 
			
		||||
  if ($humidity['sensor_precision']) 
 | 
			
		||||
  {
 | 
			
		||||
    $hum = $hum / $humidity['sensor_precision'];
 | 
			
		||||
@@ -35,7 +37,7 @@ while($humidity = mysql_fetch_array($hum_data)) {
 | 
			
		||||
    if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
 | 
			
		||||
    $msg  = "Humidity Alarm: " . $device['hostname'] . " " . $humidity['sensor_descr'] . " is " . $hum . "% (Limit " . $humidity['sensor_limit'];
 | 
			
		||||
    $msg .= "%) at " . date($config['timestamp_format']);
 | 
			
		||||
    mail($email, "Humidity Alarm: " . $device['hostname'] . " " . $humidity['sensor_descr'], $msg, $config['email_headers']);
 | 
			
		||||
    notify($device, "Humidity Alarm: " . $device['hostname'] . " " . $humidity['sensor_descr'], $msg);
 | 
			
		||||
    echo("Alerting for " . $device['hostname'] . " " . $humidity['sensor_descr'] . "\n");
 | 
			
		||||
    log_event('Frequency ' . $humidity['sensor_descr'] . " under threshold: " . $hum . " % (< " . $humidity['sensor_limit_low'] . " %)", $device['device_id'] , 'humidity', $humidity['sensor_id']);
 | 
			
		||||
  }
 | 
			
		||||
@@ -44,7 +46,7 @@ while($humidity = mysql_fetch_array($hum_data)) {
 | 
			
		||||
    if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
 | 
			
		||||
    $msg  = "Humidity Alarm: " . $device['hostname'] . " " . $humidity['sensor_descr'] . " is " . $hum . "% (Limit " . $humidity['sensor_limit'];
 | 
			
		||||
    $msg .= "%) at " . date($config['timestamp_format']);
 | 
			
		||||
    mail($email, "Humidity Alarm: " . $device['hostname'] . " " . $humidity['sensor_descr'], $msg, $config['email_headers']);
 | 
			
		||||
    notify($device, "Humidity Alarm: " . $device['hostname'] . " " . $humidity['sensor_descr'], $msg);
 | 
			
		||||
    echo("Alerting for " . $device['hostname'] . " " . $humidity['sensor_descr'] . "\n");
 | 
			
		||||
    log_event('Humidity ' . $humidity['sensor_descr'] . " above threshold: " . $hum . " % (> " . $humidity['sensor_limit'] . " %)", $device['device_id'], 'humidity', $humidity['sensor_id']);
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -211,14 +211,13 @@
 | 
			
		||||
 | 
			
		||||
      // Send alerts for interface flaps.
 | 
			
		||||
      if ($config['warn']['ifdown'] && ($port['ifOperStatus'] != $this_port['ifOperStatus'])) {
 | 
			
		||||
          if ($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
 | 
			
		||||
          if ($this_port['ifAlias']) { $falias = preg_replace('/^"/', '', $this_port['ifAlias']); $falias = preg_replace('/"$/', '', $falias); $full = $this_port['ifDescr'] . " (" . $falias . ")"; } else { $full = $this_port['ifDescr']; }
 | 
			
		||||
          switch ($this_port['ifOperStatus']) {
 | 
			
		||||
              case "up":
 | 
			
		||||
                  mail($email, "Interface UP - " . $device['hostname'] . " - " . $full, "Device:    " . $device['hostname'] . "\nInterface: " . $full . "\nTimestamp: " . date($config['timestamp_format']), $config['email_headers']);
 | 
			
		||||
                  notify($device, "Interface UP - " . $device['hostname'] . " - " . $full, "Device:    " . $device['hostname'] . "\nInterface: " . $full . "\nTimestamp: " . date($config['timestamp_format']));
 | 
			
		||||
              break;
 | 
			
		||||
              case "down":
 | 
			
		||||
                  mail($email, "Interface DOWN - " . $device['hostname'] . " - " . $full, "Device:    " . $device['hostname'] . "\nInterface: " . $full . "\nTimestamp: " . date($config['timestamp_format']), $config['email_headers']);
 | 
			
		||||
                  notify($device, "Interface DOWN - " . $device['hostname'] . " - " . $full, "Device:    " . $device['hostname'] . "\nInterface: " . $full . "\nTimestamp: " . date($config['timestamp_format']));
 | 
			
		||||
              break;
 | 
			
		||||
          }
 | 
			
		||||
      }
 | 
			
		||||
 
 | 
			
		||||
@@ -38,7 +38,7 @@ while($temperature = mysql_fetch_array($temp_data)) {
 | 
			
		||||
    if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
 | 
			
		||||
    $msg  = "Temp Alarm: " . $device['hostname'] . " " . $temperature['sensor_descr'] . " is " . $temp . " (Limit " . $temperature['sensor_limit'];
 | 
			
		||||
    $msg .= ") at " . date($config['timestamp_format']);
 | 
			
		||||
    mail($email, "Temp Alarm: " . $device['hostname'] . " " . $temperature['sensor_descr'], $msg, $config['email_headers']);
 | 
			
		||||
    notify($device, "Temp Alarm: " . $device['hostname'] . " " . $temperature['sensor_descr'], $msg);
 | 
			
		||||
    echo("Alerting for " . $device['hostname'] . " " . $temperature['sensor_descr'] . "\n");
 | 
			
		||||
    log_event('Temperature ' . $temperature['sensor_descr'] . " over threshold: " . $temp . " <20>C (> " . $temperature['sensor_limit'] . " <20>C)", $device['device_id'], 'temperature', $temperature['sensor_id']);
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -34,7 +34,7 @@ while($voltage = mysql_fetch_array($volt_data)) {
 | 
			
		||||
    if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
 | 
			
		||||
    $msg  = "Voltage Alarm: " . $device['hostname'] . " " . $voltage['sensor_descr'] . " is " . $volt . "V (Limit " . $voltage['sensor_limit'];
 | 
			
		||||
    $msg .= "V) at " . date($config['timestamp_format']);
 | 
			
		||||
    mail($email, "Voltage Alarm: " . $device['hostname'] . " " . $voltage['sensor_descr'], $msg, $config['email_headers']);
 | 
			
		||||
    notify($device, "Voltage Alarm: " . $device['hostname'] . " " . $voltage['sensor_descr'], $msg);
 | 
			
		||||
    echo("Alerting for " . $device['hostname'] . " " . $voltage['sensor_descr'] . "\n");
 | 
			
		||||
    log_event('Voltage ' . $voltage['sensor_descr'] . " under threshold: " . $volt . " V (< " . $voltage['sensor_limit_low'] . " V)", $device['device_id'], 'voltage', $voltage['sensor_id']);
 | 
			
		||||
  }
 | 
			
		||||
@@ -43,11 +43,10 @@ while($voltage = mysql_fetch_array($volt_data)) {
 | 
			
		||||
    if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
 | 
			
		||||
    $msg  = "Voltage Alarm: " . $device['hostname'] . " " . $voltage['sensor_descr'] . " is " . $volt . "V (Limit " . $voltage['sensor_limit'];
 | 
			
		||||
    $msg .= "V) at " . date($config['timestamp_format']);
 | 
			
		||||
    mail($email, "Voltage Alarm: " . $device['hostname'] . " " . $voltage['sensor_descr'], $msg, $config['email_headers']);
 | 
			
		||||
    notify($device, "Voltage Alarm: " . $device['hostname'] . " " . $voltage['sensor_descr'], $msg);
 | 
			
		||||
    echo("Alerting for " . $device['hostname'] . " " . $voltage['sensor_descr'] . "\n");
 | 
			
		||||
    log_event('Voltage ' . $voltage['sensor_descr'] . " above threshold: " . $volt . " V (> " . $voltage['sensor_limit'] . " V)", $device['device_id'], 'voltage', $voltage['sensor_id']);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  mysql_query("UPDATE sensor SET volt_current = '$volt' WHERE sensor_class='voltage' AND volt_id = '" . $voltage['sensor_id'] . "'");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -107,6 +107,11 @@ $config['os']['speedtouch']['text']     = "Thomson Speedtouch";
 | 
			
		||||
$config['os']['speedtouch']['ifname']	= 1;
 | 
			
		||||
$config['os']['speedtouch']['type']     = "network";
 | 
			
		||||
 | 
			
		||||
$config['os']['zywall']['text']     	= "ZyXEL ZyWALL";
 | 
			
		||||
$config['os']['zywall']['type']     	= "firewall";
 | 
			
		||||
$config['os']['zywall']['overgraph'][]  = "device_bits";
 | 
			
		||||
$config['os']['zywall']['overtext']     = "Traffic";
 | 
			
		||||
 | 
			
		||||
$config['os']['allied']['text']         = "AlliedWare";
 | 
			
		||||
$config['os']['allied']['type']         = "network";
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -40,17 +40,21 @@ while ($device = mysql_fetch_array($device_query)) {
 | 
			
		||||
 | 
			
		||||
   if($status != $device['status']) {
 | 
			
		||||
 | 
			
		||||
     if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
 | 
			
		||||
 | 
			
		||||
     mysql_query("UPDATE `devices` SET `status`= '$status' WHERE `device_id` = '" . $device['device_id'] . "'");
 | 
			
		||||
     if ($status == '1') { 
 | 
			
		||||
       $stat = "Up"; 
 | 
			
		||||
       mysql_query("INSERT INTO alerts (importance, device_id, message) VALUES ('0', '" . $device['device_id'] . "', 'Device is up\n')");
 | 
			
		||||
       mail($email, "Device Up: " . $device['hostname'], "Device Up: " . $device['hostname'] . " at " . date($config['timestamp_format']), $config['email_headers']);
 | 
			
		||||
       if($config['alerts']['email']['enable'])
 | 
			
		||||
       {
 | 
			
		||||
         notify($device, "Device Up: " . $device['hostname'], "Device Up: " . $device['hostname'] . " at " . date($config['timestamp_format']));
 | 
			
		||||
       }
 | 
			
		||||
     } else {
 | 
			
		||||
       $stat = "Down"; 
 | 
			
		||||
       mysql_query("INSERT INTO alerts (importance, device_id, message) VALUES ('9', '" . $device['device_id'] . "', 'Device is down\n')");
 | 
			
		||||
       mail($email, "Device Down: " . $device['hostname'], "Device Down: " . $device['hostname'] . " at " . date($config['timestamp_format']), $config['email_headers']);
 | 
			
		||||
       if($config['alerts']['email']['enable'])
 | 
			
		||||
       {
 | 
			
		||||
         notify($device, "Device Down: " . $device['hostname'], "Device Down: " . $device['hostname'] . " at " . date($config['timestamp_format']));
 | 
			
		||||
       }
 | 
			
		||||
     }
 | 
			
		||||
     eventlog("Device status changed to $stat", $device['device_id']);
 | 
			
		||||
     echo("Status Changed!\n");
 | 
			
		||||
 
 | 
			
		||||
@@ -86,7 +86,7 @@ while ($device = mysql_fetch_array($device_query)) {
 | 
			
		||||
    mysql_query("UPDATE `devices` SET `status` = '".$status."' WHERE `device_id` = '".$device['device_id']."'");
 | 
			
		||||
    mysql_query("INSERT INTO alerts (importance, device_id, message) VALUES ('0', '" . $device['device_id'] . "', 'Device is " .($status == '1' ? 'up' : 'down') . "')");
 | 
			
		||||
    log_event('Device status changed to ' . ($status == '1' ? 'Up' : 'Down'), $device['device_id'], ($status == '1' ? 'up' : 'down'));
 | 
			
		||||
    mail($email, "Device ".($status == '1' ? 'Up' : 'Down').": " . $device['hostname'], "Device ".($status == '1' ? 'up' : 'down').": " . $device['hostname'] . " at " . date($config['timestamp_format']), $config['email_headers']);
 | 
			
		||||
    alert($device, "Device ".($status == '1' ? 'Up' : 'Down').": " . $device['hostname'], "Device ".($status == '1' ? 'up' : 'down').": " . $device['hostname'] . " at " . date($config['timestamp_format']));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if ($status == "1") 
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user