How to Install Nagios NRPE on Ubuntu 14.04

Create Nagios User and Group
useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios

Update your apt-get package lists:
apt-get update

Then install the required packages:
apt-get install build-essential libgd2-xpm-dev openssl libssl-dev apache2-utils unzip -y

Install Nagios
apt-get install nagios3 -y

–Local Only
–OK
–Create Web Admin (not needed)
user: nagios
pw: nagios

Now we will install NRPE:
apt-get install nagios-nrpe-server -y

Open the nrpe.cfg in an editor:

vi /etc/nagios/nrpe.cfg

Below this line: allowed_hosts=127.0.0.1
Add this line: allowed_hosts=216.x.x.x

Now add percona commands to nrpe.cfg

Add the following commands below this line include_dir=/etc/nagios/nrpe.d/.

command[pmp-check-mysql-status]=/usr/lib/nagios/plugins/pmp-check-mysql-status -x Threads_connected -o / -y max_connections -T pct -w 90
command[pmp-check-mysql-replication-running]=/usr/lib/nagios/plugins/pmp-check-mysql-replication-running
command[pmp-check-mysql-processlist]=/usr/lib/nagios/plugins/pmp-check-mysql-processlist -w 60 -c 90
command[pmp-check-mysql-replication-delay]=/usr/lib/nagios/plugins/pmp-check-mysql-replication-delay -w 2000 -c 3000
command[pmp-check-unix-memory]=/usr/lib/nagios/plugins/pmp-check-unix-memory
command[check_mysql_longqueries.pl]=/usr/lib/nagios/plugins/check_mysql_longqueries.pl -v -u nrpe -p “update-nrpepw” -w 6000 -c 8000

Note: Do not forget to update the nrpe password for check_mysql_longqueries and run this command:

aptitude install libnagios-object-perl libnagios-plugin-perl -y
Create mysql nrpe users. ****On cluster or replication this only has to done on one server****

CREATE USER ‘nrpe’@’localhost’ IDENTIFIED BY ‘new-password’;

GRANT ALL PRIVILEGES ON * . * TO ‘nrpe’@’localhost’;

FLUSH PRIVILEGES;
Create mysql.cnf

vi /etc/nagios/mysql.cnf

Add these lines
[client]
user=nrpe
password=”new-password”
Install percona-nagios-plugins:

cd /usr/lib/nagios/plugins

Now install nagios percona plugins.
apt-get install percona-nagios-plugins

Now restart nagios and naigos-nrpe-server
service nagios-nrpe-server restart
service nagios3 restart
Note: If probes are not working and on status you see: Reason: Gave up connecting to port 5666 after 0 seconds. Also in tail -n 50 /var/log/syslog:
Host 216.x.x.x is not allowed to talk to us!

Edit vi /etc/sudoers
Add: nagios ALL=(ALL) NOPASSWD: /usr/lib/nagios/plugins/