標籤:nagios 監控 centreon cacti ndoutils
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顯示結果:
650) this.width=650;" src="http://static.oschina.net/uploads/space/2014/0924/143323_l76C_727880.png" alt="143323_l76C_727880.png" />
3)、nagios設定檔結果:
[[email protected] ~]# cd /usr/local/nagios/etc/ [[email protected] etc]# grep centreon-check-mysql -R ./* |
4)、啟用配置,重啟服務:
650) this.width=650;" src="http://static.oschina.net/uploads/space/2014/0924/143334_62sS_727880.png" alt="143334_62sS_727880.png" />
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檢查命令了,非常的方便。
本文出自 “無咎” 部落格,請務必保留此出處http://perofu.blog.51cto.com/6061242/1557709
nagios+centreon總結之第八章——Centreon 添加nagios檢查命令