check_mk自定义监控插件
2014-03-31 16:15
1036 查看
客户端:
/usr/lib/check_mk_agent/plugins/filecount
#!/bin/bash
#DIRS="/var/log /tmp"
DIRS="/var/log"
echo '<<<filecount>>>'
for dir in $DIRS
do
# ls $dir | wc --lines
count=$(ls $dir | wc --lines)
echo "$count"
done
cd /usr/lib/check_mk_agent/plugins
chmod +x filecount
服务端:
服务端执行如下命令查看是否能够从客户端获取值
[root@LY-1611-E1 checks]# check_mk -d 10.8.18.53|fgrep -A 5 filecount
<<<filecount>>>
52
<<<postgres_sessions>>>
f 115
t 0
<<<postgres_stat_database:sep(59)>>>
在服务端创建文件filecount
/usr/share/check_mk/checks/filecount
def inventory_filecount_temp(info):
inventory = []
for line in info:
disk = line[0]
inventory.append( (disk, None) )
return inventory
def check_filecount_temp(item, params, info):
for line in info:
celsius = int(line[0])
if celsius > 200:
return (2, "filecount is %d" % celsius)
#return (2, "filecount is %d" % celsius)
elif celsius > 100:
return (1, "filecount50 is %d" % celsius)
else:
return (0, "filecount is %d" % celsius)
return (3, "Disk %s not found in agent output" % item)
check_info["filecount.temp"] = {
'check_function': check_filecount_temp,
'inventory_function': inventory_filecount_temp,
'service_description': 'filecount %s',
}
检查check_mk是否可以识别新增加的check
[root@LY-1611-E1 checks]# check_mk -L|grep filecount
filecount.temp tcp no yes filecount %s
[root@LY-1611-E1 checks]# check_mk --checks=filecount.temp -I 10.8.18.53
filecount.temp 1 new checks
查看服务端从客户端获取数据结果
[root@LY-1611-E1 checks]# check_mk -nv 10.8.18.53
Check_mk version 1.2.4
PostgreSQL Daemon Sessions WARN - 109 total(!), 109 running(!)
SMART drive /dev/sda WARN - Temperature40 is 34C
filecount 52 OK - filecount is 52
filecount filecount OK - filecount is 52
OK - Agent version 1.2.4, execution time 0.2 sec|execution_time=0.190 user_time=0.280 system_time=0.010 children_user_time=0.000 children_system_time=0.000
main.mk中增加监控项
checks += [("10.8.18.53","filecount.temp","filecount",(20,25))]
此文章参考官方网站而写
http://mathias-kettner.de/checkmk_devel_agentbased.html
/usr/lib/check_mk_agent/plugins/filecount
#!/bin/bash
#DIRS="/var/log /tmp"
DIRS="/var/log"
echo '<<<filecount>>>'
for dir in $DIRS
do
# ls $dir | wc --lines
count=$(ls $dir | wc --lines)
echo "$count"
done
cd /usr/lib/check_mk_agent/plugins
chmod +x filecount
服务端:
服务端执行如下命令查看是否能够从客户端获取值
[root@LY-1611-E1 checks]# check_mk -d 10.8.18.53|fgrep -A 5 filecount
<<<filecount>>>
52
<<<postgres_sessions>>>
f 115
t 0
<<<postgres_stat_database:sep(59)>>>
在服务端创建文件filecount
/usr/share/check_mk/checks/filecount
def inventory_filecount_temp(info):
inventory = []
for line in info:
disk = line[0]
inventory.append( (disk, None) )
return inventory
def check_filecount_temp(item, params, info):
for line in info:
celsius = int(line[0])
if celsius > 200:
return (2, "filecount is %d" % celsius)
#return (2, "filecount is %d" % celsius)
elif celsius > 100:
return (1, "filecount50 is %d" % celsius)
else:
return (0, "filecount is %d" % celsius)
return (3, "Disk %s not found in agent output" % item)
check_info["filecount.temp"] = {
'check_function': check_filecount_temp,
'inventory_function': inventory_filecount_temp,
'service_description': 'filecount %s',
}
检查check_mk是否可以识别新增加的check
[root@LY-1611-E1 checks]# check_mk -L|grep filecount
filecount.temp tcp no yes filecount %s
[root@LY-1611-E1 checks]# check_mk --checks=filecount.temp -I 10.8.18.53
filecount.temp 1 new checks
查看服务端从客户端获取数据结果
[root@LY-1611-E1 checks]# check_mk -nv 10.8.18.53
Check_mk version 1.2.4
PostgreSQL Daemon Sessions WARN - 109 total(!), 109 running(!)
SMART drive /dev/sda WARN - Temperature40 is 34C
filecount 52 OK - filecount is 52
filecount filecount OK - filecount is 52
OK - Agent version 1.2.4, execution time 0.2 sec|execution_time=0.190 user_time=0.280 system_time=0.010 children_user_time=0.000 children_system_time=0.000
main.mk中增加监控项
checks += [("10.8.18.53","filecount.temp","filecount",(20,25))]
此文章参考官方网站而写
http://mathias-kettner.de/checkmk_devel_agentbased.html
相关文章推荐
- check_mk自定义监控插件监控IIS站点的性能计数器
- 自定义check_mk监控插件过程中遇到的问题1
- check_mk检测插件 - raid监控
- check_mk检测插件编写
- check_mk通用应用检测插件
- 用php自定义 nagios监控插件
- check_postgres.pl插件监控postgresql数据库
- Nagios 自定义插件与安装使用之监控dead datanodes
- nagios自定义监控API插件
- nagios 监控slave(check_mysql_health插件)
- zabbix Simple checks 监控 自定义端口
- nagios 监控流量插件check_traffic
- nagios监控插件 nagios_oracle_health+check_linux_stats.pl
- 一款德国的Nagios插件---Check_mk 搭建
- 关于nagios系统下使用shell脚本自定义监控插件的编写
- 关于nagios系统下使用shell脚本自定义监控插件的编写
- Nagios通过check_megaraid_sas(基于MecaCli工具的插件)对RAID卡和硬盘进行监控的方法
- MongoDB nagios check_mongodb插件监控
- Nagios利用check_dell_openmanage插件监控dell服务器
- check_mk 分布式监控