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/xen_expiration.py
#!/usr/bin/python

import socket
import subprocess
import datetime
import yaml

try:
    from xenapi import XenAPI
except:
    import XenAPI

socket.setdefaulttimeout(10)
def __run__(params):
    try:
        xapi = XenAPI.xapi_local()
        xapi.login_with_password("", "")
        hostname = socket.gethostname().split(".")[0]
        host_ref = xapi.xenapi.host.get_by_name_label(hostname)
        host = xapi.xenapi.host.get_record(host_ref[0])
        expire_date = host["license_params"]["expiry"].replace(":", "").replace("T", "").replace("Z", "").replace(" ", "")
        expire_days = params.get('expire_days')
        today = datetime.datetime.now()
        date = datetime.datetime(int(expire_date[0:4]), int(expire_date[4:6]), int(expire_date[6:8]), int(expire_date[8:10]), int(expire_date[10:12]), int(expire_date[12:14]))
        dif = date - today
        xapi.xenapi.session.logout()
        if dif.days >= int(expire_days):
            return [0, "OK - License is up-to-date. Expires on: %s" % date]
        elif dif.days >= 1:
            return [1, "WARNING - Verify XEN EXPIRATION: %s" % dif]
        else:
            return [2, "CRITICAL - Provide de new XenServer License. Expired on: %s" % dif]
    except Exception, e:
        xapi.xenapi.session.logout()
        return [2, "Unable to calc expiration day ERROR => %s" % repr(e)]