Cacti Server Monitoring script for Unix

Addons for Cacti and discussion about those addons

Moderators: Developers, Moderators

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

Cacti Server Monitoring script for Unix

Post by rony »

Attached is a monitoring script for monitoring the cacti server.

What the script monitors:
  • httpd is running or not running
  • mysql is running
  • if mysql is a replication slave, that it is currently up to date
  • that the Cacti poller is running
  • that the Cacti log is not to large
  • that the mounted volumes are not filling up
Just add this to your crontab for either root or the user that runs the poller every 5 minutes or the same interval you run the poller.

If you find any issues, please let me know either here or via pm/email.
Attachments
cacti_monitor.sh
Cacti Monitoring Script

Version 1.0.2 - Added a feature to error out when unable to locate a suitable mailing program.
(10.2 KiB) Downloaded 5704 times
cacti_monitor.sh
Cacti Monitoring Script

Version 1.0.1 - Fixed a bug where log rotation would cause a false positive of poller failure.
(10.16 KiB) Downloaded 3779 times
cacti_monitor.sh
Cacti Monitoring Script

Version 1.0.0 - Initial release
(9.76 KiB) Downloaded 4052 times
Last edited by rony on Wed Nov 15, 2006 3:59 pm, edited 4 times in total.
[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
mmartens
Cacti User
Posts: 110
Joined: Tue May 24, 2005 6:23 pm

Post by mmartens »

Hi sounds nice but when i edit the path en run i get the following error any ideas?

linux:/bin # ./cacti_monitor.sh
: bad interpreter: No such file or directory


Thanks in advance,

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

Post by rony »

Edit the first line of the script and alter it to use bash.

To find the full path to bash use the `which bash` command.

It's designed to work with bash, so if you don't have bash installed, I suggest you do.
[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
mmartens
Cacti User
Posts: 110
Joined: Tue May 24, 2005 6:23 pm

Post by mmartens »

Thanks for your reply.

these are the first lines in the monitor file:

#!/bin/bash
###############################################################################
# +-------------------------------------------------------------------------+
# | Copyright (C) 2006 The Cacti Group

when i perform a search for bash i get these results:
linux:~ # find / -name 'bash'
/bin/bash
/usr/share/doc/packages/bash
find: . changed during execution of find


Can you tell me what to change? do i need to uncomment the first line?

Thanks in advance.
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

Nope, you probably need to change the permissions on the script to rwx for that user you are going to run it as.

Use the following to change the permissions:

Code: Select all

chmod 755 cacti_monitor.sh
[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]
mandrk
Posts: 21
Joined: Thu May 12, 2005 1:32 am
Location: Romania
Contact:

Good job!

Post by mandrk »

Make some screenshots.
We like screenshots.
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

Screenshots of what? The outputted alert email?

There is no graphical parts to this, it's a shell script that does some basic system checks.
[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]
mandrk
Posts: 21
Joined: Thu May 12, 2005 1:32 am
Location: Romania
Contact:

Post by mandrk »

rony wrote:Screenshots of what? The outputted alert email?

There is no graphical parts to this, it's a shell script that does some basic system checks.
YES! ! i test the script and i see. Is a nice script.
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

Version 1.01 posted in the first post.

Minor update to fix false positives when the cacti.log file is empty after being rotated.
[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]
spoonman
Cacti User
Posts: 305
Joined: Tue May 03, 2005 8:54 am
Location: GA

Post by spoonman »

Nice script........looks awesome. I was testing on my system and got an error when shutting down httpd...I get an error on line 313 where mail is listed..........is that piece of code that actually mails out?? what is required there to have the mail portion work?
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

What OS and Version of OS are you running?

Do the following commands and report the results:

Code: Select all

uname -a

Code: Select all

which mail

Code: Select all

which mailx
[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]
spoonman
Cacti User
Posts: 305
Joined: Tue May 03, 2005 8:54 am
Location: GA

Post by spoonman »

netstat:/home/cacti# uname -a
Linux netstat 2.6.8-2-386 #1 Thu May 19 17:40:50 JST 2005 i686 GNU/Linux
netstat:/home/cacti# which mail
netstat:/home/cacti# which mailx
netstat:/home/cacti#


Running Debian ..........

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

Post by rony »

Not sure what package has it but you need to install the mail or mailx utility.
[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]
spoonman
Cacti User
Posts: 305
Joined: Tue May 03, 2005 8:54 am
Location: GA

Post by spoonman »

Thanks Tony...just needed apt-get install mailx

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

Post by rony »

I'm currently modifying to script to tell you it can't find a mailing program... Maybe in the future I will make it use sendmail... :lol:
[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]
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests