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/openstack_vms_status.py
#!/usr/bin/python
import json
import warnings

def __run__(params):

    warnings.filterwarnings("ignore")

    try:
        from novaclient.client import Client
        from keystoneauth1.identity import v3
        from keystoneauth1 import session
    except ImportError:
        return [1, 'WARNING  - Error: Please install python-novaclient']

    try:
        os_auth_url = params.get("auth_url", "http://localhost:5000/v2.0")
        os_username = params.get("username", "admin")
        os_password = params.get("password", "admin")
        os_tenant_name = params.get("tenant_name", "admin")
        if os_auth_url.endswith('v3'):
            auth = v3.Password(
                auth_url=os_auth_url,
                username=os_username,
                password=os_password,
                project_name=os_tenant_name,
                user_domain_name='Default',
                project_domain_name='Default',
            )
            sess = session.Session(auth=auth)
            nova = Client('2', session=sess)
        else:
            nova = Client('2.0', username=os_username, password=os_password,
                tenant_name=os_tenant_name, auth_url=os_auth_url, insecure=False)
    except Exception, e:
        return [2, 'CRITICAL - Error: %s' % repr(e)]

    try:
        servers = []
        for server in nova.servers.list(search_opts={'all_tenants': 1}):
            if server.status != 'ACTIVE':
                servers.append("%s has state %s" % (server.name, server.status))
        if servers:
            return [1, 'WARNING - %s ' % (json.dumps(servers))]
        else:
            return [0, 'OK - All servers in Openstack with status Active']
    except Exception as e:
       return [1, 'WARNING - %s' % str(e)]