標籤:ali 檢查 oca roc 使用者 efi chmod check objects
一、服務端配置:
- 安裝軟體:
yum -y install nagios nagios-plugins nagios-plugins-all nagios-plugins-nrpe nrpe
- 修改nagios主設定檔:vim /etc/nagios/nagios.cfg
cfg_dir=/etc/nagios/conf.d #確保其中有這行代碼
- 修改cgi設定檔,添加使用者:vim /etc/nagios/cgi.cfg
authorized_for_system_information=nagiosadmin,leeauthorized_for_configuration_information=nagiosadmin,leeauthorized_for_system_commands=nagiosadmin,leeauthorized_for_all_services=nagiosadmin,leeauthorized_for_all_hosts=nagiosadmin,leeauthorized_for_all_service_commands=nagiosadmin,leeauthorized_for_all_host_commands=nagiosadmin,lee
- 修改命令設定檔command.cfg:vim /etc/nagios/objects/commands.cfg
#添加define command{command_name check_nrpecommand_line $USER1/check_nrpe -H $HOSTADDRESS -c $ARG1}
- 修改連絡人設定檔:vim /etc/nagios/objects/contacts.cfg
define contact{ contact_name nagiosadmin use generic-contact alias Nagios Admin email [email protected] }define contactgroup{ contactgroup_name admins alias Nagios Administrators members nagiosadmin }
- 添加遠程主機的監控指令(可以用本地設定檔
/etc/nagios/objects/localhost.cfg
作為模板):
cp -arf /etc/nagios/objects/localhost.cfg /etc/nagios/conf.d/lee.cfg
vim /etc/nagios/conf.d/lee.cfgdefine host{ use linux-server host_name lee alias lee address 192.168.8.82 }#去掉這組定義#define hostgroup{# hostgroup_name linux-servers # alias Linux Servers # members lee # }define service{ use local-service host_name lee service_description PINGcheck_command check_ping!100.0,20%!500.0,60% }define service{ use local-service host_name lee service_description Root Partitioncheck_command check_local_disk!20%!10%!/ }define service{ use local-service host_name lee service_description Current Userscheck_command check_local_users!20!50 }define service{ use local-service host_name lee service_description Total Processescheck_command check_local_procs!250!400!RSZDT }define service{ use local-service host_name lee service_description Current Loadcheck_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0 }define service{ use local-service host_name lee service_description Swap Usagecheck_command check_local_swap!20!10 }define service{ use local-service host_name lee service_description SSHcheck_command check_sshnotifications_enabled 0 }define service{ use local-service host_name lee service_description HTTPcheck_command check_httpnotifications_enabled 0 }
- 檢查設定檔文法:
nagios -v /etc/nagios/nagios.cfg
- 修改nagios相關目錄許可權:
chown nagios.nagios /etc/logrotate.d/nagioschmod g+w /etc/logrotate.d/nagioschown -R nagios.nagios /etc/nagios
- 設定apache賬戶密碼:
htpasswd -c /etc/nagios/passwd lee
- 啟動服務:
systemctl start httpdsystemctl start nagios
二、用戶端配置:
- 安裝軟體:
yum -y install nagios-plugins nagios-plugins-nrpe nrpe
- 修改 nrpe 主設定檔:vim /etc/nagios/nrpe.cfg
#添加服務端ipallowed_hosts=127.0.0.1,192.168.8.81
- 啟動nrpe服務:
systemctl start nrpe
三、測試:
centos7安裝nagios