Initial commit

This commit is contained in:
2025-08-21 22:20:54 +02:00
commit cc0902f789
5 changed files with 428 additions and 0 deletions

33
plugins/asterisk.py Normal file
View File

@@ -0,0 +1,33 @@
#!/usr/bin/env python3
import subprocess
#
# Put plugin in /lib/check_mk_agent/plugins
#
print("<<<asterisk_endpoints>>>")
endpoints = []
res = subprocess.check_output(["asterisk", "-rx", "pjsip show endpoints"]).decode('utf8')
res = res.split("==\n\n")[1]
res = res.split("Objects found")[0]
# Split the data into the endpoints and parse them info the list (endpoint, Contact, state(available/unavailable))
for endpoint in res.split('Endpoint:')[1:]:
endpoint = endpoint.strip()
#print(endpoint)
endpointV = endpoint.split(' ')[0]
# Find the current state of the endpoint
endP = endpoint.split('\n')[0].split()
indexOfOF = endP.index('of')
state = endP[1:indexOfOF-1]
# Join state
state = '_'.join(state)
channelUsed = endP[-1]
channelAvail = endP[-3]
print(f'{endpointV}\t{state}\t{channelUsed}\t{channelAvail}')
#asterisk -rx 'pjsip show endpoints'