{"id":3466,"date":"2024-05-28T22:54:54","date_gmt":"2024-05-28T17:24:54","guid":{"rendered":"https:\/\/www.veeble.org\/kb\/?p=3466"},"modified":"2025-04-09T12:40:05","modified_gmt":"2025-04-09T07:10:05","slug":"how-to-monitor-a-vps-using-nagios","status":"publish","type":"post","link":"https:\/\/www.veeble.com\/kb\/how-to-monitor-a-vps-using-nagios\/","title":{"rendered":"How to Monitor a VPS Using Nagios"},"content":{"rendered":"\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2024\/05\/Remote-VPS-Monitoring-Made-Easy.jpg\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"536\" src=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2024\/05\/Remote-VPS-Monitoring-Made-Easy-1024x536.jpg\" alt=\"Nagios Monitoring\" class=\"wp-image-3470\" srcset=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/05\/Remote-VPS-Monitoring-Made-Easy-1024x536.jpg 1024w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/05\/Remote-VPS-Monitoring-Made-Easy-300x157.jpg 300w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/05\/Remote-VPS-Monitoring-Made-Easy-768x402.jpg 768w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/05\/Remote-VPS-Monitoring-Made-Easy.jpg 1200w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>As a server administrator, constantly checking the status of each server manually can be time-consuming and overwhelming. Monitoring individual commands and server health can quickly become a headache, especially in a large infrastructure. Thankfully, Nagios simplifies this task by providing a centralized monitoring solution. It continuously monitors the health of servers and notifies you of any issues. Business professionals, IT managers, and network engineers also struggle with maintaining the health and performance of their systems.&nbsp;<\/p>\n\n\n\n<p>Nagios is an ideal solution for all these professionals. It offers comprehensive monitoring capabilities, proactive alerting, and detailed reporting, making it easier to maintain optimal performance and uptime across diverse IT environments. By configuring <a href=\"https:\/\/en.wikipedia.org\/wiki\/Nagios\" target=\"_blank\" rel=\"noopener\">Nagios<\/a> to monitor remote servers, such as a Virtual Private Server (VPS), you can ensure that your systems are running smoothly without the need for constant manual checks. This guide will walk you through the steps to set up Nagios to monitor a remote VPS, streamlining your monitoring tasks and providing peace of mind.&nbsp;<\/p>\n\n\n\t\t\t\t<div class=\"wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-f70c68a5      \"\n\t\t\t\t\tdata-scroll= \"1\"\n\t\t\t\t\tdata-offset= \"30\"\n\t\t\t\t\tstyle=\"\"\n\t\t\t\t>\n\t\t\t\t<div class=\"uagb-toc__wrap\">\n\t\t\t\t\t\t<div class=\"uagb-toc__title\">\n\t\t\t\t\t\t\tTable Of Contents\t\t\t\t\t\t<\/div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"uagb-toc__list-wrap \">\n\t\t\t\t\t\t<ol class=\"uagb-toc__list\"><li class=\"uagb-toc__list\"><a href=\"#prerequisites\" class=\"uagb-toc-link__trigger\">Prerequisites<\/a><li class=\"uagb-toc__list\"><a href=\"#configure-remote-server\" class=\"uagb-toc-link__trigger\">Configure remote server<\/a><ul class=\"uagb-toc__list\"><li class=\"uagb-toc__list\"><a href=\"#1-update-the-package-manager\" class=\"uagb-toc-link__trigger\">1: Update the Package Manager<\/a><li class=\"uagb-toc__list\"><li class=\"uagb-toc__list\"><a href=\"#2-install-required-packages\" class=\"uagb-toc-link__trigger\">2: Install Required Packages<\/a><li class=\"uagb-toc__list\"><li class=\"uagb-toc__list\"><a href=\"#3-configure-nrpe\" class=\"uagb-toc-link__trigger\">3: Configure NRPE<\/a><ul class=\"uagb-toc__list\"><li class=\"uagb-toc__list\"><a href=\"#set-allowed-hosts\" class=\"uagb-toc-link__trigger\">Set Allowed Hosts:<\/a><li class=\"uagb-toc__list\"><li class=\"uagb-toc__list\"><a href=\"#define-commands\" class=\"uagb-toc-link__trigger\">Define Commands:<\/a><\/li><\/ul><\/li><\/ul><\/li><li class=\"uagb-toc__list\"><a href=\"#configure-nagios-server\" class=\"uagb-toc-link__trigger\">Configure Nagios Server<\/a><ul class=\"uagb-toc__list\"><li class=\"uagb-toc__list\"><a href=\"#verify-configuration\" class=\"uagb-toc-link__trigger\">Verify Configuration<\/a><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/li><li class=\"uagb-toc__list\"><a href=\"#access-the-nagios-web-interface\" class=\"uagb-toc-link__trigger\">Access the Nagios Web Interface<\/a><ul class=\"uagb-toc__list\"><li class=\"uagb-toc__list\"><a href=\"#conclusion\" class=\"uagb-toc-link__trigger\">Conclusion<\/a><li class=\"uagb-toc__list\"><li class=\"uagb-toc__list\"><a href=\"#supercharge-wordpress-managed-hosting-that-works\" class=\"uagb-toc-link__trigger\">Supercharge WordPress: Managed Hosting That Works.<\/a><\/ul><\/ul><\/ul><\/ul><\/ol>\t\t\t\t\t<\/div>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\n\n\n<p><\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"prerequisites\"><strong>Prerequisites<\/strong><\/h2>\n\n\n<ul class=\"wp-block-list\">\n<li>A Nagios server already set up and running.<\/li>\n\n\n\n<li>Root or sudo access to both the Nagios server and the remote VPS.<\/li>\n\n\n\n<li>The remote VPS should be running a Linux-based operating system.<\/li>\n<\/ul>\n\n\n<h2 class=\"wp-block-heading\" id=\"configure-remote-server\"><strong>Configure remote server<\/strong><\/h2>\n\n<h4 class=\"wp-block-heading\" id=\"1-update-the-package-manager\">1: <strong>Update the Package Manager<\/strong><\/h4>\n\n\n<p>Ensure your system is up-to-date by running.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yum update<\/code><\/pre>\n\n\n<h4 class=\"wp-block-heading\" id=\"2-install-required-packages\">2: <strong>Install Required Packages<\/strong><\/h4>\n\n\n<p>Install the NRPE (Nagios Remote Plugin Executor) and Nagios plugins packages:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>yum install nrpe nagios-plugins-all<\/code><\/pre>\n\n\n<h4 class=\"wp-block-heading\" id=\"3-configure-nrpe\">3: Configure NRPE<\/h4>\n\n\n<p>Edit the NRPE configuration file<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vi \/etc\/nagios\/nrpe.cfg<\/code><\/pre>\n\n\n<h5 class=\"wp-block-heading\" id=\"set-allowed-hosts\">Set Allowed Hosts:<\/h5>\n\n\n<p>Add your Nagios server&#8217;s IP address to the allowed_hosts directive:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>allowed_hosts=127.0.0.1,::1,&lt;Nagios_Server_IP&gt;<\/code><\/pre>\n\n\n<h5 class=\"wp-block-heading\" id=\"define-commands\">Define Commands:<\/h5>\n\n\n<p>Add command definitions for checks you want NRPE to execute:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>command&#91;check_disk]=\/usr\/lib64\/nagios\/plugins\/check_disk -w 20% -c 10% -p \/\ncommand&#91;check_load]=\/usr\/lib64\/nagios\/plugins\/check_load -w 15,10,5 -c 30,25,20\ncommand&#91;check_procs]=\/usr\/lib64\/nagios\/plugins\/check_procs -w 150 -c 200\ncommand&#91;check_users]=\/usr\/lib64\/nagios\/plugins\/check_users -w 5 -c 10<\/code><\/pre>\n\n\n\n<p>Adjust paths and thresholds as needed for your environment.<\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"configure-nagios-server\"><strong>Configure Nagios Server<\/strong><\/h2>\n\n\n<p>On your Nagios server, configure it to monitor the remote VPS using the NRPE plugin.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Edit the Nagios services configuration file<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-preformatted\">cd \/usr\/local\/nagios\/etc\/objects<br>vi server.conf<\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>define host {\n    use                     linux-server\n    host_name               remote-vps\n    alias                   Remote VPS\n    address                 *********\n    max_check_attempts      5\n    check_period            24x7\n    notification_interval   30\n    notification_period     24x7\n}\n\ndefine service {\n    use                     generic-service\n    host_name               remote-vps\n    service_description     Disk Usage\n    check_command           check_nrpe!check_disk\n}\n\ndefine service {\n    use                     generic-service\n    host_name               remote-vps\n    service_description     Load\n    check_command           check_nrpe!check_load\n}\n\ndefine service {\n    use                     generic-service\n    host_name               remote-vps\n    service_description     Processes\n    check_command           check_nrpe!check_procs\n}\n\ndefine service {\n    use                     generic-service\n    host_name               remote-vps\n    service_description     Users\n    check_command           check_nrpe!check_users\n}\n<\/code><\/pre>\n\n\n\n<p>Note:  Add the above configuration, replacing &lt;*********&gt; with the appropriate IP address(Remote server):<\/p>\n\n\n\n<p>    2. Reload Nagios Configuration:<\/p>\n\n\n\n<p>After making changes to the configuration, reload the Nagios service to apply them:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl reload nagios<\/code><\/pre>\n\n\n<h4 class=\"wp-block-heading\" id=\"verify-configuration\"><strong>Verify Configuration<\/strong><\/h4>\n\n\n<p>Test NRPE Locally on the Remote VPS:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Ensure the NRPE commands work locally:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>\/usr\/lib64\/nagios\/plugins\/check_disk -w 20% -c 10% -p \/\n\/usr\/lib64\/nagios\/plugins\/check_load -w 15,10,5 -c 30,25,20<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-27-125449-1.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"997\" height=\"91\" src=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-27-125449-1.png\" alt=\"verify NRPE\" class=\"wp-image-3472\" srcset=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-27-125449-1.png 997w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-27-125449-1-300x27.png 300w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-27-125449-1-768x70.png 768w\" sizes=\"auto, (max-width: 997px) 100vw, 997px\" \/><\/a><\/figure>\n\n\n<h2 class=\"wp-block-heading\" id=\"access-the-nagios-web-interface\">Access the Nagios Web Interface<\/h2>\n\n\n<p>Open a web browser and navigate to the Nagios web interface. The URL format will depend on your server&#8217;s IP address or hostname.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>http:\/\/&lt;server IP&gt;\/nagios<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-28-224539.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"485\" src=\"https:\/\/www.veeble.org\/kb\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-28-224539-1024x485.png\" alt=\"Nagios web interface\" class=\"wp-image-3471\" srcset=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-28-224539-1024x485.png 1024w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-28-224539-300x142.png 300w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-28-224539-768x364.png 768w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-28-224539-1536x728.png 1536w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/05\/Screenshot-2024-05-28-224539.png 1792w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p><\/p>\n\n\n<h3 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h3>\n\n\n<p>By following these steps, you can access the Nagios web interface, providing you with a powerful tool to monitor and manage your network infrastructure. The web interface offers a comprehensive overview of the status of your hosts and services, enabling you to quickly identify and address any issues. This streamlined monitoring process helps maintain optimal performance and reliability across your IT environment, reducing the burden on server administrators and other IT professionals.<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-uagb-call-to-action uagb-block-a1ce4489 wp-block-button\"><div class=\"uagb-cta__wrap\"><h3 class=\"uagb-cta__title\">Supercharge WordPress: Managed Hosting That Works.<\/h3><p class=\"uagb-cta__desc\">Stop server headaches. Blazing speed, security, &amp; expert support. Automatic updates, backups &amp; staging. Focus on your content.<\/p><\/div><div class=\"uagb-cta__buttons\"><a href=\"https:\/\/www.veeble.com\/in\/managed-wordpress\/\" class=\"uagb-cta__button-link-wrapper wp-block-button__link\" target=\"_blank\" rel=\"noopener noreferrer\">Explore Plans<svg xmlns=\"https:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\"><path d=\"M504.3 273.6l-112.1 104c-6.992 6.484-17.18 8.218-25.94 4.406c-8.758-3.812-14.42-12.45-14.42-21.1L351.9 288H32C14.33 288 .0002 273.7 .0002 255.1S14.33 224 32 224h319.9l0-72c0-9.547 5.66-18.19 14.42-22c8.754-3.809 18.95-2.075 25.94 4.41l112.1 104C514.6 247.9 514.6 264.1 504.3 273.6z\"><\/path><\/svg><\/a><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>As a server administrator, constantly checking the status of each server manually can be time-consuming and overwhelming. Monitoring individual commands and server health can [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":3470,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[3,5],"tags":[],"class_list":["post-3466","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-installation","category-linux"],"uagb_featured_image_src":{"full":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/05\/Remote-VPS-Monitoring-Made-Easy.jpg",1200,628,false],"thumbnail":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/05\/Remote-VPS-Monitoring-Made-Easy-150x150.jpg",150,150,true],"medium":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/05\/Remote-VPS-Monitoring-Made-Easy-300x157.jpg",300,157,true],"medium_large":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/05\/Remote-VPS-Monitoring-Made-Easy-768x402.jpg",768,402,true],"large":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/05\/Remote-VPS-Monitoring-Made-Easy-1024x536.jpg",1024,536,true],"1536x1536":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/05\/Remote-VPS-Monitoring-Made-Easy.jpg",1200,628,false],"2048x2048":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/05\/Remote-VPS-Monitoring-Made-Easy.jpg",1200,628,false]},"uagb_author_info":{"display_name":"Nayana Nair","author_link":"https:\/\/www.veeble.com\/kb\/author\/nayana\/"},"uagb_comment_info":0,"uagb_excerpt":"As a server administrator, constantly checking the status of each server manually can be time-consuming and overwhelming. Monitoring individual commands and server health can [&hellip;]","_links":{"self":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts\/3466","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/comments?post=3466"}],"version-history":[{"count":11,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts\/3466\/revisions"}],"predecessor-version":[{"id":8530,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts\/3466\/revisions\/8530"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/media\/3470"}],"wp:attachment":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/media?parent=3466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/categories?post=3466"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/tags?post=3466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}