• disable selinux
  • install packages and enable users <code> rpm -Uvh yum -y install httpd php gd mod_ssl nagios* htpasswd -c /etc/nagios/htpasswd.users nagiosadmin </code>
  • check that you have nagiosadmin user in /etc/nagios/cgi.cfg
  • edit /etc/nagios/objects/contacts.cfg to include your data, at least your email <code> service nagios restart service httpd restart </code>
  • test /nagios URL in your server
  • in shell <code> service nagios start service httpd start </code>
  • edit file /etc/nagios/objects/templates.cfg and add to the end of file <code> define service { name graphed-service actionurl /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$' onMouseOver='showGraphPopup(this)' onMouseOut= 'hideGraphPopup()' rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&period=week&rrdopts=-w+450+-j register 0 } </code> * Add graphed functionality to your server object definition file /etc/nagios/objects/host.cfg <code> define service{ use local-service,graphed-service hostname localhost servicedescription PING checkcommand check_ping!100.0,20%!500.0,60% } </code>
  • restart nagios and wait a few minutes

NRPE client enables Nagios to query and use plugins remotely from Linux and Windows servers. This one is about Linux client.

  • install software with yum <code> yum install nagios-nrpe nagios-plugins nagios-plugins-nrpe </code>
  • use nrpe daemon or xinetd, this one uses daemonized nrpe <code> vi /etc/nagios/nrpe.cfg </code>
  • fix allowedhosts according to your environment * fix the check commands according to your environment (w = warning, c = critical limit) <code> command[checkusers]=/usr/lib64/nagios/plugins/checkusers -w 5 -c 10 command[checkload]=/usr/lib64/nagios/plugins/checkload -w 10,7,4 -c 20,15,10 #command[checkload]=/usr/lib64/nagios/plugins/checkload -w 15,10,5 -c 30,25,20 command[checkrootv]=/usr/lib64/nagios/plugins/checkdisk -w 10% -c 5% -p /dev/mapper/vgmyserver-rootv command[checkzombieprocs]=/usr/lib64/nagios/plugins/checkprocs -w 5 -c 10 -s Z command[checktotalprocs]=/usr/lib64/nagios/plugins/checkprocs -w 350 -c 400 </code>
  • if you wish you can describe the service to /etc/services, needed if xinetd is used <code>nrpe 5666/tcp # Nagios NRPE</code>
  • make iptables allow rules if necessary <code> iptables -I INPUT -p TCP –dport 5666 -s nagios-server-ip service iptables save </code>
  • start nrpe daemon <code>service nrpe start</code>
  • do testing in client <code>/usr/lib64/nagios/plugins/checknrpe -H localhost</code> <code>/usr/lib64/nagios/plugins/checknrpe -H localhost -c checkusers</code> * do testing in nagios server /usr/lib64/nagios/plugins/checknrpe -H client-ip
  • edit file /etc/nagios/objects/commands.cfg <code> define command{ commandname checknrpe commandline $USER1$/checknrpe -H $HOSTADDRESS$ -c $ARG1$ } </code>
  • add the host to nagios server <code>vi /etc/nagios/objects/host.cfg</code>
  • example data for /etc/nagios/objects/host.cfg <code> define host{ use linux-server hostname myhost alias My Virtual server address } define service{ use local-service,graphed-service hostname myhost servicedescription PING checkcommand check_ping!100.0,20%!500.0,60% }

define service{

      use                             local-service,graphed-service
      host_name                       myhost
      service_description             Root Partition
      check_command                   check_nrpe!check_rootv


  • documents/nagios_on_centos.txt
  • Last modified: 2021/10/24 13:31
  • by