{"id":1381,"date":"2013-10-01T23:02:12","date_gmt":"2013-10-01T21:02:12","guid":{"rendered":"http:\/\/www.extradrm.com\/?p=1381"},"modified":"2013-10-01T23:10:11","modified_gmt":"2013-10-01T21:10:11","slug":"monitoring-linux-servers-with-nagios-and-nrpe","status":"publish","type":"post","link":"https:\/\/www.extradrm.com\/?p=1381","title":{"rendered":"Monitoring Linux servers with Nagios and NRPE"},"content":{"rendered":"<p>Monitor linux hosts Nagios using le plugin NRPE. This is an Ubuntu install.<\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2013\/10\/nrpe.png\"><img loading=\"lazy\" class=\"alignnone size-full wp-image-1382\" alt=\"nrpe plugin\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2013\/10\/nrpe.png\" width=\"536\" height=\"144\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2013\/10\/nrpe.png 536w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2013\/10\/nrpe-300x80.png 300w\" sizes=\"(max-width: 536px) 100vw, 536px\" \/><\/a><\/p>\n<h2>On your server Nagios&#8230;<\/h2>\n<p>Ubuntu\/Debian:<\/p>\n<pre># sudo apt-get install nagios-nrpe-plugin<\/pre>\n<p>We must check too (commands.cfg):<\/p>\n<pre>...\r\n######\r\n# NRPE\r\n######\r\n\r\n# 'check_nrpe' command definition\r\ndefine command{\r\ncommand_name check_nrpe\r\ncommand_line $USER1$\/check_nrpe -H $HOSTADDRESS$ -c $ARG1$\r\n}\r\n...<\/pre>\n<hr\/>\n<h2>On the monitored server ..<strong>.<\/strong><\/h2>\n<p>Under Ubuntu\/Debian:<\/p>\n<pre># sudo apt-get install nagios-nrpe-server\r\n# sudo apt-get install nagios-plugins<\/pre>\n<p>Next, we need to set up the Nagios server to be able to check our machine.<\/p>\n<pre>sudo nano \/etc\/nagios\/nrpe.cfg<\/pre>\n<p>and change<\/p>\n<pre>allowed_hosts=127.0.0.1<\/pre>\n<p>to<\/p>\n<pre>allowed_hosts=127.0.0.1,x.x.x.x<\/pre>\n<p>where \u201cx.x.x.x\u201d is the ip address of your nagios server. Now restart the nrep daemon so it reloads the settings<\/p>\n<p>Under Ubuntu\/Debian start the service :<\/p>\n<pre># \/etc\/init.d\/nagios-nrpe-server start<\/pre>\n<p>next, we should check and make sure that the service is actually running. We can do this two ways<\/p>\n<pre>sudo ps -Al | grep nrpe<\/pre>\n<p>This will show a line where the process is started. If it just comes back without stating anything something is wrong. Another check is to make sure you machine is listening on the nrpe port<\/p>\n<pre>netstat -an | grep 5666<\/pre>\n<hr\/>\n<h2>Some checks to do from the Nagios server<\/h2>\n<p>Go on Nagios derver under (\/usr\/lib\/nagios\/plugins) and test plugin NRPE:<\/p>\n<pre># .\/check_nrpe -H Adresse_IP_du_serveur_Linux\r\nNRPE v2.7<\/pre>\n<p>If all is ok it will answer with NRPE Vn.n<\/p>\n<p>We can test directly from server the NRPE Services:<\/p>\n<pre># .\/check_nrpe -H Adresse_IP_du_serveur_Linux -c check_load<\/pre>\n<hr\/>\n<h2>Configure Nagios Server Models&#8230;<\/h2>\n<p>Edit (hosts.cfg default) and add a Linux host :<\/p>\n<pre>define host {\r\nuse generic-host\r\nhost_name linus\r\nalias Ma machine Linux\r\naddress 192.168.0.7\r\n}<\/pre>\n<p>Then add NRPE services (dans le fichier services.cfg), Some examples:<\/p>\n<pre># Charge CPU\r\ndefine service{\r\nuse generic-service\r\nhost_name remotehost\r\nservice_description CPU Load\r\ncheck_command check_nrpe!check_load\r\n}\r\n\r\n# Memoire\r\ndefine service{\r\nuse generic-service\r\nhost_name remotehost\r\nservice_description Memory\r\ncheck_command check_nrpe!check_mem\r\n}<\/pre>\n<p>To add new plugins to be executed byNRPE, edit \/etc\/nagios\/nrpe.cfg and add a line by service:<\/p>\n<pre>...\r\ncommand[check_disk]=\/usr\/lib\/nagios\/plugins\/check_disk -w 20 -c 10 -p \/dev\/hda\r\n...<\/pre>\n<p>Do not forget to launch service every time we update (nrpe.cfg):<\/p>\n<pre># \/etc\/init.d\/nagios-nrpe-server start<\/pre>\n<p>Cheers<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Monitor linux hosts Nagios using le plugin NRPE. This is an Ubuntu install. On your server Nagios&#8230; Ubuntu\/Debian: # sudo apt-get install nagios-nrpe-plugin We must check too (commands.cfg): &#8230; ###### # NRPE ###### #&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":2843,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[209,14],"tags":[233,234,235],"youtube_video":null,"_links":{"self":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts\/1381"}],"collection":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1381"}],"version-history":[{"count":0,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts\/1381\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/media\/2843"}],"wp:attachment":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1381"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1381"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1381"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}