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/rqworker.py
import sys
import redis
import rq
import platform
import imp


def __run__(params):
    try:
        sys.path = filter(lambda p: p not in ('', '.'), sys.path)
        sys.path.append('')
        os_distro = platform.dist()[0].lower()
        if "debian" in os_distro or "ubuntu" in os_distro:
            rediscli = "/usr/share/pyshared/redis/__init__.py"
        else:
            rediscli = "/usr/lib/python%s.%s/site-packages/redis/__init__.py" %\
                         (sys.version_info.major, sys.version_info.minor)
        redis = imp.load_source("Redis", rediscli)
    except (ImportError, IOError):
        return [2, "CRITICAL - Error: Redis python client not found. Please install 'python-redis'"]

    try:
        host      = params.get("host", "localhost")
        port      = int(params.get("port", "6379"))
        db        = int(params.get("db", "0"))
        passwd    = params.get("passwd")
        queue     = params.get("queue")
        maxjobs_c = int(params.get("maxjobs", "100"))
        maxjobs_w = maxjobs_c * 0.7
    except Exception, e:
        return [2, "CRITICAL - Error: %s" % repr(e)]

    try:
        connection = redis.Redis(db=db, host=host, password=passwd)
        count = rq.Queue(name=queue, connection=connection).count
    except Exception, e:
        return [2, "CRITICAL - Error: %s" % repr(e)]

    if count >= maxjobs_c:
        return [2, "CRITICAL - Queue '%s' has %s pending jobs" % (queue, count)]
    if count >= maxjobs_w:
        return [1, "WARNING - Queue '%s' has %s pending jobs" % (queue, count)]
    return [0, "OK - Queue '%s' has %s pending jobs" % (queue, count)]