HEX
Server: Apache
System: Linux vpshost0650.publiccloud.com.br 4.4.79-grsec-1.lc.x86_64 #1 SMP Wed Aug 2 14:18:21 -03 2017 x86_64
User: bandeirantesbomb3 (10068)
PHP: 8.0.7
Disabled: apache_child_terminate,dl,escapeshellarg,escapeshellcmd,exec,link,mail,openlog,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,php_check_syntax,php_strip_whitespace,popen,proc_close,proc_open,shell_exec,symlink,system
Upload Files
File: //usr/lib/python2.7/site-packages/lap/check_asterisk_udp_ports.py
import os
import subprocess
import shlex
import sys,linecache, types, time


def __run__(params):

    try:
        norm = int(params.get("norm"))
        warn = int(params.get("warn"))
        crit = int(params.get("crit"))
    except Exception, e:
        return [2, "CRITICAL - Error getting params: %s" % repr(e)]

    try:
        
        command = "netstat -nupl | grep -c asterisk"
        p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
        stdout = p.communicate()[0]
        count = int(stdout)
        
        if count <= norm:
            return [0, "OK - Used ports: %s" % (count)]

        if count >= norm and count <= warn:
            return [1, "WARN - Used ports: %s" % (count)]
        else:
            return [2, "CRIT - Used ports: %s" % (count)]

    except Exception, e:
        exc_type, exc_obj, tb = sys.exc_info()
        f = tb.tb_frame
        lineno = tb.tb_lineno
        filename = f.f_code.co_filename
        linecache.checkcache(filename)
        line = linecache.getline(filename, lineno, f.f_globals)
        return [2, 'Exception in ({}, line {} "{}"): {}'.format(filename, lineno, line.strip(), exc_obj)]