Friday, May 23. 2008Nagios 2-way alerting via SMS - Part 2Comments
Display comments as
(Linear | Threaded)
Excellent posts, very useful and informative. Thanks for posting - looking forward to part three!
Very good tutorial, but Nagios don't send SMS yet
When you say "I call this script /usr/local/bin/sendsms.sh" why in the command line definition you refer to other path, it was a mistake? command_line /usr/local/nagios/sendsms.sh host And another thing. I found a easy way to test the notifications just starting and stopping the ssh service, so I just added to in my localhost.cfg to my SSH service description this : contact_groups admins-sms notifications_enabled 1 But I don't receive any SMS
I keep getting "SendingError" under the Status Field in my smsd databases' "sentsms" table. My smsd database's "outbox" table gets populated as per normal and my "sentsms" table follows suit afterward but "SendingError" keeps appearing under the Status Field.
I'm using Ubuntu Server 8.04 LTS with Gammu version 1.18.90. My server is connected via serial port to a Siemens MC35i. I think I am 95% successful, but I can't figure out why I keep on getting a SendingError. I can send an sms successfully using: # echo "Test message" | gammu --sendsms TEXT . Any ideas? Anyone?
Hmm...
Take a look and the sendsms.sh The line to do the sending is:
Have you configured up items like the /etc/smsdrc, /etc/gammu and the $NAGIOS_CONTACTPAGER for each person? Also refer to the upstart information.. you need the SMSd to be running to be able to send via this method. (so it logs correctly).
Hi Matt,
Thanks for your reply! Appreciate it. My /etc/smsdrc and /etc/gammu files are below: /etc/smsdrc [smsd] PIN = 1234 commtimeout = 1 sendtimeout = 10 # ------------------------- SETTINGS FOR --smsd MYSQL --------------------------- user = gammu password = password pc = localhost database = smsd ------EOF------- /etc/gammurc [gammu] port = /dev/ttyS0 connection = at19200 startinfo = no name=Siemens MC35i synchronizetime = no use_locking = no ------EOF---------- My commands.cfg: ---------------------- # 'host-notify-by-sms' command definition define command { command_name host-notify-by-sms command_line /usr/local/bin/sendsms.sh host } # 'notify-by-sms' command definition define command { command_name notify-by-sms command_line /usr/local/bin/sendsms.sh service } My contacts.cfg: ------------------- define contact{ contact_name joe alias joe daniels service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,u,c,r host_notification_options d,u,r service_notification_commands notify-by-sms host_notification_commands host-notify-by-sms pager + } define contactgroup{ contactgroup_name admins-sms alias Administrators who receive SMS Alerts members joe } My routers.cfg: ----------------- # Define the router/switch that we'll be monitoring define host{ use routers ; Inherit default values from a template host_name edge-gw1 ; The name we're giving to this router/switch alias PrimaryRouter ; A longer name associated with the router/switch address 192.168.1.4 ; IP address of the router/switch hostgroups edge_routers ; Host groups this router/switch is associated with check_command check-host-alive max_check_attempts 20 check_period 24x7 contact_groups admins-sms # Create a new hostgroup for Edge routers define hostgroup{ hostgroup_name edge_routers ; The name of the hostgroup alias Edge Routers ; Long name of the group } # Service to PING Edge Routers define service{ use generic-service ; Inherit values from a template hostgroup_name edge_routers service_description PING ; The service description contact_groups admins-sms check_command check_ping!200.0,20%!600.0,60% ; The command used to monitor the service normal_check_interval 5 ; Check the service every 5 minutes under normal conditions retry_check_interval 1 ; Re-check the service every minute until its final/hard state is determined } Hope the above helps. Rgds, Smiley
Any further helpful pointers from anyone is much appreciated in advance. Kinda desperate to get things working. Stumped at the moment.
Smiley
So i follow your rules to configure Nagios 2-way alerting via SMS. I did Step 1: Plugging in my GSM source. So it works fine. Next Step 2: Setting up my database (i did that). Step 3: Configure gammu (works fine . I can send sms) . Step 4: Configure the SMS Daemon (works fine too it drop my sms into database). Step 5: Configure Nagios. (Nagios configured) drops :
1. ..... 2. Checking for circular paths between hosts... 3. Checking for circular host and service dependencies... 4. Checking global event handlers... 5. Checking obsessive compulsive processor commands... 6. Checking misc settings... 7. 8. Total Warnings: 0 9. Total Errors: 0 10. 11. Things look okay - No serious problems were detected during the pre-flight check But it doesn't send me sms when alert is... Maybe this script is bad : script /usr/local/bin/sendsms.sh. ... I can't understand there problem is. I'm on FREEBSD 7.2 OS. Gammu is newest version and Nagios so on.
I only want to send alert sms from nagios no need for taking messages, do i still need a db?
The DB retains them for historical purposes.
And no you don't need to store them in the DB if you don't want to.
Heh,
Great articles Matt. They were inspiring to me. With your help I managed to make SMS alerts work. The only unsuccess I had was with the Sms Daemon. When I start smsd.sh it will throw: Starting communication Error getting SMS status (Unknown response from phone.) although when using only gammu, everything seems to work. Should this be the Phone (Motorola C650) not supporting something? Because I really wanted to go on with replying Nagios. Do you recommend any workarounds? Cheers, Alex.
Hi Alex,
Thank you for your kind words! I'm glad you've found the posts inspiring and useful. Do you have any messages in the log files? Ensure that smsd uses similar command line arguments that works with your phone as you used on the command line. Hopefully that works.
Ok, I managed to make it work. I grabbed the latest version of gammu and compiled it, and it works like a charm. Only minor modifications to your script, like instead of "gammu sendsmsdsms" it's "gammu-smsd-inject", it has separate binaries now, and a different database schema for mysql.
Also it took me a while to understand why nagios wouldn't send sms - (a heads up for beginners), I "su" to user nagios and tried to send a sms and it would refuse to do so because of permissions on the log file. Chmod did the trick. Now on to the third part of your tutorial! Cheers!
Hi Matt,
I configured everything as instructed but I'm not able to send sms alerts from nagios.I did chmod logfile & I can see the message generated in logfile , but its not sending sms. I have done changes in "sendsms.sh" as follows echo -e $MESSAGE | gammu-smsd-inject TEXT $NAGIOS_CONTACTPAGER I ran above command on command line as a nagios user & it worked fine.SMS was delivered . Can u please elloborate more to fix this issue.
Hello Matt,
I got problem on configuration step 4 : Configure the SMS Daemon. I have set up the gammu-smsdrc and gammurc file on /etc/ directory. But when i tried to take the smsd.sh file on /etc/inittab, i dont have the inittab dir, so i used the upstart. For your information, I dont really understand how upstart works (still dummy :p). So, when i want to place the smsd file on /etc/event.d/ directory, i realized that i dont have that directory either. Then i try to create it, but still it doesnt work. When i run "sudo /sbin/initctl start smsd ", the output is : "initctl: Unknown job: smsd" So i move the smsd file to /etc/init.d , but the same problem still happens. I also tried to change the smsd.sh file into like this : 1. #!/bin/sh 2. export LANG=en_US 3. /usr/local/bin/gammu-smsd MYSQL /etc/smsdrc (because i think maybe you and i have a different location instalation) still, it didnt solve the problems. Please, help me. Many thanks, Aulia
Hi Aulia,
If you let me know the details of the version and distribution you are running I may be able to assist.
Hi Matt,
Thanks for this amazing article. I am now able to receive sms notifications successfully. I was using gammu version 1.10 that comes natively packaged with Centos 5.4. but it has a problem working with Huawei modems (e160). It throws up an error of no network answer CMS error 500 when you try sending an sms. This can only be sorted out by upgrading to the latest version of gammu which is gammu 1.28.92 (http://wammu.eu/gammu/). When you upgrade, you'll notice that the file names change slightly, like /etc/smsdrc becomes /etc/gammu-smsdrc. also, you'll need to change the smsd.sh script that keeps the SMS daemon running to this #! /bin/sh /usr/local/bin/gammu-smsd -c /etc/gammurc This change is due to the change in the new version of gammu. You'll also need to change the script SENDSMS.SH, the line that sends the message to: echo -e $MESSAGE | /usr/local/bin/gammu-smsd-inject -c /etc/gammurc TEXT $NAGIOS_CONTACTPAGER. I hope this update is helpful, especially to people who will be using Huawei modems. Thanks again Matt and everyone else for your contribution.
Hi, should this not be as the following?
#!/bin/sh export LANG=en_US /usr/local/bin/gammu-smsd --config /etc/gammu-smsdrc --pid /var/run/gammu-smsd.pid --daemon echo -e $MESSAGE should be without the -e flag. Otherwise I don't think the message can be parsed. Kind regards, Valentin
i don't know where i put my mistake in nagios configuration... i used nagios 3.2.3 and nagios plugin 1.4.15 ....and i've followed these steps..... and it does't work ....
anybody can help?? |
QuicksearchCalendar
My PhotosWhat I've been listening toUndecided by Silverchair on Tue 6 Mar 2012, 11:10:37 AM Young Man, Old Man by The Dissociatives on Tue 6 Mar 2012, 11:06:33 AM black fingernails red wine by Eskimo Joe on Tue 6 Mar 2012, 11:02:27 AM Chasing Cars by Snow Patrol on Tue 6 Mar 2012, 10:57:59 AM Sour Sour Times by Portishead on Tue 6 Mar 2012, 10:54:04 AM She Wants To Move (Album Version) by N*E*R*D on Tue 6 Mar 2012, 10:50:31 AM Last Chance by Jet on Tue 6 Mar 2012, 10:48:39 AM Sick and Tired by Anastacia on Tue 6 Mar 2012, 10:45:07 AM Somethings Gotta Give by The John Butler Trio on Tue 6 Mar 2012, 10:42:02 AM Slip Into Something More Comfortable (Instrumental Version) by Kinobe on Tue 6 Mar 2012, 10:37:20 AM Wed 22 May 2013, 05:42:39 AM
Recently BookmarkedBlog StatsLast entry: 2011-01-10 18:19
279 entries written
521 comments have been made
Blog Tags accounting advertising alerting apps asterisk australia birthday building coding cricket email entertainment failure family firefox football friends gnome google government hardware health holiday house humour Internet ISP java life linksys Linux marriage microsoft mistake monitoring movies mozilla nagios networking news office openoffice open source opinion oss pets phone photo play politics power relax respect review security shopping sms snom snoring society software spam sport support sysadmin technology telephony tennis terrorism tv twitter ups virtualbox virtualization voip web weekend wildlife windows wine wireless workLicense |
|||||||||||||||||||||||||||||||||||||||||||||||||
This is a 3 part posting that covers how you can setup 2-way Nagios alerting via SMS. The series is broken down as such: Part 1: Background and Requirements (this article)Part 2: Sending SMS messages from NagiosPart 3: Acknowledging SMS messages For
Tracked: May 23, 01:29
This is a 3 part posting that covers how you can setup 2-way Nagios alerting via SMS. The series is broken down as such: Part 1: Background and RequirementsPart 2: Sending SMS messages from NagiosPart 3: Acknowledging SMS messages (this article) Rev
Tracked: May 24, 02:57