Nagios SMS Alerts using CURL and External HTTP SMS Gateway
Configure Nagios.
We need to configure following CFGs
Edit commands.cfg
vi /etc/Nagios/objects/commands.cfg |
and add
################################################################################ # # SMS NOTIFICATION COMMANDS # # These are some example notification commands. # Please provide details of PhoneNumber, User, Password and http:// # you can mention a single PhoneNumber of Named List in PhoneNumber variable. # ################################################################################ # ‘notify-host-by-SMS’ command definition } # ‘notify-service-by-SMS’ command definition } |
Edit templates.cfs
Now edit templates.cfs
vi /etc/Nagios/objects/templates.cfg |
and add
############################################################################### ############################################################################### # # CONTACT TEMPLATES # ############################################################################### ############################################################################### # Generic contact definition template – This is NOT a real contact, just a template! define contact{ service_notification_period 24×7 ; service notifications can be sent anytime host_notification_period 24×7 ; host notifications can be sent anytime service_notification_options w,u,c,r,f,s ; send notifications for all service states, flapping events, and scheduled downtime events host_notification_options d,u,r,f,s ; send notifications for all host states, flapping events, and scheduled downtime events service_notification_commands notify-service-by-email ; send service notifications via email service_notification_commands notify-service-by-sms,notify-service-by-email ; send service notifications via email and SMS host_notification_commands notify-host-by-email ; send host notifications via email host_notification_commands notify-host-by-sms,notify-host-by-email ; send host notifications via email and SMS register 0 ; DONT REGISTER THIS DEFINITION – ITS NOT A REAL CONTACT, JUST A TEMPLATE! } |
Once you’ve made all required changes, you may wish to check the nagios configuration. Please Issue
nagios -v /etc/nagios/nagios.cfg |
and check there are no warnings and errors. It should appear something like this:
……. Checking for circular paths between hosts… Checking for circular host and service dependencies… Checking global event handlers… Checking obsessive compulsive processor commands… Checking misc settings… Total Warnings: 0 Total Errors: 0 |
Things look okay – No serious problems were detected
If you’re all good, you can then reload your nagios configuration
/etc/init.d/nagios restart |
You should now be able to receive SMS alerts via Nagios.
Please monitor log files SMS alerts
tail -f /var/log/nagios/nagios.log |
OR
tail -f /var/log/messages |
I hope this will work for you and thanks for visiting https://www.learnacad.com
References
- http://www.nagios.org
- http://www.nagios.org/about/
- http://support.nagios.com/knowledgebase
- http://exchange.nagios.org/