/
usr
/
local
/
lib
/
python3.9
/
site-packages
/
agent360
/
plugins
/
/usr/local/lib/python3.9/site-packages/agent360/plugins
mkdir
upload
Name
Size
Mode
Actions
__pycache__/
-
0755
rm
apt-updates.py
1260
0644
edit
dl
rm
asterisk.py
1012
0644
edit
dl
rm
bind.py
732
0644
edit
dl
rm
bird.py
841
0644
edit
dl
rm
bitninja.py
1302
0644
edit
dl
rm
cloudlinux-dbgov.py
1066
0644
edit
dl
rm
cloudlinux.py
1020
0644
edit
dl
rm
cpanel.py
1441
0644
edit
dl
rm
cpu.py
2020
0644
edit
dl
rm
cpu_freq.py
583
0644
edit
dl
rm
dirsize.py
617
0644
edit
dl
rm
diskinodes.py
652
0644
edit
dl
rm
diskstatus-nvme.py
1618
0644
edit
dl
rm
diskstatus.py
2005
0644
edit
dl
rm
diskusage.py
4140
0644
edit
dl
rm
docker.py
3442
0644
edit
dl
rm
dovecot.py
1304
0644
edit
dl
rm
elasticsearch.py
4342
0644
edit
dl
rm
exim.py
484
0644
edit
dl
rm
fail2ban.py
831
0644
edit
dl
rm
gpu.py
959
0644
edit
dl
rm
haproxy.py
4274
0644
edit
dl
rm
httpd.py
2800
0644
edit
dl
rm
iostat.py
5227
0644
edit
dl
rm
janus.py
705
0644
edit
dl
rm
kamailio.py
556
0644
edit
dl
rm
litespeed.py
3114
0644
edit
dl
rm
loadavg.py
332
0644
edit
dl
rm
loggedin.py
400
0644
edit
dl
rm
mailq.py
528
0644
edit
dl
rm
mdstat.py
1388
0644
edit
dl
rm
megacli.py
2787
0644
edit
dl
rm
memcached.py
3165
0644
edit
dl
rm
memory.py
932
0644
edit
dl
rm
minecraft.py
2410
0644
edit
dl
rm
mongodb.py
5766
0644
edit
dl
rm
mysql.py
5256
0644
edit
dl
rm
network.py
2786
0644
edit
dl
rm
nginx.py
3275
0644
edit
dl
rm
openvpn.py
2223
0644
edit
dl
rm
phpfpm.py
2781
0644
edit
dl
rm
ping.py
3165
0644
edit
dl
rm
plesk-cgroups.py
6330
0644
edit
dl
rm
plugins.py
2538
0644
edit
dl
rm
postfix.py
1774
0644
edit
dl
rm
powerdns.py
4669
0644
edit
dl
rm
process.py
4365
0644
edit
dl
rm
proftpd.py
1130
0644
edit
dl
rm
rabbitmq.py
3569
0644
edit
dl
rm
redis_stat.py
5615
0644
edit
dl
rm
sleeper.py
244
0644
edit
dl
rm
swap.py
364
0644
edit
dl
rm
system.py
5811
0644
edit
dl
rm
tcpports.py
1110
0644
edit
dl
rm
temp.py
1480
0644
edit
dl
rm
unbound.py
3316
0644
edit
dl
rm
vms.py
6352
0644
edit
dl
rm
wp-toolkit.py
1845
0644
edit
dl
rm
yum-updates.py
810
0644
edit
dl
rm
__init__.py
0
0644
edit
dl
rm
Edit:
/usr/local/lib/python3.9/site-packages/agent360/plugins/haproxy.py
(4274B)
#!/usr/bin/env python # -*- coding: utf-8 -*- import time import plugins import csv import requests class Plugin(plugins.BasePlugin): __name__ = 'haproxy' def run(self, config): results = dict() next_cache = dict() try: username = config.get('haproxy', 'username') password = config.get('haproxy', 'password') user_pass = (username, password) except: user_pass = False status_page_url = config.get('haproxy', 'status_page_url') if not ";csv" in status_page_url: status_page_url = status_page_url + ";csv" request = requests.get(status_page_url, auth=user_pass) next_cache['ts'] = time.time() prev_cache = self.get_agent_cache() # Get absolute values from previous check if request.status_code is 200: response = request.text.split("\n") else: return "Could not load haproxy status page: {}".format(request.text) non_delta = ( 'qcur', 'qmax', 'scur', 'smax', 'slim', 'stot', 'weight', # 'act', # 'bck', # 'chkfail', # 'chkdown', # 'lastchg', # 'downtime', 'qlimit', # 'pid', # 'iid', # 'sid', 'throttle', 'lbtot', 'tracked', # 'type', 'rate', 'rate_lim', 'rate_max', # 'check_status', # 'check_code', # 'check_duration', 'hanafail', 'req_rate', 'req_rate_max', 'req_tot', # 'lastsess', # 'last_chk', # 'last_agt', # 'qtime', # 'ctime', # 'rtime', # 'ttime', # 'agent_status', # 'agent_code', # 'agent_duration', # 'agent_health', 'conn_rate', 'conn_rate_max', 'conn_tot', # 'intercepted' ) delta = ( 'bin', 'bout', 'cli_abrt', 'srv_abrt', 'intercepted', 'hrsp_1xx', 'hrsp_2xx', 'hrsp_3xx', 'hrsp_4xx', 'check_rise', 'check_fall', 'check_health', 'agent_rise', 'agent_fall', 'hrsp_5xx', 'comp_in', 'comp_out', 'comp_byp', 'comp_rsp', 'hrsp_other', 'dcon', 'dreq', 'dresp', 'ereq', 'econ', 'eresp', 'wretr', 'wredis', 'dses' ) csv_reader = csv.DictReader(response) data = dict() constructors = [str, float] for row in csv_reader: results[row["# pxname"]+"/"+row["svname"]] = {} data[row["# pxname"]+"/"+row["svname"]] = {} try: prev_cache[row["# pxname"]+"/"+row["svname"]]['ts'] = prev_cache['ts'] except KeyError: prev_cache[row["# pxname"]+"/"+row["svname"]] = {} for k, v in row.items(): for c in constructors: try: v = c(v) except ValueError: pass if k in non_delta: results[row["# pxname"]+"/"+row["svname"]][k] = v elif k in delta and type(v) is not str: results[row["# pxname"]+"/"+row["svname"]][k] = self.absolute_to_per_second(k, float(v), prev_cache[row["# pxname"]+"/"+row["svname"]]) data[row["# pxname"]+"/"+row["svname"]][k] = float(v) else: pass data['ts'] = time.time() self.set_agent_cache(data) return results if __name__ == '__main__': Plugin().execute()
Save
cmd:
run