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/ig_isr.py
import redis
import psutil
import commands
import datetime

def list_processes():
    processes = []
    for pid in psutil.process_iter():
        try:
            processes.append(psutil.Process(pid).name)
        except:
            continue
    return processes

def dovecot_proxy():
    cmd = "sudo /usr/bin/doveadm proxy list 2>/dev/null | sort -k 2 | uniq -c -f 2"
    status, response = commands.getstatusoutput(cmd)
    if status == 0:
        return [ line.strip().split() for line in response.split("\n") ]
    return []

def load():
    r = redis.Redis(host='127.0.0.1', db=0, port=6379)
    now = datetime.datetime.now() - datetime.timedelta(seconds=60)
    key = "status:%s:%s:%s:%s:%s" % (now.year, now.month, now.day, now.hour, now.minute)
    key_hour = "status:%s:%s:%s:%s" % (now.year, now.month, now.day, now.hour)
    info = {}
    [ info.update({key: value}) for key, value in r.zrevrange(key, 0, -1, withscores=True) ]
    [ info.update({key_hour: value}) for key_hour, value in r.zrevrange(key_hour, 0, -1, withscores=True) ]
    return info

def __run__(params):
    perfdata = []
    data = load()
    for key, value in data.iteritems():
        if key.startswith("latency_"):
            # Calculate average latency
            k = key.replace("latency_", "")
            value = value / data.get(k)
        perfdata.append((key, str(value)))

    # Dovecot proxy
    for line in dovecot_proxy():
        if len(line) != 0:
            perfdata.append(("proxy_%s" % (line[2]), str(line[0])))

    # Count processes for common machines
    for p in ["smtpd", ]:
        total = len([ proc for proc in list_processes() if proc == p ])
        perfdata.append(("proc_%s" % (p), str(total)))

    perfdata = "|".join([ "=".join(x) for x in perfdata])
    return [0, "OK", perfdata]

if __name__== '__main__':
    print __run__({})