HEX
Server: Apache
System: Linux dinesh8189 5.15.98-grsec-sharedvalley-2.lc.el8.x86_64 #1 SMP Thu Mar 9 09:07:30 -03 2023 x86_64
User: cgmgerenciamento1 (814285)
PHP: 8.1.26
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/thread-self/root/etc/zabbix/sower/sower_metrics.py
#!/usr/bin/python3.6
from __future__ import print_function
from __future__ import division
from requests import Session
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
import psutil
import socket
import json
import os
import sys

def GPP(data, url, route, method=None):
        endpoint = "http://%s/%s" %(url, route)
        header = {}
        header["Authorization"] = "Token cb935f472a8af723098d24740d7b3e84213f0f54"
        s = Session()
        s.trust_env = False
        if method == "GET":
                return s.get(endpoint, headers=header)
        elif method == "POST":
                header = {}
                header["Content-Type"] = "application/json"
                header["Authorization"] = "Token cb935f472a8af723098d24740d7b3e84213f0f54"
                return s.post(endpoint, headers=header, data=data)
        elif method == "PUT":
                header = {}
                header["Content-Type"] = "application/json"
                header["Authorization"] = "Token cb935f472a8af723098d24740d7b3e84213f0f54"
                return s.put(endpoint, headers=header, data=data)

def GET_APACHE(url):
        if url is not None:
                r = Session()
                r.trust_env = False
                return r.get(url)

try:
        d = {}
        server = socket.gethostname()
        m = psutil.virtual_memory()
        d["name"] = server
        d["cpu"] = psutil.cpu_percent(interval=1)
        d["memory_used"] = m.percent
        d["status"] = "true"
        d["elegible"] = "true"
        d["idleWorkers"] = [str(values) for values in GET_APACHE("http://localhost/server-status?auto").text.split("\n") if "IdleWorkers" in values][0].split(":")[1].strip()
        d["products"] = "new_shared_linux"
        d["sites"] =  [sites.endswith(".conf") for sites in os.listdir("/etc/locaweb/hospedagem/")].count(True)
        if d is not None:
                GET = GPP(json.dumps(d),"sower.infralwb.com.br","v2/shared_linux/{0}".format(server),method="GET")
                if GET.status_code == 400:
                        GPP(json.dumps(d),"sower.infralwb.com.br","v2/shared_linux",method="POST")
                else:
                        GPP(json.dumps(d),"sower.infralwb.com.br","v2/shared_linux/{0}".format(server),method="PUT")
                        print (1)
        else:
                GET = GPP(json.dumps(d),"sower.infralwb.com.br","v2/shared_linux/{0}".format(server),method="GET")
                if GET.status_code == 400:
                        GPP(json.dumps(d),"sower.infralwb.com.br","v2/shared_linux",method="POST")
                else:
                        GPP(json.dumps(d),"sower.infralwb.com.br","v2/shared_linux/{0}".format(server),method="PUT")
                        print (1)
except:
        print (0)