cacti threshold propagation to Nagios passive check

Support questions about the Threshold plugin

Moderators: Developers, Moderators

Post Reply
prune
Posts: 23
Joined: Sun Sep 11, 2005 9:51 am
Location: Paris, France
Contact:

cacti threshold propagation to Nagios passive check

Post by prune »

We talked about that some time ago. As nobody wanted to go in that way, I did some changes in the plugin to support that. Here is how it work :

in Settings -> alerting threshold added a "Nagios Notification Options" where you specify :
* a checkbox to enable the module or not
* Nagios Script where you specify a path to a script cacti will run when an a threshold is... thresholded :)

This way you can also change this script to do whatever you want.

Then, in the threshold page of every datasource, you can add (or not) in a Nagios module :

*Nagios Host Name : the name of the host you defines in Nagios
*Nagios Service Name : The service name defined in Nagios and attached to the host defined above.

Then you add a passive check in nagios like this :

Code: Select all

define service{
        use                             generic-service         ; Name of service template to use
        host_name                       encoder-tmp
        service_description             ENCODER-TMP_ENCODER_PROCESS
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              1
        normal_check_interval           5
        retry_check_interval            1
        contact_groups                  admins
        notification_options            w,u,c,r
        notification_interval           960
        notification_period             24x7
        active_checks_enabled           0
        check_command                   check_dummy
        }
with this definition, you have to define in cacti :

Code: Select all

Nagios Host Name : encoder-tmp
Nagios Service Name : ENCODER-TMP_ENCODER_PROCESS
The script executed by Cacti is like :

Code: Select all

> cat /opt/monitor/scripts/cacti-to-nagios.sh

#!/bin/sh
# this script copy the data in argument to the Nagios external command file

NAGIOS_FILE="/opt/monitor/nagios/var/rw/nagios.cmd"

echo $1 >> ${NAGIOS_FILE}
exit 0
When you start nagios, your check will remain in "not checked" state. You can give a passive check to initialise it.
When the threshold is reached, an entry is added to the passive check file in Nagios.

I have this working for few months now, so I think it is working well :)

I may give a diff file if someone is interested, and if someone want to add this to the official source.
Of course, this can be extended to work with any software, not only Nagios, and can easily be adapted to directly send the message by SMS.
--
Prune
(Dual G5/4go/RAID)
cigamit
Developer
Posts: 3367
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Post by cigamit »

Send me the diff and I will take a look at it. Might come in handy if you want to run "other" items too.
prune
Posts: 23
Joined: Sun Sep 11, 2005 9:51 am
Location: Paris, France
Contact:

Post by prune »

I will try to do this by the week-end. keep in touch
--
Prune
(Dual G5/4go/RAID)
melvinshaw
Posts: 6
Joined: Tue Feb 13, 2007 5:14 pm
Location: Columbus, OH

Post by melvinshaw »

Hey prune, you have a chance to run that diff? I think I might wanna a peak at it as well, if you don't mind.

-melvin
mastrboy
Posts: 26
Joined: Wed Aug 02, 2006 2:40 am

Post by mastrboy »

please share that diff file.

i have been waiting for this function for ages!
damien
Posts: 4
Joined: Tue Jan 03, 2006 6:01 am

Post by damien »

like this ? --> http://cactiusers.org/forums/topic425.html

maybe need to be rewriting
Fagao
Posts: 3
Joined: Tue Dec 23, 2003 5:40 am

Post by Fagao »

I used the code of the following user :
http://cactiusers.org/forums/topic425.html
to implement Passive check submitting to Nagios in the latest (0.3.9) version of the Thold plugin. Somebody interested to see the diff ?
flukester
Posts: 17
Joined: Fri Jan 16, 2009 3:01 pm
Location: Montreal, QC, Canada

Post by flukester »

Fagao wrote:I used the code of the following user :
http://cactiusers.org/forums/topic425.html
to implement Passive check submitting to Nagios in the latest (0.3.9) version of the Thold plugin. Somebody interested to see the diff ?
Yes! By all means, please post your diff file! :)

I have been looking for a working patch for thold 0.3.9. I have found a lot about 0.3.4 (prune's blog and patch) but haven't found a real discussion and patch about 0.3.9. With enough googling, I found the following diff:

http://forums.cacti.net/download.php?id=15035
which redirects to:
http://forums.cacti.net//files/thold_nagios_149.patch


It seems to be based off thold 0.3.9 but I can't find the matching thread or post nor do I know who the author is. There are no posts made by author "drich" here unless (s)he uses a different name here.

I haven't tested the patch yet, I'm not sure if it's complete or not. See how there are lines like this in the patch:
Only in thold: graph_thold.php
Only in thold: nagios.php
Only in thold: nagios-test.php
Only in thold: nsca.php


This looks like a missing option to diff (-N?) that would include new files as well, so I guess this patch is incomplete..


Can we please have a look at your diff? Maybe we can also try to track the author of this (incomplete) patch I referenced above and take the best of everybody's patches?


Thank you!
Antoine
flukester
Posts: 17
Joined: Fri Jan 16, 2009 3:01 pm
Location: Montreal, QC, Canada

Post by flukester »

flukester wrote:With enough googling, I found the following diff:

http://forums.cacti.net/download.php?id=15035
which redirects to:
http://forums.cacti.net//files/thold_nagios_149.patch


It seems to be based off thold 0.3.9 but I can't find the matching thread or post nor do I know who the author is. There are no posts made by author "drich" here unless (s)he uses a different name here.
Sorry to reply to myself, but I have found the thread where that patch is coming from. The author's name here is 'wwwdrich' and the thread is located here:

http://forums.cacti.net/viewtopic.php?t ... c&start=15

See towards the end of the thread (page 2). I'll be asking Dan if he can post an updated version of his patch, that would include the missing files (using 'diff -ruN')

Antoine
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests