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: //proc/self/root/lib/python2.7/site-packages/lap/workers_apache.py
import urllib2
import sys
import os
import yaml

def __run__(params):
    try:
        thresholds = yaml.load(params.get('thresholds'))
        noproxy = params.get("noproxy", False)
        if noproxy: 
            urllib2.getproxies = lambda: {}
            os.environ['no_proxy'] = '127.0.0.1,localhost'
        url = params.get("url", "http://localhost/server-status?auto")
        
    except Exception, e:
        return [2, "CRITICAL - Error: %s" % repr(e)]

    try:
        busy = idle = free = 0
        for line in [ line.split() for line in urllib2.urlopen(url).read().split("\n") if line ]:
            if line[0] == "Scoreboard:":
                idle = line[1].count("_")
                free = line[1].count(".")
                busy = len(line[1]) - (idle + free)

        perfdata = []
        perfdata.append(("workers_busy", str(busy)))
        perfdata.append(("workers_idle", str(idle)))
        perfdata.append(("workers_free", str(free)))
        perfdata = "|".join([ "=".join(x) for x in perfdata])

        total = busy + idle + free
        use = (float(busy) / float(total)) * 100
        if use > thresholds['critical']:
            return [2, "CRITICAL - %d (%.2f%%) busy apache workers (%d max)" % (busy, use, total), perfdata]
        elif use > thresholds['warning']:
            return [1, "WARNING - %d (%.2f%%) busy apache workers (%d max)" % (busy, use, total), perfdata]
        else:
            return [0, "OK - %d (%.2f%%) busy apache workers (%d max)" % (busy, use, total), perfdata]
    except Exception, e:
        return [2, "CRITICAL - Error: %s" % repr(e)]