码迷,mamicode.com
首页 > 其他好文 > 详细

zabbix user-defined item

时间:2018-04-30 13:22:24      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:like   form   pytho   param   except   for   efi   $1   else   

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‘")

zabbix user-defined item

标签:like   form   pytho   param   except   for   efi   $1   else   

原文地址:https://www.cnblogs.com/vickey-wu/p/8973210.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!