{"id":263,"date":"2015-09-07T16:08:29","date_gmt":"2015-09-07T16:08:29","guid":{"rendered":"http:\/\/onlinelab.info\/?p=263"},"modified":"2015-09-07T16:08:29","modified_gmt":"2015-09-07T16:08:29","slug":"monitor-remote-machine-with-icinga-on-centos-7","status":"publish","type":"post","link":"https:\/\/www.asianux.org.vn\/index.php\/2015\/09\/07\/monitor-remote-machine-with-icinga-on-centos-7\/","title":{"rendered":"Monitor remote machine with Icinga on CentOS 7"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7423\" src=\"http:\/\/www.itzgeek.com\/wp-content\/uploads\/2014\/08\/Icinga-Logo.png\" alt=\"Icinga Logo\" width=\"228\" height=\"107\" title=\"\"><\/p>\n<p>Once you installed the Icinga, you can monitor the system via web interface; by default it is limited to monitor the local machine where Icinga installed. If you like to monitor the remote Linux box or Windows box, you need to have Nagios plugin and NRPE add-on installed on the remote box. Once installed the plugin and add-on, you need to configure the Icinga server to collect the information from the remote machine and display it on the web interface.<\/p>\n<p>If you are yet to install the Icinga; visit the post of <a title=\"Setup Icinga Monitoring Tool on CentOS 7 \/ RHEL 7\" href=\"http:\/\/www.itzgeek.com\/how-tos\/linux\/centos-how-tos\/setup-icinga-monitoring-tool-on-centos-7-rhel-7.html\" target=\"_blank\" rel=\"nofollow noopener\">Installing Icinga on Centos 7<\/a>. Monitoring the Remote Linux system includes the 6 Steps<\/p>\n<h3><strong>Icinga Remote Host:<\/strong><\/h3>\n<ol>\n<li>Add User Account<\/li>\n<li>Download &amp; Install Nagios Plugin<\/li>\n<li>Install NRPE Add-on<\/li>\n<li>Configure NRPE Add-On<\/li>\n<\/ol>\n<h3><strong>Icinga Server Host:<\/strong><\/h3>\n<ol>\n<li>Configure Icinga Server<\/li>\n<li>Monitor remote machine.<\/li>\n<\/ol>\n<h3><strong>Icinga Remote Host:<\/strong><\/h3>\n<p>Install the required packages.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">yum install gcc cpp glibc-devel glibc-headers kernel-headers libgomp libmpc mpfr make openssl* xinetd<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h4><strong>Add User account:<\/strong><\/h4>\n<p>Before proceeding the installation, create a new user in the name of \u201cicinga\u201d and give it a password.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">useradd icinga<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Set the password.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">passwd icinga<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h4><strong>Download and Install Nagios Plugin:<\/strong><\/h4>\n<p>Download the Nagios plugins on the remote host using the following command ( For latest version Visit<a href=\"http:\/\/www.nagios.org\/download\/plugins\" target=\"_blank\" rel=\"nofollow noopener\">Nagios Website <\/a>)<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">cd \/tmp\nwget http:\/\/nagios-plugins.org\/download\/nagios-plugins-2.0.3.tar.gz<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Extract the Nagios plugins tarball.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">tar -zxvf \/tmp\/nagios-plugins-2.0.3.tar.gz\ncd \/tmp\/nagios-plugins-2.0.3<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Compile and install the plugin.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">.\/configure --prefix=\/usr\/local\/icinga --with-cgiurl=\/icinga\/cgi-bin --with-nagios-user=icinga --with-nagios-group=icinga\nmake\nmake install<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Change the permission of the nagios plugin directory on the remote host.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">chown icinga:icinga \/usr\/local\/icinga\/\nchown -R icinga:icinga \/usr\/local\/icinga\/libexec\/<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h4><strong>Download and install NRPE Add-on:<\/strong><\/h4>\n<p>Visit the <a href=\"http:\/\/sourceforge.net\/projects\/nagios\/files\/nrpe-2.x\/\" target=\"_blank\" rel=\"nofollow noopener\">Nagios download page<\/a> and download the NRPE Add-on.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">cd \/tmp\nwget http:\/\/downloads.sourceforge.net\/project\/nagios\/nrpe-2.x\/nrpe-2.15\/nrpe-2.15.tar.gz<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Once downloaded, Extract the tar ball.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">tar -zxvf \/tmp\/nrpe-2.15.tar.gz\ncd \/tmp\/nrpe-2.15<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Compile it.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">.\/configure --with-nagios-user=icinga --with-nagios-group=icinga --with-nrpe-group=icinga --with-nrpe-user=icinga --prefix=\/usr\/local\/icinga\nmake all\nmake install-plugin\nmake install-daemon\nmake install-daemon-config\nmake install-xinetd<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h4><strong>Configure NRPE Add-on:<\/strong><\/h4>\n<p>NRPE is the part of the xinetd daemon, modify the NRPE configurations file to accept the connection from the Nagios server, Edit the \/etc\/xinetd.d\/nrpe.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">vi \/etc\/xinetd.d\/nrpe<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Add the Nagios server ip address like below.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">only_from = 127.0.0.1 192.168.12.151<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Add NRPE port at the end of the \/etc\/services file.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">nrpe 5666\/tcp # NRPE<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Restart the Xinetd.d service.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">systemctl restart xinetd.service<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Confirm that NRPE Listening.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">netstat -at | grep 5666\ntcp6\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0 0 :::5666\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 :::*\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 LISTEN\u00a0\u00a0\u00a0\u00a0\u00a0 26780\/xinetd<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Confirm the NRPE functioning.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">\/usr\/local\/nagios\/libexec\/check_nrpe -H 127.0.0.1\nNRPE v2.15<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h4><strong>Modify NRPE Config file:<\/strong><\/h4>\n<p>Modify the\u00a0\/usr\/local\/icinga\/etc\/nrpe.cfg on the remote host, it contains the command argument to check the service on the remote host. The nrpe.cfg file contains the basic commands to check the remote services, below are the command lines to check the cpu load and running process. Thecheck_load and check_total_procs has to be entered on template file on the server host to enable the monitoring.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">command[check_load]=\/usr\/local\/nagios\/libexec\/check_load -w 15,10,5 -c 30,25,20\ncommand[check_total_procs]=\/usr\/local\/nagios\/libexec\/check_procs -w 150 -c 200<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>In the above command -w stands for warning whereas -c stands for critical alert. For example if you execute the second command on the terminal, it will check the running process; it will warn when the process more than 150 or it will report critical when the process more than 200 and at the same time it will say OK if process below 150.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">\/usr\/local\/icinga\/libexec\/check_procs -w 150 -c 200\nPROCS OK: 17 processes | procs=17;150;200;0;<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Change warning to 15 and critical to 150 for testing purpose, since process running\u00a0 on the server is very less. Now you can see the warning message, according to your requirement you can modify it.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">\/usr\/local\/icinga\/libexec\/check_procs -w 15 -c 200\nPROCS WARNING: 17 processes | procs=17;15;200;0;<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h3><strong>Icinga Server Host:<\/strong><\/h3>\n<p>On Icinga server we must have NRPE add-on installed and template of the remote host.<\/p>\n<h4><strong>Install NRPE Add-on:<\/strong><\/h4>\n<p>Visit the Nagios download page and <a href=\"http:\/\/sourceforge.net\/projects\/nagios\/files\/nrpe-2.x\/\" target=\"_blank\" rel=\"nofollow noopener\">download the NRPE Add-on<\/a>.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">cd \/tmp\nwget http:\/\/downloads.sourceforge.net\/project\/nagios\/nrpe-2.x\/nrpe-2.15\/nrpe-2.15.tar.gz<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Once downloaded, Extract the tar ball.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">tar -zxvf \/tmp\/nrpe-2.15.tar.gz\ncd \/tmp\/nrpe-2.15<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Compile it.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">.\/configure --with-nagios-user=icinga --with-nagios-group=icinga --with-nrpe-group=icinga --with-nrpe-user=icinga --prefix=\/usr\/local\/icinga\nmake all\nmake install-plugin<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h4><strong>Configure Nagios Server:<\/strong><\/h4>\n<p>Now its the time configure the Icinga server to monitor the remote client, You\u2019ll need to create a command definition in one of your Icinga object configuration files in order to use the check_nrpe plugin. Edit commands.cfg file.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">vi \/usr\/local\/icinga\/etc\/objects\/commands.cfg<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Add the following command definition to the file.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\"># .check_nrpe. command definition\ndefine command{\ncommand_name check_nrpe\ncommand_line $USER1$\/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$\n}<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Create the new configuration file (\/usr\/local\/icinga\/etc\/objects\/remote.cfg) to define the host and service definition. You can use the following template, modify according to your requirement. The following is configured to display the CPU Load,Disk Space,Current Users. Etc..,<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">define host{\nuse linux-server\nhost_name remote.itzgeek.com\nalias Client 1\naddress 192.168.12.102\n}\ndefine hostgroup{\nhostgroup_name Linux Client\nalias Linux Client 1\nmembers remote.itzgeek.com\n}\ndefine service{\nuse local-service\nhost_name remote.itzgeek.com\nservice_description Root Partition\ncheck_command check_nrpe!check_hda1\n}\ndefine service{\nuse local-service\nhost_name remote.itzgeek.com\nservice_description Current Users\ncheck_command check_nrpe!check_users\n}\ndefine service{\nuse local-service\nhost_name remote.itzgeek.com\nservice_description Total Processes\ncheck_command check_nrpe!check_total_procs\n}\ndefine service{\nuse local-service\nhost_name remote.itzgeek.com\nservice_description Current Load\ncheck_command check_nrpe!check_load\n}<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Add the new template on the icinga.cfg configuration file, so that it will read the new entries.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">vi \/usr\/local\/icinga\/etc\/icinga.cfg<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Add below line.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\"># Definitions for monitoring the Remote (Linux) host\ncfg_file=\/usr\/local\/icinga\/etc\/objects\/remote.cfg<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Restart the icinga server.<\/p>\n<div class=\"wp_syntax\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\">\n<pre class=\"dos\">\/etc\/init.d\/icinga restart<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h3><strong>Monitor the remote machine:<\/strong><\/h3>\n<p>Now login to the web interface and start do the monitoring. The following screenshot shows the remote Linux server with the default service available.<\/p>\n<figure id=\"attachment_7438\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.itzgeek.com\/wp-content\/uploads\/2014\/08\/CentOS-7-Icinga-With-Remote-Monitoring.jpg\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7438\" src=\"http:\/\/www.itzgeek.com\/wp-content\/uploads\/2014\/08\/CentOS-7-Icinga-With-Remote-Monitoring.jpg\" alt=\"CentOS 7 - Icinga With Remote Monitoring\" width=\"640\" height=\"300\" title=\"\"><\/a><figcaption class=\"wp-caption-text\">CentOS 7 \u2013 Icinga With Remote Monitoring<\/figcaption><\/figure>\n<p>That\u2019s All. Now you can easily monitor the remote machine with Icinga.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Once you installed the Icinga, you can monitor the system via web interface; by default it is limited to monitor the local machine where Icinga installed. If you like to monitor the remote Linux box&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-263","post","type-post","status-publish","format-standard","hentry","category-monitoring"],"_links":{"self":[{"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/posts\/263","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/comments?post=263"}],"version-history":[{"count":0,"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/posts\/263\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/media?parent=263"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/categories?post=263"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.asianux.org.vn\/index.php\/wp-json\/wp\/v2\/tags?post=263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}