Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


Cacti Server Monitoring script for Unix
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cacti Forum Index -> Addons for Cacti
Author Message
rony
Developer/Forum Admin


Joined: 17 Nov 2003
Posts: 5443
Location: Wisconsin, USA

PostPosted: Wed Aug 02, 2006 6:28 pm    Post subject: Cacti Server Monitoring script for Unix Reply with quote

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.



cacti_monitor.sh
 Description:
Cacti Monitoring Script

Version 1.0.2 - Added a feature to error out when unable to locate a suitable mailing program.

Download
 Filename:  cacti_monitor.sh
 Filesize:  10.2 KB
 Downloaded:  1048 Time(s)


cacti_monitor.sh
 Description:
Cacti Monitoring Script

Version 1.0.1 - Fixed a bug where log rotation would cause a false positive of poller failure.

Download
 Filename:  cacti_monitor.sh
 Filesize:  10.16 KB
 Downloaded:  269 Time(s)


cacti_monitor.sh
 Description:
Cacti Monitoring Script

Version 1.0.0 - Initial release

Download
 Filename:  cacti_monitor.sh
 Filesize:  9.76 KB
 Downloaded:  473 Time(s)



Last edited by rony on Wed Nov 15, 2006 3:59 pm; edited 4 times in total
Back to top
mmartens



Joined: 24 May 2005
Posts: 49

PostPosted: Tue Aug 29, 2006 4:43 pm    Post subject: Reply with quote

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
Back to top
rony
Developer/Forum Admin


Joined: 17 Nov 2003
Posts: 5443
Location: Wisconsin, USA

PostPosted: Tue Aug 29, 2006 4:54 pm    Post subject: Reply with quote

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.
Back to top
mmartens



Joined: 24 May 2005
Posts: 49

PostPosted: Sat Sep 02, 2006 2:08 am    Post subject: Reply with quote

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.
Back to top
rony
Developer/Forum Admin


Joined: 17 Nov 2003
Posts: 5443
Location: Wisconsin, USA

PostPosted: Sat Sep 02, 2006 8:49 am    Post subject: Reply with quote

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:
chmod 755 cacti_monitor.sh
Back to top
mandrk



Joined: 12 May 2005
Posts: 21
Location: Romania

PostPosted: Wed Oct 18, 2006 12:39 pm    Post subject: Good job! Reply with quote

Make some screenshots.
We like screenshots.
Back to top
rony
Developer/Forum Admin


Joined: 17 Nov 2003
Posts: 5443
Location: Wisconsin, USA

PostPosted: Wed Oct 18, 2006 12:44 pm    Post subject: Reply with quote

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.
Back to top
mandrk



Joined: 12 May 2005
Posts: 21
Location: Romania

PostPosted: Wed Oct 18, 2006 12:48 pm    Post subject: Reply with quote

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.
Back to top
rony
Developer/Forum Admin


Joined: 17 Nov 2003
Posts: 5443
Location: Wisconsin, USA

PostPosted: Wed Oct 25, 2006 5:24 pm    Post subject: Reply with quote

Version 1.01 posted in the first post.

Minor update to fix false positives when the cacti.log file is empty after being rotated.
Back to top
spoonman
Cacti User


Joined: 03 May 2005
Posts: 243

PostPosted: Thu Oct 26, 2006 1:10 pm    Post subject: Reply with quote

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?
Back to top
rony
Developer/Forum Admin


Joined: 17 Nov 2003
Posts: 5443
Location: Wisconsin, USA

PostPosted: Thu Oct 26, 2006 1:38 pm    Post subject: Reply with quote

What OS and Version of OS are you running?

Do the following commands and report the results:

Code:
uname -a

Code:
which mail

Code:
which mailx
Back to top
spoonman
Cacti User


Joined: 03 May 2005
Posts: 243

PostPosted: Thu Oct 26, 2006 1:42 pm    Post subject: Reply with quote

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
Back to top
rony
Developer/Forum Admin


Joined: 17 Nov 2003
Posts: 5443
Location: Wisconsin, USA

PostPosted: Thu Oct 26, 2006 1:47 pm    Post subject: Reply with quote

Not sure what package has it but you need to install the mail or mailx utility.
Back to top
spoonman
Cacti User


Joined: 03 May 2005
Posts: 243

PostPosted: Thu Oct 26, 2006 1:52 pm    Post subject: Reply with quote

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

CYA
Back to top
rony
Developer/Forum Admin


Joined: 17 Nov 2003
Posts: 5443
Location: Wisconsin, USA

PostPosted: Thu Oct 26, 2006 1:59 pm    Post subject: Reply with quote

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...
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Addons for Cacti All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 



Powered by phpBB © 2001, 2005 phpBB Group