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

import pexpect
import socket
from datetime import datetime, date, timedelta
from distutils.spawn import find_executable
import sys
import os

hostname = socket.gethostname()
bibbconsole = '/opt/bacula/bin/bconsole'
hpastday = datetime.now() - timedelta(hours=13)
bacula_format_date = hpastday.strftime('%Y-%m-%d')

def bconsole(command, pattern, timeout):
    child = pexpect.spawn(bibbconsole)
    child.sendline(command)
    try:
        child.expect(pattern, timeout=timeout)
        child.close()
        return True
    except Exception,e:
        return False

def bconsole_runjob(timeout):
    now = datetime.now()
    today18 = now.replace(hour=18, minute=0, second=0, microsecond=0)
    today1805 = now.replace(hour=18, minute=0, second=0, microsecond=0)
    if now > today18 and now < today1805:

        try:
            child = pexpect.spawn(bibbconsole)
            child.sendline('run job=%s-%s-test yes' % (hostname, hostname))
            child.expect('Job queued. JobId=', timeout=timeout)
            child.close()
            return True
        except Exception,e:
            return False
    else:
        return True

def bconsole_lastjob():
    try:
        child = pexpect.spawn(bibbconsole)
        child.sendline('list jobs jobstatus=T jobtype=B order=DESC')
        child.expect(bacula_format_date)
        child.close()
        return True
    except Exception,e:
        return False

def __run__(params):
    if bconsole('m', '\*$', 300) == True or bconsole('status dir', '\*$', 300) == True and bconsole_runjob(300) == True and bconsole_lastjob() == True:
        return [0, 'OK: bacula seems to be working properly']
    else:
        return [2, 'CRITICAL: bacula seems to be stoped']