Difference between revisions of "Nagios"
From Wasya Wiki
(→Add a new custom check) |
|||
(12 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | == Install Server == | ||
+ | From: https://help.ubuntu.com/lts/serverguide/nagios.html.en | ||
+ | sudo apt install nagios3 nagios-nrpe-plugin | ||
+ | |||
+ | |||
+ | == Install Client == | ||
+ | apt-get install nagios-nrpe-server nagios-plugins-basic -y | ||
+ | |||
+ | == Client Important Files == | ||
+ | /etc/nagios/nrpe.cfg <- allowed_hosts of server goes here | ||
+ | /usr/lib/nagios/plugins <- specific checks go here | ||
+ | |||
+ | == Server Important Files== | ||
+ | /usr/lib/nagios/plugins <- nothing important here, actually | ||
+ | /etc/nagios3/config.d <- everything goes here | ||
+ | |||
+ | == Nagios Config == | ||
+ | * make sure IPs, ports, security groups allow communication | ||
+ | * client: in /etc/nagios/nrpe.cfg: | ||
+ | allowed_hosts <should include the server ip> | ||
+ | command[echo_ok3]=/usr/lib/nagios/plugins/echo_ok3 | ||
+ | * client: restart service | ||
+ | sudo kill -9 `ps aux | grep nr | grep -v color | awk '{print $2}'` ; /usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -d | ||
+ | * server: | ||
+ | define command { | ||
+ | command_name echo-ok3 | ||
+ | command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c echo_ok3 | ||
+ | } | ||
+ | define service { | ||
+ | service_description echo-ok3 | ||
+ | hostgroup_name microsites3_api | ||
+ | check_command echo-ok3 | ||
+ | use default-service | ||
+ | } | ||
+ | |||
+ | = Nagios Utils = | ||
==== Setup Client ==== | ==== Setup Client ==== | ||
apt-get install -y nagios-plugins nagios-nrpe-server | apt-get install -y nagios-plugins nagios-nrpe-server | ||
− | |||
==== Change password ==== | ==== Change password ==== | ||
htpasswd -c -b /etc/nagios/htpasswd.users nagiosadmin admin | htpasswd -c -b /etc/nagios/htpasswd.users nagiosadmin admin | ||
+ | |||
+ | = Nagios Custom Plugin = | ||
+ | |||
+ | ==== CHECK_NRPE: Error – Could not complete SSL handshake ==== | ||
+ | From: https://geekpeek.net/could-not-complete-ssl-handshake/ | ||
+ | |||
+ | = Add a new custom check = | ||
+ | Implement a new custom check: | ||
+ | * assume nagios3 server is already installed | ||
+ | * install nagios-nrpe-server on the client (sudo apt-get install nagios-nrpe-server -y) | ||
+ | * make sure allowed hosts are correct, as per https://geekpeek.net/could-not-complete-ssl-handshake/ (/etc/nagios/nrpe.conf) | ||
+ | * create the entry for the command on client in /etc/nagios/nrpe.conf (command[check_mongod]=/usr/lib/nagios/plugins/check_mongod) | ||
+ | * create /usr/lib/nagios/plugins/check_mongod | ||
+ | * restart nagios-nrpe-server | ||
+ | * check that you can connect on the server: ( root@utils:/usr/lib/nagios/plugins# ./check_nrpe -H 10.138.224.158 -c check_mongod ) | ||
+ | * add this check to this host | ||
+ | <pre> | ||
+ | root@utils:/etc/nagios3/conf.d# cat dev_mongo2.cfg | grep mongod -B 3 -A 7 | ||
+ | define service{ | ||
+ | use generic-service | ||
+ | host_name dev-mongo2.operaevent | ||
+ | service_description mongod service | ||
+ | check_command check_mongod | ||
+ | } | ||
+ | </pre> | ||
+ | * restart server ( root@utils:/etc/nagios3/conf.d# sudo service nagios3 restart ) | ||
+ | |||
+ | == Notes == | ||
+ | |||
+ | https://geekpeek.net/could-not-complete-ssl-handshake/ | ||
+ | |||
+ | verify configuration: | ||
+ | nagios3 -v /etc/nagios3/nagios.cfg | ||
+ | |||
+ | on client: | ||
+ | sudo service nagios-nrpe-server restart | ||
+ | |||
+ | on server: | ||
+ | sudo service nagios3 restart |
Latest revision as of 19:19, 2 April 2022
Contents
Install Server
From: https://help.ubuntu.com/lts/serverguide/nagios.html.en
sudo apt install nagios3 nagios-nrpe-plugin
Install Client
apt-get install nagios-nrpe-server nagios-plugins-basic -y
Client Important Files
/etc/nagios/nrpe.cfg <- allowed_hosts of server goes here /usr/lib/nagios/plugins <- specific checks go here
Server Important Files
/usr/lib/nagios/plugins <- nothing important here, actually /etc/nagios3/config.d <- everything goes here
Nagios Config
- make sure IPs, ports, security groups allow communication
- client: in /etc/nagios/nrpe.cfg:
allowed_hosts <should include the server ip> command[echo_ok3]=/usr/lib/nagios/plugins/echo_ok3
- client: restart service
sudo kill -9 `ps aux | grep nr | grep -v color | awk '{print $2}'` ; /usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -d
- server:
define command { command_name echo-ok3 command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c echo_ok3 } define service { service_description echo-ok3 hostgroup_name microsites3_api check_command echo-ok3 use default-service }
Nagios Utils
Setup Client
apt-get install -y nagios-plugins nagios-nrpe-server
Change password
htpasswd -c -b /etc/nagios/htpasswd.users nagiosadmin admin
Nagios Custom Plugin
CHECK_NRPE: Error – Could not complete SSL handshake
From: https://geekpeek.net/could-not-complete-ssl-handshake/
Add a new custom check
Implement a new custom check:
- assume nagios3 server is already installed
- install nagios-nrpe-server on the client (sudo apt-get install nagios-nrpe-server -y)
- make sure allowed hosts are correct, as per https://geekpeek.net/could-not-complete-ssl-handshake/ (/etc/nagios/nrpe.conf)
- create the entry for the command on client in /etc/nagios/nrpe.conf (command[check_mongod]=/usr/lib/nagios/plugins/check_mongod)
- create /usr/lib/nagios/plugins/check_mongod
- restart nagios-nrpe-server
- check that you can connect on the server: ( root@utils:/usr/lib/nagios/plugins# ./check_nrpe -H 10.138.224.158 -c check_mongod )
- add this check to this host
root@utils:/etc/nagios3/conf.d# cat dev_mongo2.cfg | grep mongod -B 3 -A 7 define service{ use generic-service host_name dev-mongo2.operaevent service_description mongod service check_command check_mongod }
- restart server ( root@utils:/etc/nagios3/conf.d# sudo service nagios3 restart )
Notes
https://geekpeek.net/could-not-complete-ssl-handshake/
verify configuration:
nagios3 -v /etc/nagios3/nagios.cfg
on client:
sudo service nagios-nrpe-server restart
on server:
sudo service nagios3 restart