Nagios 插件编写
来源:互联网 发布:闪电精灵seo 编辑:程序博客网 时间:2024/05/17 09:21
脚本编写步骤
1、nagios插件编写规范
Nagios的插件可以用脚本(shell、Perl、python等)C编译后的可执行程序,但必须满足以下两件事:
a、退出时有一个返回值
b、至少向标准输出设备(STDOUT)输出一行文件。(但也不能太大,默认是4K )
Plugin Return Codes(具体参考官网 http://nagios-plugins.org/doc/guidelines.html#PREFACE)
Numeric Value
Service Status
Status Description
0
OK
The plugin was able to check the service and it appeared to be functioning properly
1
Warning
The plugin was able to check the service, but it appeared to be above some "warning" threshold or did not appear to be working properly
2
Critical
The plugin detected that either the service was not running or it was above some "critical" threshold
3
Unknown
Invalid command line arguments were supplied to the plugin or low-level failures internal to the plugin (such as unable to fork,or open a tcp socket) that prevent it from performing the specifiedoperation. Higher-level errors (such as name resolution errors,socket timeouts, etc) are outside of the control of plugins and shouldgenerally NOT be reported as UNKNOWN states.
下面是一个插件,就输出一句话:
#!/usr/bin/perl -w
my(%ERRORS) = ( OK=>0, WARNING=>1, CRITICAL=>2, UNKNOWN=>3 );
my $status=$ERRORS{OK};;
if( 1 ) {
print "OK,it's 1.";
exit $status;
}
写完脚本之后,要修改它的执行权限:chmod a+x 文件名
// 注意文件有后缀名的别忘了,要文件全称。
使用 Nagios 进行注册:
在 command.cfg中添加命令:(或者在 /etc/nagios-plugins/config/ 目录下创建一个文件,例如
,内容和下面一样) mygetloadavg2.cfg
define command{
command_name zccheck_disk
command_line /usr/lib/nagios/plugins/zccheck_disk.plmygetloadavg2.cfg
}
最后创建一个插件的服务:
define service{
host_name localhost
service_description zccheck-disk
check_command zccheck_disk
max_check_attempts 5
normal_check_interval 5
retry_check_interval 2
check_period 24x7
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
contact_groups sagroup
}
这样这个插件就可以显示在网页上了。
- 如何编写 Nagios 插件
- Nagios 插件编写
- nagios插件编写总结
- 为Nagios编写自己的插件
- Nagios插件编写及调试方法(shell)
- Nagios插件编写及调试方法
- nagios 插件编写:检查磁盘状况
- 用 Python 编写一个nagios监控磁盘负载的插件
- 通过自己编写的插件来使用 Nagios
- Nagios插件编写及调试方法(个人经验版)
- 通过自己编写的插件来使用 Nagios
- 关于nagios系统下使用shell脚本自定义监控插件的编写
- Nagios插件NDOUtils安装
- nagios 插件介绍
- nagios nrpe 插件开发
- Nagios的插件-nsca
- Nagios的插件-NSClient++
- nagios 插件--监控网速
- jquery操作select大全
- 网站项目必备——12款经典的白富美型 jQuery 图片轮播插件
- ReentrantLock实现源码剖析
- 栾城兴中鸽粮混合粮
- C#中抽象类里面建立静态方法
- Nagios 插件编写
- 算法导论——lec 02
- Linux 下 Eureka 服务器的部署
- sql之left join、right join、inner join的区别
- C++类静态成员与类静态成员函数
- Hibernate注解映射mysql数据库上text类型
- 精心挑选的12款优秀 jQuery Ajax 分页插件和教程
- 体绘制技术小结
- HTTPClient模块的HttpGet和HttpPost .