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: //lib/python2.7/site-packages/lap/resl_pleskcl.py
import re

# Temporary check for monitor resl number of pleskcl clients

def __run__(params):
    try:
        import pymongo
    except (ImportError, IOError):
        return [2, "CRITICAL - Error: python-pymongo not installed. Please install 'python-pymongo'"]
    try:
        from yaml import load
    except (ImportError, IOError):
        return [2, "CRITICAL - Error: python-yaml not installed. Please install 'python-yaml'"]

    try:
        warn = params.get("warn")
        crit = params.get('crit')
        if crit < warn:
            raise Exception('critical is lower than warn threshold please fix it')
    except Exception, e:
        return [2, "CRITICAL - Error: %s" % repr(e)]

    with open('/var/www/reseller-provisioning/config/mongo.yml', 'r') as stream:
        servers = load(stream)['production']['servers']

    try:
        c = pymongo.Connection(servers)
    except Exception, e:
        return [2, 'CRITICAL - Problems connecting on MongoDB: %s' % repr(e)]

    db = c['reseller_provisioning']
    install_servers = db['shared_installation_servers']
    results = install_servers.find()
    for result in results:
        if re.match('pleskcl', result['name']):
            servers_col = db['servers']
            result = servers_col.find_one( { 'name': result['name'] } )
            resellers_col = db['resellers']
            count = resellers_col.find( { '$and': [{'server_id': result['_id'] }, { 'status': { '$ne': 'deleted'}} ] }).count()

            if count < warn:
                return [0, 'OK - %d clients installed' % count]
            elif count >= warn and count < crit:
                return [1, 'WARN - %d clients installed' % count]
            else:
                return [2, 'CRIT: %d clients installed' % count]