403Webshell
Server IP : 68.178.202.69  /  Your IP : 216.73.216.122
Web Server : Apache
System : Linux 69.202.178.68.host.secureserver.net 3.10.0-1160.139.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Nov 3 13:30:41 UTC 2025 x86_64
User : ikioworld ( 1005)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/fm-agent/plugins/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/fm-agent/plugins//opcache.py
import agent_util
import logging
from agent_util import float

try:
    # Python 2.x
    from urllib2 import urlopen
except ImportError:
    from urllib.request import urlopen

logger = logging.getLogger(__name__)


class OpCachePlugin(agent_util.Plugin):
    textkey = "opcache"
    label = "PHP OpCache"

    @classmethod
    def update_metrics(self, config):
        # Make initial call to opcache.py using url set in config
        metric = {}
        r = urlopen(config["opcache_url"])
        reply = r.read()
        reply = reply.strip().strip(";").split(";")
        for item in reply:
            if "time" in item:
                continue
            # So we can strip out the duplicate entries from the metadata like the duplicate free/used_memory stats
            # did this because the first metric it returns is the actual correct one, the second is the default
            elif item.split(":")[0] in metric.keys():
                continue
            elif "Array" in item:
                continue
            else:
                metric_name = item.split(":")[0]
                metric_value = item.split(":")[-1]
                metric[metric_name] = float(metric_value)
        return metric

    @classmethod
    def get_metadata(self, config):
        status = agent_util.MISCONFIGURED
        msg = "Missing/incorrect data in [opcache] block!"

        if "opcache_url" in config:
            url = config["opcache_url"]
            status = agent_util.SUPPORTED
            msg = None
        else:
            return {}

        metadata = {}
        metrics = self.update_metrics(config)

        options = []

        for textkey in metrics:
            if textkey == "Array":
                continue
            metadata[textkey] = {
                "label": textkey.replace("_", " ").title(),
                "options": options,
                "status": status,
                "error_message": msg,
            }
        return metadata

    def check(self, textkey, data, config):
        tmp = self.update_metrics(config)
        if textkey in tmp:
            # Adjusting for MB since it outputs in bytes
            if "memory" in textkey or "buffer" in textkey:
                return float(tmp[str(textkey)]) / 1048576
            else:
                return tmp[str(textkey)]
        else:
            return None

Youez - 2016 - github.com/yon3zu
LinuXploit