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/elasticsearch-snapshot.py
#!/usr/bin/python
import json
import requests, re
from datetime import datetime, timedelta
from elasticsearch.serializer import JSONSerializer

class SetEncoder(JSONSerializer):
   def default(self, obj):
       if isinstance(obj, set):
           return list(obj)
       if isinstance(obj, Something):
           return 'CustomSomethingRepresentation'
           return JSONSerializer.default(self, obj)

def __run__(params):
    try:
        host = params.get("host")
        porta = int(params.get("port"))
        prefix = params.get("prefix")
    except Exception, e:
        return [2, "CRITICAL - Error %s" % repr(e)]

    try:
        prefix = "%s" % prefix
        date = datetime.utcnow().strftime("%Y%m%d")
        old_date = datetime.strftime(datetime.now() - timedelta(1), "%Y%m%d")
        snapshot_name = prefix + date + '*'
        old_snapshot = prefix + old_date + '*'
    except Exception, e:
        return [2, "  CRITIAL - Error %s" % repr(e)]

    try:
        now = datetime.now()
        res = requests.get('http://%s:%s/_snapshot/backup/{}'.format(snapshot_name) % (host, porta))
        old = requests.get('http://%s:%s/_snapshot/backup/{}'.format(old_snapshot) % (host, porta))
        result1 = re.search ('SUCCESS', res.content)
        result2 = re.search ('SUCCESS', old.content)

        if now.hour <= 03 and 'SUCCESS' == result2.group(0): 
                return [0, "OK - Snapshot %s generated" % repr(str(old_snapshot))] 
        elif now.hour > 03 and 'SUCCESS' == result1.group(0):
                return [0, "OK - Snapshot %s generated" % repr(str(snapshot_name))]
        else:
                return [2, "CRITICAL - Snapshot %s don't exist" % repr(str(snapshot_name))]
    except Exception, e:
        return [2, "CRITICAL - %s" % repr(e)]