HEX
Server: Apache
System: Linux server.enlacediseno.com 4.18.0-553.62.1.el8_10.x86_64 #1 SMP Wed Jul 16 04:08:25 EDT 2025 x86_64
User: maor (1069)
PHP: 7.3.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/local/lib/python3.6/site-packages/agent360/plugins/asterisk.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import plugins
import subprocess


class Plugin(plugins.BasePlugin):
    __name__ = 'asterisk'

    def run(self, config):
        ip = config.get(__name__, 'sbcip')
        p = subprocess.Popen("sudo asterisk -rx 'core show calls' | grep 'active' | cut -f1 -d ' '", stdout=subprocess.PIPE, shell=True)
        p = p.communicate()[0].decode('utf-8').replace("\n", "")
        incoming = subprocess.Popen("sudo asterisk -rx 'core show channels verbose' | cut -c1-15 | grep 'pstn_' | wc -l", stdout=subprocess.PIPE, shell=True)
        incoming = incoming.communicate()[0].decode('utf-8').replace("\n", "")

        devices = subprocess.Popen("sudo asterisk -rx 'sip show peers' | grep '%s' | wc -l" % (ip), stdout=subprocess.PIPE, shell=True)
        devices = devices.communicate()[0].decode('utf-8').replace("\n", "")

        res = { "calls": p, "incomingcalls": incoming, "devices": devices }
        return res

if __name__ == '__main__':
    Plugin().execute()