Cacti Server Monitoring script for Unix

Addons for Cacti and discussion about those addons

Moderators: Moderators, Developers

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

Cacti Server Monitoring script for Unix

#1 Post by rony » Wed Aug 02, 2006 6:28 pm

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 4274 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 2379 times
cacti_monitor.sh
Cacti Monitoring Script

Version 1.0.0 - Initial release
(9.76 KiB) Downloaded 2637 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

#2 Post by mmartens » Tue Aug 29, 2006 4:43 pm

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: 6016
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

#3 Post by rony » Tue Aug 29, 2006 4:54 pm

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

#4 Post by mmartens » Sat Sep 02, 2006 2:08 am

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: 6016
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

#5 Post by rony » Sat Sep 02, 2006 8:49 am

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!

#6 Post by mandrk » Wed Oct 18, 2006 12:39 pm

Make some screenshots.
We like screenshots.

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

#7 Post by rony » Wed Oct 18, 2006 12:44 pm

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:

#8 Post by mandrk » Wed Oct 18, 2006 12:48 pm

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: 6016
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

#9 Post by rony » Wed Oct 25, 2006 5:24 pm

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: 298
Joined: Tue May 03, 2005 8:54 am
Location: GA

#10 Post by spoonman » Thu Oct 26, 2006 1:10 pm

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: 6016
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

#11 Post by rony » Thu Oct 26, 2006 1:38 pm

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: 298
Joined: Tue May 03, 2005 8:54 am
Location: GA

#12 Post by spoonman » Thu Oct 26, 2006 1:42 pm

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: 6016
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

#13 Post by rony » Thu Oct 26, 2006 1:47 pm

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: 298
Joined: Tue May 03, 2005 8:54 am
Location: GA

#14 Post by spoonman » Thu Oct 26, 2006 1:52 pm

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

CYA

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

#15 Post by rony » Thu Oct 26, 2006 1:59 pm

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