PyAgent

🔰 基于 asyncio 的高性能/插件式 Python Agent, 灵感来自 Telegraf, 跨平台的运维监控和指标采集客户端框架

MIT License

Stars
4

PyAgent ()

asyncio / Python Agent, . Windows/Linux, : Telegraf

  • , ,
  • , , /()
  • , ,
  • ,
    • : demo, cpu, mem, disk, process curl, network, ping, telnet

Python-3.8.5+, : requirements.txt

, src/conf/config.py update() .

YAML , 3 , :

(input/processor/aggs/output)
  > host.yaml( IP )
    > main.yaml(, )

:

pip3 install -r requirements.txt
# source ./scripts/etc-profile.d-pyagent.sh
python3 main.py
# nohup ./main.py >./log/run.log 2>&1 &
root@DevBeta:~/py/pyagent# python3 main.py 
2021-11-15 10:20:39.680 | DEBUG | src.conf.config.init_logger:288 | 
2021-11-15 10:20:39.681 | INFO | src.app.main:71 | PyAgent(v0.1.0) start working
2021-11-15 10:20:39.695 | INFO | src.app.start_plugins:93 | Plugin cpu start working
2021-11-15 10:20:39.696 | INFO | src.app.start_plugins:93 | Plugin mem start working
2021-11-15 10:20:39.697 | INFO | src.app.start_plugins:93 | Plugin disk start working
2021-11-15 10:20:39.699 | DEBUG | src.input.run:25 | input.cpu is working
2021-11-15 10:20:39.699 | DEBUG | src.processor.run:25 | processor.default(cpu) is working
2021-11-15 10:20:39.700 | DEBUG | src.aggs.run:26 | aggs.cpu(cpu) is working
2021-11-15 10:20:39.701 | DEBUG | src.output.run:25 | output.console(cpu) is working
2021-11-15 10:20:39.701 | DEBUG | src.output.es.run:30 | output.es(cpu) is working
2021-11-15 10:20:39.702 | DEBUG | src.output.default.run:21 | output.default(cpu) is working
2021-11-15 10:20:39.702 | DEBUG | src.input.run:25 | input.mem is working
2021-11-15 10:20:39.702 | DEBUG | src.processor.run:25 | processor.default(mem) is working
2021-11-15 10:20:39.703 | DEBUG | src.aggs.run:26 | aggs.mem(mem) is working
2021-11-15 10:20:39.703 | DEBUG | src.output.run:25 | output.console(mem) is working
2021-11-15 10:20:39.703 | DEBUG | src.output.es.run:30 | output.es(mem) is working
2021-11-15 10:20:39.704 | DEBUG | src.output.default.run:21 | output.default(mem) is working
2021-11-15 10:20:39.704 | DEBUG | src.input.run:25 | input.disk is working
2021-11-15 10:20:39.704 | DEBUG | src.processor.run:25 | processor.default(disk) is working
2021-11-15 10:20:39.705 | DEBUG | src.aggs.run:26 | aggs.disk(disk) is working
2021-11-15 10:20:39.705 | DEBUG | src.output.run:25 | output.console(disk) is working
2021-11-15 10:20:39.705 | DEBUG | src.output.es.run:30 | output.es(disk) is working
2021-11-15 10:20:39.706 | DEBUG | src.output.default.run:21 | output.default(disk) is working
>>> METRIC, name=mem time=2021-11-15T10:20:39+08:00 timestamp=1636942839 node_ip=0.0.0.0 host=WebServer total=8348397568 available=5567897600 percent=33.3 used=2422042624 free=433340416 active=3699130368 inactive=3444563968 buffers=349544448 cached=5143470080 shared=46780416 slab=621330432 human_total=7.8 GB human_available=5.2 GB human_used=2.3 GB human_free=413.3 MB human_active=3.4 GB human_inactive=3.2 GB human_buffers=333.4 MB human_cached=4.8 GB human_shared=44.6 MB human_slab=592.5 MB
>>> METRIC, name=disk time=2021-11-15T10:20:39+08:00 timestamp=1636942839 node_ip=0.0.0.0 host=WebServer device=/dev/sda2 mountpoint=/ fstype=ext4 opts=rw,relatime maxfile=255 maxpath=4096 total=42004086784 used=22808981504 free=17031004160 percent=57.3 human_total=39.1 GB human_used=21.2 GB human_free=15.9 GB
>>> METRIC, name=cpu time=2021-11-15T10:20:39+08:00 timestamp=1636942839 node_ip=0.0.0.0 host=WebServer cpu_logical_count=4 cpu_count=4 cpu_percent=2.4 cpu_times={'user': 1803486.75, 'nice': 4242.65, 'system': 437369.76, 'idle': 62342010.14, 'iowait': 3763.82, 'irq': 0.0, 'softirq': 97654.76, 'steal': 0.0, 'guest': 0.0, 'guest_nice': 0.0} cpu_stats={'ctx_switches': 17157214700, 'interrupts': 14394108423, 'soft_interrupts': 18238331768, 'syscalls': 0} cpu_freq={'current': 3300.0, 'min': 0.0, 'max': 0.0}

pyinstaller , etc main.exe .

(: : src/conf/config.py self.plugins = PLUGINS , Windows 7 2008 , Python-3.8)

dist , main.exe .

, Windows .

:

set PYAGENT_CONFIG_API_KEY=bbM1VU6LkCDM3pV67ELEBDvgH4YTkeoaBypVQhJYUuzwvZ && main.exe

:

pyinstaller -p E:\Python\github\PyAgent\venvw38\Lib\site-packages -F main.py -i doc\f.ico

etc/main.yaml , , , ().

.
 doc               
 etc               
  aggs          ()
  input         ()
  output        
  processor     
 log               
 src               
  aggs          : ()
  common        
  conf          
  input         : 
  libs          
  output        : 
  processor     : 
  test          
 venvw

ff

Related Projects