Hi, every body
Today I’d like to write a article about wrtting a script by python and use it in zabbix as a media type for sending triggers by sms:
First : create a file with name : ghasedak.py , and write your script.
Pay attention to first line “#!/usr/bin/env python”, this line have to be here for running script by python.
We must use sys.argv . sys.argv is a list in Python, which contains the command-line arguments passed to the script.
you can write any script that work’s with your provider
#!/usr/bin/env python import requests as requests import sys url = "http://api.smsapp.ir/v2/sms/send/simple" frm = 'my number' to = str(sys.argv[1]) message = str(sys.argv[2]) payload = "message=" + message + "&sender=" + frm + "&Receptor=" + to + "" headers = {'content-type': "application/x-www-form-urlencoded", 'apikey': "mykey", } response = requests.request("POST", url, data=payload, headers=headers) print(response.text)
Save this Script and in terminal enter : sudo chmod +x ghasedak.py
GO to Adminisrations->Media Types and create a new media type, do like this:
Go to Users and create a new User:
Then Go to media tab for your user, add media ,select media type and tel_number in ‘Send to’
finally check severity that you want and enable it.
Now, Go to configuration->Actions and create action for triggers :
set conditions ,I use sms if trigger severity is equals High, change it to your own opnion.
In action you are calling a group of trigger and you can filter in user that each user recieve a specific trigger.
for example admin can recive all trigger severiry and guest can see warning and ….
Go to operations tab ,do this
add new in Operatios like this:
add user or users you want to recieve trigger’s sms:
Do recovery operations and update operations like above