Nagios sends alarm messages using MSN

Source: Internet
Author: User
Tags sendmsg
There are too many servers managed by the company! Cacti was deployed a year ago, but cacti can only perform post-analysis work, but the real-time alarm function is not strong. before cacti, nagios was installed on the monitoring PC, I just haven't had time to study it in detail! Currently, scripts are automatically managed on hundreds of servers! Then send an alarm email

There are too many servers managed by the company! Cacti was deployed a year ago, but cacti can only perform post-analysis work, but the real-time alarm function is not strong. before cacti, nagios was installed on the monitoring PC, I just haven't had time to study it in detail! Currently, scripts are automatically managed on hundreds of servers! Then, send an alert email!
This is a bit of time to study nagios. from today on, I will record the results of my recent study! Make a search for future subordinates and do some information!
Today, we will mainly record the basic nagios-based method of using MSN messages for alarms that were successfully studied yesterday!

1. prepare the MSN account used for MSN robot login and the MSN account for receiving alarm messages. the two accounts must be friends with each other;

2. MSN robots use PHP class: sendMsg
To download and install sendMsg, you only need to put the sendMsg directory under the web root directory. configure the MSN account and password used for MSN registration, and configure the recipient's MSN account:

$ SenderUser = MSN account;
$ SenderPass = password;
$ SendToList = array (receiver 1, receiver 2 );


After configuring the preceding message, you can test it:
Open the following link in IE, and receive the following Chinese message in the MSN alarm receiving MSN account:

Http://noc.chinarenservice.com/msn/index.php? SendMess = I killed you


3. commands. cfg configuration

[Root @ TS263 servers] # less/usr/local/nagios/etc/servers/commands. cfg
###################################### Msn Alert ######################################## #################
# Define Y-by-msn command definition
Define command {
Command_name sort Y-host-by-msn
Command_line/usr/bin/printf "% B" "****** Nagios 1.0 ***** Notification Type: $ icationicationtype $ Service: $ SERVICEDESC $ Host: $ HOSTALIAS $ Address: $ HOSTADDRESS $ State: $ SERVICESTATE $ Date/Time: $ DATETIME $ Additional Info: $ OUTPUT $ ">/usr/local/nagios/msnhost. out | $ USER1 $/messagehost. sh
}
# Define Y-service-by-msn command definition
Define command {
Command_name sort Y-service-by-msn
Command_line/usr/bin/printf "% B" "****** Nagios ***** Notification Type: $ icationicationtype $ Service: $ SERVICEDESC $ Host: $ HOSTALIAS $ Address: $ HOSTADDRESS $ State: $ SERVICESTATE $ Date/Time: $ LONGDATETIME $ Additional Info: $ SERVICEOUTPUT $ ">/usr/local/nagios/msnservice. out | $ USER1 $/messageservice. sh
}
[Root @ TS263 servers] # less/usr/local/nagios/libexec/messageservice. sh
#! /Bin/bash
Message = 'cat/usr/local/nagios/msnservice. out'
Wget-qO-http://noc.chinarenservice.com/msn/index.php? SendMess = "$ message"

4. add an MSN contact to receive messages.

[Root @ TS263 servers] # less/usr/local/nagios/etc/servers/contacts. cfg
Define contact {
Contact_name freeke2
Alias freeke2
Use generic-contact
Service_icationication_period 24x7
Host_icationication_period 24x7
Service_icationication_options w, u, c, r
Host_icationication_options d, u, r
Service_icationication_commands notify-service-by-msn
Host_icationication_commands notify-host-by-msn
Email myfreeke@gmail.com
Pager 15920094782
Address1 myfreeke@gmail.com
Address2 555-555-5555
}
After adding the contact, note that you must add the contact to the contact group.

[Root @ TS263 servers] # less/usr/local/nagios/etc/servers/contactgroup. cfg
Define contactgroup {
Contactgroup_name admin
Alias Nagios Administrators
Members support, freeke2
}

Then, add contact_groups admin in the service configuration to use the MSN alarm function normally. The effect is like receiving alarm information under the above section!

When I configured nagios to use MSN, I asked a lot of people, because they didn't understand shell and write code, so they were so depressed for a long time!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.