-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathzabbix-matrix-call.py
44 lines (34 loc) · 1.11 KB
/
zabbix-matrix-call.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/python3
URL = "https://localhost:8448"
TOKEN = "access_token"
###############################
import sys
import requests
from urllib.parse import quote_plus
call_id = "zabbix"
roomid = sys.argv[1]
subject = sys.argv[2]
#message = sys.argv[3]
if subject.startswith('OK'):
exit(0)
#lifetime = sys.argv[2]
#lifetime = int(lifetime)
lifetime = 10
headers = { 'Authorization': 'Bearer '+TOKEN }
payload = { "call_id": call_id, "lifetime": lifetime*1000, "offer": { "sdp": "", "type": "offer" }, "version": "0" }
payload2 = { "call_id": call_id, "version": "0" }
url = URL+"/_matrix/client/r0/rooms/"+quote_plus(roomid)+"/send/m.call.invite"
url2 = URL+"/_matrix/client/r0/rooms/"+quote_plus(roomid)+"/send/m.call.hangup"
r = requests.post(url,json=payload,headers=headers,timeout=30)
if r.status_code != 200:
print(r.status_code)
print(r.text)
exit(1)
# workaround https://github.com/vector-im/riot-android/issues/2741
import time
time.sleep(lifetime)
r2 = requests.post(url2,json=payload2,headers=headers,timeout=30)
if r2.status_code != 200:
print(r2.status_code)
print(r2.text)
exit(1)