nagios+centreon总结之第八章——Centreon 添加nagios检查命令

5.使用centreon命令之Commands

详细使用,请参考:

http://documentation.centreon.com/docs/centreon-clapi/en/latest/user/objects/commands.html#

使用centreon的commands参数,可以增、删、改nagios的检查命令。

①. 列出可用的Nagios命令,使用SHOW动作:

1)、命令:


centreon -u用户名 -p密码 -o HOST -o CMD -a   show


[[email protected]   ~]# centreon -uadmin -p123456 -o CMD -a show

id;name;type;line

1;check_host_alive;check;$USER1$/check_ping   -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 1

2;check_disk_smb;check;$USER1$/check_disk_smb   -H $HOSTADDRESS$ -s $ARG1$ -u $ARG2$ -p $ARG3$ -w $ARG4$ -c $ARG5$

3;check_distant_disk_space;check;$USER1$/check_distant_disk_space   -H $HOSTADDRESS$ -C $ARG1$ -p $ARG2$ -w $ARG3$ -c $ARG4$

4;check_centreon_dummy;check;$USER1$/check_centreon_dummy   -s $ARG1$ -o $ARG2$

……

列参数说明:


Column


Description


Command ID


Command name


自定义


Command type


Values:check, notif or misc


Command line


System command line that will be run on execution

②. 增加的Nagios命令,使用ADD动作:

格式:


centreon   -u用户名 -p密码 -o CMD -a ADD -v ‘命令名;类型;命令‘

注:直接定义命令时,需要使用单引号【’】,应为命令中含有变量【$...】。

1)、执行命令:


[[email protected]
  ~]# centreon -uadmin -p123456 -o CMD -a ADD -v  
‘centreon-check-mysql;check;$USER1$/check_mysql -H $HOSTADDRESS$ -P
$ARG1$ -u   $ARG2$ -p $ARG3$‘

[[email protected]   ~]#

2)、web显示结果:

3)、nagios配置文件结果:


[[email protected]   ~]# cd /usr/local/nagios/etc/

[[email protected]   etc]# grep centreon-check-mysql -R ./*

4)、激活配置,重启服务:

5)、nagios配置文件结果:


[[email protected]   etc]# grep centreon-check-mysql -R ./*

[[email protected]   etc]#

[[email protected]   etc]# grep centreon-check-mysql -R ./*

./checkcommands.cfg:    command_name                    centreon-check-mysql

[[email protected]   etc]#

6)、列参数说明:


Column


Description


Command ID


Command name


自定义


Command type


Values:check, notif or misc


Command line


System command line that will be run on execution

注:你需要重新生成配置文件,然后重新启动,以应用更改监控引擎。

命令的类型,很重要;一般能直接执行,且能获取到被监控机的信息的命令,使用check类型,而通知的命令,则使用notify。

③. 删除的Nagios命令,使用DEL动作:

格式:


centreon   -u用户名 -p密码 -o CMD -a DEL -v ‘命令名‘

注:直接定义命令时,需要使用单引号【’】,应为命令中含有变量【$...】。

1)、执行命令:


[[email protected]   ~]# centreon -uadmin -p123456 -o CMD -a DEL -v ‘centreon-check-mysql‘

[[email protected]   ~]#

注:你需要重新生成配置文件,然后重新启动,以应用更改监控引擎。

④. 修改的Nagios命令,使用SETPARAM动作:

格式:


centreon   -u用户名 -p密码 -o CMD -a SETPARAM -v ‘命令名;参数;值‘

注:直接定义命令时,需要使用单引号【’】,应为命令中含有变量【$...】。

1)、执行命令:


[[email protected]   etc]# centreon -uadmin -p123456 -o CMD -a show|grep centreon-check-mysql

119;centreon-check-mysql;check;$USER1$/check_mysql   -H $HOSTADDRESS$ -P $ARG1$ -u $ARG2$ -p $ARG3$

[[email protected]   etc]# centreon -uadmin -p123456 -o CMD -a SETPARAM -v   ‘centreon-check-mysql;type;notif‘

[[email protected]   etc]# centreon -uadmin -p123456 -o CMD -a show|grep centreon-check-mysql

119;centreon-check-mysql;notif;$USER1$/check_mysql   -H $HOSTADDRESS$ -P $ARG1$ -u $ARG2$ -p $ARG3$

[[email protected]   etc]# centreon -uadmin -p123456 -o CMD -a SETPARAM -v ‘centreon-check-mysql;name;fufangchun-check-mysql‘

[[email protected]   etc]# centreon -uadmin -p123456 -o CMD -a show|grep fufangchun-check-mysql

119;fufangchun-check-mysql;notif;$USER1$/check_mysql   -H $HOSTADDRESS$ -P $ARG1$ -u $ARG2$ -p $ARG3$

[[email protected]   etc]#

2)、列参数说明:


Parameter


Description


name


Name of command


line


Command line


type


check, notif, misc


graph


Graph template applied on command


example


Example of arguments (i.e: !80!90)


comment


Comments regarding the command

注:你需要重新生成配置文件,然后重新启动,以应用更改监控引擎。

至此,我们可以使用centreon命令,自动的添加nagios检查命令了,非常的方便。

时间: 2024-08-03 07:58:57

nagios+centreon总结之第八章——Centreon 添加nagios检查命令的相关文章

实战Nagios NSCA方式监控Linux系统资源使用情况 -- Nagios配置篇 -- Nagios Server端

关于nrpe的方式网上已经有很多很好的总结,我现在说说在我们系统中如何是用NSCA方式来获取我们需要的被监控节点的资源使用情况信息. 先讲讲Nagios Server端的基本配置: 1. nagios web gui 访问配置,系统中使用的是nagios core中推荐的配置方式,通过apache httpd访问nagios web,安装nagios的时候会自动寻找系统中安装的httpd,把nagios的httpd文件放到httpd的conf.d目录下,这样,只要生成一次nagios web访问

Cacti+Nagios监控系统(三):安装Nagios

一.添加用户 groupadd nagcmd useradd -G nagcmd nagios passwd nagios 123456 usermod -a -G nagcmd apache 二.安装nagios cd /root/download wget http://jaist.dl.sourceforge.net/project/nagios/nagios-4.x/nagios-4.0.7/nagios-4.0.7.tar.gz 也可以从这里下载:http://www.nagios.o

添加右键菜单命令 在此处打开命令窗口(W)(带图标)

@color 0A @title 添加右键菜单命令 在此处打开命令窗口(W)(带图标) by wjshan0808 @echo off reg add HKCR\Directory\Background\shell\在此处打开命令窗口(W) /v Icon /t reg_expand_sz /d %ComSpec% /f reg add HKCR\Directory\Background\shell\在此处打开命令窗口(W)\command /ve /t reg_sz /d "%ComSpec%

nodejs 编写(添加时间戳)命令行工具 timestamp

Nodejs除了编写服务器端程序还可以编写命令行工具,如gulp.js就是Nodejs编写的. 接下来我们来实现一个添加时间戳的命令: $ timestamp action https://www.npmjs.com/package/timestamp007 1.需要用的模块: commander  模块 用途 :解析命令行参数 主页: https://tj.github.io/commander.js/ fs 模块 用途 :于对系统文件及目录进行读写操作 2.命令格式 编写命令行工具前,首先定

win7下给右键菜单添加启动cmd命令

win7下给右键菜单添加启动cmd命令 (2013-07-20 19:20:56) 转载▼ 标签: it 右键 cmd 分类: 小软件操作技巧 最近编辑器在用windows下的gvim,但进入cmd命令启动vim,然后再cd到目录文件下比较麻烦,就看有没有方式可以直接右键就可以选择启动cmd命令,本意是在当前文件夹内的空白处点击右键,能够选择启动cmd命令. 于是就网上搜了一下,找到了如下这篇文章,链接是:http://dongwei.iteye.com/blog/816350  这两种方法我都

clion上添加程序的预定添加程序的命令行

例如我想在程序上,debug的状态下,添加命令行 //例如,本来生成是 mosquitto_sub //但我想在debug的状态下,添加命令行弄成如下,而方便我去测试 mosquitto_sub -h localhost -v -t "#" 就在下面的program arguments下,预定添加程序的命令行 原文地址:https://www.cnblogs.com/orangezs/p/8425445.html

实战Nagios NSCA方式监控Linux系统资源使用情况 -- Nagios配置篇 -- 被监控端

Nagios要求被监控端按照约定格式定时将数据发送到Nagios端.监控包括节点和服务2种. 节点监控约定数据格式如下: [<timestamp>] PROCESS_HOST_CHECK_RESULT;<host_name>;<host_status>;<plugin_output> 格式很容易理解,数据提交时间戳,被监控节点名称,节点状态(UP/DOWN/UNREARCHABLE),插件自定义的额外数据.状态具体每个字段的解释如下: 1. timestam

linux中添加用户后命令行改变

描述: [[email protected] /]# mkdir -p /u01/oracle[[email protected] /]# useradd -g oinstall -G dba -d /u01/oracle/ oracleuseradd: warning: the home directory already exists.Not copying any file from skel directory into it. 而且/u01/oracle目录下没有任何文件. 解决方法:

u-boot-2014.10移植第19天----添加nand flash命令支持(一)

今天继续移植nand flash,对于很多情况而言,u-boot从nand flash启动是一个至关重要的功能,毕竟NOR flash成本太高,不是所有开发板都会添加NOR flash. u-boot中的SMDK2410模板是没有支持从nand flash启动的功能的,但是却有支持操作nand_flash的操作命令,2410和2440在nand flash支持上的区别有: 1.2410仅支持小块nandflash,2440则同时支持大块nandflash:2.为支持大块nandflash,244