Nagios plugin to monitor Cacti log

Addons for Cacti and discussion about those addons

Moderators: Moderators, Developers

Post Reply
Author
Message
User avatar
rony
Developer/Forum Admin
Posts: 6016
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Nagios plugin to monitor Cacti log

#1 Post by rony » Thu Aug 03, 2006 8:37 pm

Well, I was on a kick to write a shell script monitor a Cacti server, I figure I might as well write a nagios plugin to monitor the Cacti log.

Parameters can be set from command line or by editing the script.

Code: Select all

Cacti log monitoring plugins for Nagios
Copyright (C) 2006 The Cacti Group

Syntax:

  cacti_log_check.sh <Path> <Warn> <Critical> <Interval>

    <Path> - Path to Cacti log file, default:
             /var/www/htdocs/cacti/log/cacti.log
    <Warn> - Size to alert warning in bytes, default: 536870912
    <Critical> - Size to alert critical in bytes, default: 1073741824
    <Interval> - Polling interval in seconds, default: 300
Questions, concerns, comments, let me know! :)
Attachments
cacti_log_check.sh
Nagios Plugin for monitoring Cacti log
(4.69 KiB) Downloaded 1981 times
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]

User avatar
rony
Developer/Forum Admin
Posts: 6016
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

#2 Post by rony » Fri Aug 04, 2006 12:27 pm

Also should note, if you are using Cacti not on the same machine as Nagios, I would suggest using NRPE to use the plugin on the Cacti server.
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]

knobdy
Cacti User
Posts: 495
Joined: Wed Sep 28, 2005 1:39 pm

#3 Post by knobdy » Tue Sep 12, 2006 12:43 pm

I'm thinking this goes into services.cfg - so what is the format one should use for the check_command? Whatabout the checkcommands.cfg file?

I've edited the script for my system and can run it correctly from the command line (just running it) but Nagios is showing:

Code: Select all

Check Cacti service	UNKNOWN 	09-12-2006 12:37:00 	0d 1h 1m 41s 	3/3 	CACTI UNKNOWN: Log file not found 

knobdy
Cacti User
Posts: 495
Joined: Wed Sep 28, 2005 1:39 pm

#4 Post by knobdy » Mon Sep 18, 2006 2:30 pm

So, any news on this? I haven't yet been able to get Nagios to work with this script - via Nagios (run manually, again, it reports everything OK). I think its just an issue with my configuration of the service in the config file - so perhaps just an example of your setup?

User avatar
rony
Developer/Forum Admin
Posts: 6016
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

#5 Post by rony » Mon Sep 18, 2006 5:28 pm

Are you running the plugin on the same server that Cacti is installed on? Does the user that nagios is running as have access to the Cacti log file?
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]

knobdy
Cacti User
Posts: 495
Joined: Wed Sep 28, 2005 1:39 pm

#6 Post by knobdy » Tue Sep 19, 2006 8:29 am

It is on the same server and the cacti log file is RW for user and group - the group is "users" and nagios is in that group.

User avatar
rony
Developer/Forum Admin
Posts: 6016
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

#7 Post by rony » Tue Sep 19, 2006 9:09 am

In your nagios services configuration, surround the path on the service check with single quotes.
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]

Hiney
Cacti User
Posts: 56
Joined: Mon Oct 16, 2006 11:50 pm

setup

#8 Post by Hiney » Wed Feb 28, 2007 12:49 am

someone asked what to do with the checkcommands.cfg

I added
  • define command{
    command_name check-cacti-log
    command_line $USER1$/cacti_log_check.sh
    }
i added the following to the server.cfg file
  • # Define a service to check the cacti log
    define service{
    use generic-service ; Name of service template to use
    host_name <server>
    service_description Cacti log
    is_volatile 0
    check_period 24x7
    max_check_attempts 4
    normal_check_interval 5
    retry_check_interval 1
    contact_groups admins
    notification_options w,c,r
    notification_interval 1440
    notification_period daytime
    check_command check-cacti-log
    }
Last edited by Hiney on Wed Feb 28, 2007 5:34 pm, edited 1 time in total.
"The difference between theory and practice, is that in theory, there is no difference between theory and practice."

"The first 90% of a project takes 90% of the time, the last 10% takes the other 90% of the time" - Murphy's Law

User avatar
rony
Developer/Forum Admin
Posts: 6016
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

#9 Post by rony » Wed Feb 28, 2007 9:48 am

Thanks, I don't have a Nagios installation to test on and haven't used it in years.. :)
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]

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

#10 Post by prune » Fri Aug 03, 2007 7:05 am

Hi,

I made a post some time ago, but this is an update.
I made a patch to threshold plugin so the alert can be passed to Nagios as a passive check.
Feel free to check and download it from my blog :

http://www.lecentre.net/blog/archives/77

If your Nagios install is on a remote host, change the script to send the alarm by scp or ssh.

Hope this can help
--
Prune
(Dual G5/4go/RAID)

Post Reply