Uptime plugin (reboot monitor)

General discussion about Plugins for Cacti

Moderators: Developers, Moderators

Post Reply
User avatar
gilles
Cacti User
Posts: 250
Joined: Tue Jul 12, 2005 8:16 pm

Uptime plugin (reboot monitor)

Post by gilles »

08/04/2008
http://gilles.boulon.free.fr/uptime/uptime-0.4.zip

Obsolete :
http://gilles.boulon.free.fr/uptime/uptime-0.3.rar

like suggesting by torstentfk, i think that Cacti must checks the uptime of
devices, and signal if the device has rebooted.

originals posts :
http://forums.cacti.net/about6508-0-asc-495.html
http://cactiusers.org/forums/topic253.html


so i have done this plugin, using thold and working with cactid


1. decompress plugin in <cacti base dir>\plugins\uptime

2. install plugin (see plugin architecture documentation)

3. optionnaly, use patched host.php (ONLY with Plugin Architecture 0.9)
(this file is only here to add fonctionnality to Uptime and Monitor plugins)

TODO :
i don't need them but all features i want to include are already in thold :
- weekend or hours exception (because my windows servers are rebooted the weekend...)
- global or extra notify...

NB :
for hours exception in thold, see this :
http://cactiusers.org/forums/viewtopic.php?p=1224#1224
Attachments
auth
auth
auth.png (9.72 KiB) Viewed 63097 times
uptime1
uptime1
uptime2.png (31.02 KiB) Viewed 63096 times
hosts
hosts
host.png (29.8 KiB) Viewed 63496 times
devices
devices
devices.png (12.31 KiB) Viewed 63497 times
Last edited by gilles on Tue Apr 08, 2008 2:51 pm, edited 6 times in total.
User avatar
twelzy
Cacti User
Posts: 83
Joined: Wed Mar 30, 2005 6:48 pm
Location: BRAZIL/Brasilia

Post by twelzy »

gilles,

Great plugin!
I have just a little suggestion...
Change the line:

Code: Select all

print round(($q_row["uptime"])/8640000, 1) . "d " . (($q_row["uptime"])%8640000)/360000) . "h";
to:

Code: Select all

$days=floor(($q_row["uptime"]/8640000));
$hours=floor((($q_row["uptime"]%8640000)/360000));
$minutes=floor(((($q_row["uptime"]%8640000)%360000)/6000));
print $days . "d " . $hours . "h " . $minutes ."m";
Thanks in advance!
(...and sorry for my poor English!)
Thanks in advance!
(And sorry for my poor English...)
_______________________________________
twelzy (Enio Sanches)
User avatar
twelzy
Cacti User
Posts: 83
Joined: Wed Mar 30, 2005 6:48 pm
Location: BRAZIL/Brasilia

Post by twelzy »

gilles,

I just received +1300 e-mails with the subject "Reboot detected of host:..." from all my hosts that are "Disabled" or "Down"!!!
There is any way to correct this?!
I think that the Uptime plugin should send e-amil only when a reboot is detected in a host, and not when a host is down or when it is disabled!

Thanks in advance!
(...and sorry for my poor English!)
Thanks in advance!
(And sorry for my poor English...)
_______________________________________
twelzy (Enio Sanches)
User avatar
gilles
Cacti User
Posts: 250
Joined: Tue Jul 12, 2005 8:16 pm

Post by gilles »

I thank you for your message.
twelzy wrote: I think that the Uptime plugin should send e-amil only when a reboot is detected in a host, and not when a host is down or when it is disabled!
I have updated the plugin.

Now, it check if host is down or disabled.

I have also resolve a bug for the checkbox "check uptime".

I have updated too "host.php".

I'm going to see a method to clean the table "uptime" when you delete a host.
torstentfk
Cacti User
Posts: 367
Joined: Tue Apr 05, 2005 9:52 am
Location: Munich, Germany

Post by torstentfk »

Hi,

I am happy that my suggestion is now ready for a plugin.
I change my installation and found some issues:
- the sorting o fthe uptime is not correct.
Please use BIGINT as the type of uptime not strings.
- the sort for Uptime-ASC/DESC does not remove other sorting. everytime i click on Uptime (for resorting) I get different views.
- posibility for mass-change to enable all hosts to check uptime.
(I made this via phpmyadmin)

...Works great!

Torsten
User avatar
gilles
Cacti User
Posts: 250
Joined: Tue Jul 12, 2005 8:16 pm

Post by gilles »

torstentfk wrote: Please use BIGINT as the type of uptime not strings.
- posibility for mass-change to enable all hosts to check uptime.
Torsten
Done.
User avatar
gilles
Cacti User
Posts: 250
Joined: Tue Jul 12, 2005 8:16 pm

Post by gilles »

Uptime plugin has been updated.
Attachments
tab
tab
tab_uptime.gif (2.31 KiB) Viewed 63093 times
shakey_1
Posts: 42
Joined: Thu Feb 16, 2006 12:49 pm

Post by shakey_1 »

I have installed the uptime plugin and it is working as I see the uptime on the devices page, but when I go to the "Uptime" tab, none of the systems that I have chosen to be monitored are listed? I noticed in your images that you have an option to monitor uptime in the drop down menu that I do not have (I have the checkbox on the individual devices page). Am I missing a step somewhere or would this be a part of the patched host file that is included? thanks.

***EDIT*** Sorry, just used the patched host.php file and it does add the uptime option to the drop down menu and also just realized that the "Uptime" tab lists last reboot and since none of my systems have been rebooted, probably explains why there is no data there. :oops:
r_chetanjain
Cacti User
Posts: 83
Joined: Fri Aug 22, 2003 4:33 am

might be install problem

Post by r_chetanjain »

Its not showing any thing on the devices page....do i need to install the .sql file with the command mysql -p cacti < uptime.sql.....provided in the rar file....its showing N/A....but i have snmp enabled on all the devices....

Chetan Jain.
magix
Posts: 4
Joined: Fri Jun 02, 2006 4:41 am

problem uptime

Post by magix »

I received 100 e-mails with the subject "Reboot detected of host:..." everyday

Directory: uptime
Version: 0.3
Author: Gilles Boulon
Home Page: http://forums.cacti.net/viewtopic.php?t=13510

Please help me
torstentfk
Cacti User
Posts: 367
Joined: Tue Apr 05, 2005 9:52 am
Location: Munich, Germany

Post by torstentfk »

Hi,

the reboot-monitor alert if the device is more than 497 days up, Mail:
"Host : xxxxx, old uptime was : 4294951006 (497.1d), new is : 13353 (0d)"
(The snmp-variable only stores 32bit of ticks=497 days)

It would be nice, if the plugin checks the old uptime and if it detects a reboot it should check also the uptime beeing between 497 and 498 days. If it is so there should be no alarm.

Torsten
Allen K
Posts: 25
Joined: Sat Oct 15, 2005 9:34 pm

Great Tool.. feature suggestion

Post by Allen K »

Great plugin work !!

This has been working very well in our case, I would like to offer a feature suggestion. Our network has many technicians for many different circuts. We monitor links for other companies as well.. I would like to be able to send individual notices for each device to only certain technicians. For example, reboots should notify:

device1 : tech1@host.com, admin@network.com
device2 : tech2@othercompany.com, admin@othercompany.com

Is that something that can be coded into the plugin?

Thanks !!
torstentfk
Cacti User
Posts: 367
Joined: Tue Apr 05, 2005 9:52 am
Location: Munich, Germany

Post by torstentfk »

torstentfk wrote:Hi,

the reboot-monitor alert if the device is more than 497 days up, Mail:
"Host : xxxxx, old uptime was : 4294951006 (497.1d), new is : 13353 (0d)"
(The snmp-variable only stores 32bit of ticks=497 days)

It would be nice, if the plugin checks the old uptime and if it detects a reboot it should check also the uptime beeing between 497 and 498 days. If it is so there should be no alarm.

Torsten
Found time to change it: file "check-uptime"
Insert before last if-Statement: if (($old_uptime<4294937286) || ($old_uptime>4294967297)) {
insert after befor last 3rd } another }to close the new if-statement

Also changed the thold_mail - function call:
thold_mail($global_alert_address, '', 'Reboot detected at' . $reboot_date . ' of host : ' . $q_row........

Torsten
Last edited by torstentfk on Tue Jul 11, 2006 2:52 am, edited 1 time in total.
torstentfk
Cacti User
Posts: 367
Joined: Tue Apr 05, 2005 9:52 am
Location: Munich, Germany

Post by torstentfk »

Hello developer,

found a bug for computing the uptime at host.php. The floor function could not read BIGINT or it does not run with very big numbers.
I changed this:

Code: Select all

# diff host.new  host.php
835,836c835
<       $sql_where =" ON host.id=uptime.id ";
<     $sql_where .= "where (host.hostname like '%%" . $_REQUEST["filter"] . "%%' OR host.description like '%%" . $_REQUEST["filter"] . "%%')";
---
>     $sql_where = "where (host.hostname like '%%" . $_REQUEST["filter"] . "%%' OR host.description like '%%" . $_REQUEST["filter"] . "%%')";
852a852
> 
857c857
<               from host LEFT JOIN uptime
---
>               from host
870,872c870,871
<               host.availability,
<                 uptime.uptime
<               FROM host LEFT JOIN uptime
---
>               host.availability
>               FROM host
909c908
<               "avg_time" => array("Average (ms)", "DESC"),
---
>               "avg_time" => array("Average (ms>", "DESC"),
940,942c939,942
<     $days=floor($q_row["uptime"]/8640000); $r=$q_row["uptime"]-$days*8640000;
<     $hours=floor(  $r/360000 );  $r=$q_row["uptime"]-$days*8640000-$hours*360000;
<     $minutes=floor($r/6000); 
---
> 
>     $days=floor(($q_row["uptime"]/8640000)); 
>     $hours=floor((($q_row["uptime"]%8640000)/360000)); 
>     $hours=floor((($q_row["uptime"]%8640000)/360000)); 
>     $minutes=floor(((($q_row["uptime"]%8640000)%360000)/6000)); 

I use the host.php version where I can sort the columns by clicking in the headers. Please check this and incoorperate it in the future versions.

Torsten
User avatar
MikeP
Posts: 14
Joined: Thu Nov 03, 2005 11:51 am
Location: Elgin, Illinois
Contact:

Re: Uptime plugin (reboot monitor)

Post by MikeP »

gilles wrote:so i have done this plugin, using thold and working with cactid


1. decompress plugin in <cacti base dir>\plugins\uptime

2. install plugin (see plugin architecture documentation)

3. optionnaly, use patched host.php (ONLY with Plugin Architecture 0.9)
(this file is only here to add fonctionnality to Uptime and Monitor plugins)
This looks like an awesome patch. I am having troubles getting it to install. I have decompressed the files but am not sure how to install it. Can someone help?

Thanks,

Mike
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests