zabbix user-defined item

1、user-defind item at:/etc/zabbix/zabbix_agent.conf

format: UserParameter=<key>,<command>
UnsafeUserParameters=1
UserParameter=memory.free,/usr/bin/free | awk '/^Mem/{print $4}'
UserParameter=memory.info[*],/bin/cat /proc/meminfo | awk '/^$1/{print $$2}'
UserParameter=load.info[*],/etc/zabbix/key/load_info.py $1

2、item at frontend
format: key <key> note: <key> should be the same as zabbix_agent.conf key:load.info[LoadOneMin]
3、user-defind script: load_info.py

# -*- coding: UTF-8 -*-
import sys
import os
para = None
try:
    para = sys.argv[1]
except Exception as e:
    print("please input para, like 'LoadOneMin'")
if para == "LoadOneMin":
    LoadOneMin = os.system("uptime | awk -F',| +' '{print $14}'")
elif para == "LoadFiveMin":
    LoadOneMin = os.system("uptime | awk -F',| +' '{print $16}'")
elif para == "LoadFifthMin":
    LoadOneMin = os.system("uptime | awk -F',| +' '{print $18}'")
else:
    print("please input para, like 'LoadOneMin'")

猜你喜欢

转载自www.cnblogs.com/vickey-wu/p/8973210.html
今日推荐