Zabbix text message by script principle
and Zabbix e-mail is the same, are configured in action, the way to send text messages by calling SMS Company API to complete, of course, there are many online use 139 mailbox to send, this is actually called a call email, here is to repeat the method called script.
Step
- Write a script that sends text messages. Plus executable permissions.
- Administration-> Medis types inside Create, type Select script, fill in your script name.
- Specify Alertscriptspath in the server's configuration file. Note that this directory can be accessed by Zabbix.
- Restart the server.
- Configured in action.
- The individual user's media is configured with a mobile phone number.
Finally, attach a Python script
#!/usr/bin/python#coding: Utf-8ImportUrllib2ImportUrllibImportSys def sendm(mobile,content):URL =' http://xxx/sms.aspx 'data = Urllib.urlencode ({"userid":' xx ',"Account":' xx ',"Password":' xxx ',"mobile": Mobile,"Content": Content,"Sendtime":"","Action":"Send","Extno":""}) req = Urllib2. Request (url,data) res = Urllib2.urlopen (req)PrintRes.read () number=sys.argv[1]msg=sys.argv[2]SENDM (NUMBER,MSG)
In fact, in many cases the script is called Urllib2 this module, you can see my previous document, Python URLLIB2 module
Zabbix sending text messages through scripts