Python to increase the function of Nagios micro-alarm Notification

Source: Internet
Author: User
Tags file permissions

Nagios powerful alarm function now has a new play, the idea is to call the micro-trust Platform API interface to send the alarm message. There are a few things to do before the formal operation. To install Nagios First, you can use the Nagios one-click installation script that I provided. Then to the micro-trust public platform to apply for an enterprise number, I applied for the organization, no certification can also be used. Finally log on to the public platform to add the Address Book, and create a new application (such as Nagios), which is used after the ID of the application. User permissions what set themselves.

Micro-letter Script

After Nagios and micro-trust platforms are ready, download the micro-mail command script. Right-click to download, save. Then upload to Nagios server, such as/usr/local/nagios/python/weixin directory, set file permissions to executable. To create a new file in the/usr/local/nagios/python/weixin directory, add the following configuration.

#coding: Utf-8

Corpid= ' xxxxx '
secret= ' Xxxxxxxxxxxxxxxxx '


Touser= ' '
These two corpid and secret can be obtained by logging on to the micro-trust public platform and opening the added application (for example, Nagios).

The parameters passed by the micro-letter script command are segmented by the "-@@-" symbol, which can refer to my GitHub address:

Nagios Configuration

The following is the general configuration on the Nagios.

commands.cfg command file to add the Weixin command:

Define command{
    command_name notify-host-by-weixin
    command_line/usr /local/nagios/python/weixin/ "host-@@-$NOTIFICATIONTYPE $-@@-$HOSTNAME $-@@-$HOSTSTATE $-@@-$ hostaddress$-@@-$HOSTOUTPUT $-@@-$CONTACTALIAS $ "
Define command{
    command_name Notify-service-by-weixin
    command_line/usr/local/nagios/python/weixin/ " service-@@-$NOTIFICATIONTYPE $-@@-$SERVICEDESC $-@@-$HOSTALIAS $-@@-$HOSTADDRESS $-@@-$SERVICESTATE $-@@-$ serviceoutput$-@@-$CONTACTALIAS $ "
Templates.cfg template file Add a contact Template:

Define Contact{
Name Weixin-contact
Service_notification_period 24x7
Host_notification_period 24x7
Service_notification_options w,u,c,r,f,s
Host_notification_options d,u,r,f,s
Service_notification_commands Notify-service-by-weixin
Host_notification_commands Notify-host-by-weixin
Register 0
Contacts.cfg contact to add a micro-letter to notify the contact, where the alias name and the micro-trust in the public platform Address Book name account will be sent successfully.

Define Contact{
Contact_Name Zhangnq-weixin
Use Weixin-contact
Alias Zhangnq
Finally, when the service is configured to add zhangnq-weixin This contact person can be sent through the micro-mail alarm message

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: 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.