centreon批量添加主机脚本只能添加主机,不能生成和主机相关联的服务。此时需要用到centreon CLAPI,它是centreon命令行接口,可以替代在网页上的许多工作。具体介绍
http://forge.centreon.com/projects/centreon-clapi/wiki
一、安装clapi
#tar xf centreon-clcpi-1.1.tar.gz
#cd centreon-clapi-1.1
#./install.sh -i (交互式)
按提示输入配置文件路径:/usr/local/centreon/etc
#cd /usr/local/centreon/www/modules/centreon-clapi/core/
#vim +64 centreon
require_once "$centreon_etc/centreon.conf.php";改成
require_once "/usr/local/centreon/etc/centreon.conf.php";
二、使用
#./centreon -u -p -o HOST -a show
-u :web登陆账号
-p :web登陆密码
显示所有主机信息
#./centreon -u -p -o HOST -a applytpl -v "hostname"
对hostname主机添加关联的模板服务
三、批量添加服务脚本
#!/bin/bash user="admin" password="centreon" hostfile="./hosts" while read ip hostname do /usr/local/centreon/www/modules/centreon-clapi/core/centreon -u admin -p centreon -o HOST -a applytpl -v "$hostname" revalue=$(echo $?) echo "$hostname $revalue" sleep 1 done < $hostfile