mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
moar.
git-svn-id: http://www.observium.org/svn/observer/trunk@1899 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
8
irc.php
8
irc.php
@@ -49,13 +49,13 @@ $chan = "#observium";
|
||||
|
||||
$bot = &new observiumbot();
|
||||
$irc = &new Net_SmartIRC();
|
||||
$irc->setUseSockets( TRUE );
|
||||
$irc->setUseSockets(TRUE);
|
||||
|
||||
$irc->registerActionhandler( SMARTIRC_TYPE_CHANNEL, '!device', $bot, 'device_info' );
|
||||
$irc->registerActionhandler( SMARTIRC_TYPE_CHANNEL, '!port', $bot, 'port_info' );
|
||||
$irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '!device', $bot, 'device_info');
|
||||
$irc->registerActionhandler(SMARTIRC_TYPE_CHANNEL, '!port', $bot, 'port_info');
|
||||
|
||||
$irc->connect($host, $port));
|
||||
$irc->login($nick, 'Observium Bot', 0, $nick );
|
||||
$irc->login($nick, 'Observium Bot', 0, $nick);
|
||||
$irc->join(array($chan))));
|
||||
$irc->listen();
|
||||
$irc->disconnect();
|
||||
|
@@ -6,16 +6,19 @@ include("config.php");
|
||||
include("includes/functions.php");
|
||||
|
||||
$device_query = mysql_query("SELECT * FROM `devices` WHERE `device_id` LIKE '%" . $argv[1] . "' AND disabled = '0' ORDER BY `device_id` DESC");
|
||||
while ($device = mysql_fetch_array($device_query)) {
|
||||
|
||||
while ($device = mysql_fetch_array($device_query))
|
||||
{
|
||||
$port = $device['port'];
|
||||
|
||||
echo($device['hostname']. " ");
|
||||
|
||||
if( isPingable($device['hostname']) ) {
|
||||
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';
|
||||
@@ -24,27 +27,29 @@ while ($device = mysql_fetch_array($device_query)) {
|
||||
$status='0';
|
||||
}
|
||||
|
||||
|
||||
if($status == '1') {
|
||||
if ($status == '1')
|
||||
{
|
||||
echo("Up\n");
|
||||
} else {
|
||||
echo("Down\n");
|
||||
}
|
||||
|
||||
if($status != $device['status']) {
|
||||
|
||||
if ($status != $device['status'])
|
||||
{
|
||||
mysql_query("UPDATE `devices` SET `status`= '$status' WHERE `device_id` = '" . $device['device_id'] . "'");
|
||||
if ($status == '1') {
|
||||
|
||||
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'])
|
||||
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')");
|
||||
if($config['alerts']['email']['enable'])
|
||||
if ($config['alerts']['email']['enable'])
|
||||
{
|
||||
notify($device, "Device Down: " . $device['hostname'], "Device Down: " . $device['hostname'] . " at " . date($config['timestamp_format']));
|
||||
}
|
||||
@@ -53,4 +58,5 @@ while ($device = mysql_fetch_array($device_query)) {
|
||||
echo("Status Changed!\n");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user