{"id":198,"date":"2021-03-28T17:38:55","date_gmt":"2021-03-29T00:38:55","guid":{"rendered":"https:\/\/my.apolonio.tech\/?p=198"},"modified":"2021-03-29T00:03:19","modified_gmt":"2021-03-29T07:03:19","slug":"configuring-nagios-part-1","status":"publish","type":"post","link":"https:\/\/my.apolonio.tech\/?p=198","title":{"rendered":"Configuring Nagios Part 1"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Setting Up Hosts<\/h2>\n\n\n\n<h1 class=\"wp-block-heading\">Introduction<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">You followed the <a href=\"https:\/\/my.apolonio.tech\/?p=109\">minimal installation of Linux<\/a>, then proceeded to <a href=\"https:\/\/my.apolonio.tech\/?p=194\">install monitoring software<\/a>, now you are ready for the next step.&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">First off, What is nagios?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before I jump on google, lookup Wikipedia or the nagios.org website, I wanted to come up with my own definition.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Nagios is network monitoring and alerting software.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It monitors your network using plugins, the plugins are written using a variety of programming and scripting languages, C, bash scripts, pearl, python, php, you can write plugins in basic, SQL, and assembly, it has to return an exit code and some text.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Based on the exit code, nagios can take action, like send an alert via email, sms, or text message.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That to me is what Nagios is, the magic is in the plugins.&nbsp; To be fair, nagios does a lot more things, there is a search feature, escalations, a map, and agents that can run on the host.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Nagios can be a beast if you try to take it all in at one time.&nbsp; I have been using nagios for close to 2 decades, and I still find interesting things for it to do.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With that said, I must break nagios down from one giant meal in to 5 edible parts:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Part 1 &#8211; Monitoring Hosts<\/li><li>Part 2 &#8211; Monitoring Services<\/li><li>Part 3 &#8211; Plugins<\/li><li>Part 4 &#8211; NRPE<\/li><li>Part 5 &#8211; Notifications, Escalation, and Automated Scripts<\/li><\/ul>\n\n\n\n<h1 class=\"wp-block-heading\">What is host monitoring<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Nagios monitors hosts and services.&nbsp; In this first article we are going to monitor hosts.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When you want to check if a machine on your network is up, you can do it several ways, you can try to connect to it with Remote Desktop if it is a Windows box, or SSH if it is a Linux box.&nbsp; If it is an appliance, we can check if a Web Management Interface is up.&nbsp; The most common way though, is to ping.&nbsp; It is common to open up a command line and type ping 192.168.1.1 to see if something is up.&nbsp; Or ping 8.8.8.8 as a way to see if your internet is up by pinging Google\u2019s DNS server.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Setting Things Up<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">First thing we will do is tweak the environment a bit to make it easier to use.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It is assumed you have installed nagios and have it running (see prior article).&nbsp; But all you see when you log in is localhost when you click on the Hosts section<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"968\" height=\"492\" src=\"https:\/\/my.apolonio.tech\/wp-content\/uploads\/2021\/03\/Part-1-Only-Localhost.jpg\" alt=\"\" class=\"wp-image-199\" srcset=\"https:\/\/my.apolonio.tech\/wp-content\/uploads\/2021\/03\/Part-1-Only-Localhost.jpg 968w, https:\/\/my.apolonio.tech\/wp-content\/uploads\/2021\/03\/Part-1-Only-Localhost-300x152.jpg 300w, https:\/\/my.apolonio.tech\/wp-content\/uploads\/2021\/03\/Part-1-Only-Localhost-768x390.jpg 768w\" sizes=\"auto, (max-width: 968px) 100vw, 968px\" \/><figcaption>Only localhost here<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Log in to the nagios box as root and go to \/etc\/nagios<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Edit the nagios.cfg file<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>vi \/etc\/nagios\/nagios.cfg<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Got to around line 51 and uncomment the following<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>#cfg_dir=\/etc\/nagios\/servers<br>#cfg_dir=\/etc\/nagios\/printers<br>#cfg_dir=\/etc\/nagios\/switches<br>#cfg_dir=\/etc\/nagios\/routers<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Remove the # sign and make it look like this<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>cfg_dir=\/etc\/nagios\/servers<br>cfg_dir=\/etc\/nagios\/printers<br>cfg_dir=\/etc\/nagios\/switches<br>cfg_dir=\/etc\/nagios\/routers<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now create folders with those names<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>mkdir \/etc\/nagios\/servers<br>mkdir \/etc\/nagios\/printers<br>mkdir \/etc\/nagios\/switches<br>mkdir \/etc\/nagios\/routers<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Although you do not have to, it is good practice to give ownership of those folders (and any config files you create) nagios ownership.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>chown nagios:nagios \/etc\/nagios\/servers<br>chown nagios:nagios \/etc\/nagios\/printers<br>chown nagios:nagios \/etc\/nagios\/switches<br>chown nagios:nagios \/etc\/nagios\/routers<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><u>IMPORTANT<br><\/u><\/strong>Every time you make a change or add something to nagios, test the config first using the following command<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>nagios -v \/etc\/nagios\/nagios.cfg<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If there are no errors, you can restart the nagios service<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"661\" height=\"77\" src=\"https:\/\/my.apolonio.tech\/wp-content\/uploads\/2021\/03\/Part-1-No-Errors.jpg\" alt=\"\" class=\"wp-image-200\" srcset=\"https:\/\/my.apolonio.tech\/wp-content\/uploads\/2021\/03\/Part-1-No-Errors.jpg 661w, https:\/\/my.apolonio.tech\/wp-content\/uploads\/2021\/03\/Part-1-No-Errors-300x35.jpg 300w\" sizes=\"auto, (max-width: 661px) 100vw, 661px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><code>systemctl restart nagios<\/code><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Adding the first host<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Go in to \/etc\/nagios\/servers and create a file for your first host with the extension .cfg, the name can be anything, but make it easy on yourself and use the name of the host.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>cd \/etc\/nagios\/servers<br>vi alpha.cfg<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the example above, the server I will be monitoring is alpha, a raspberry pi in my lab that does DNS, Time and DHCP on my network.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Populate the file with the following content, modify your file to match what you have on your network.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>define host{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; host_name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alpha<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 192.168.80.10<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; max_check_attempts&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 10<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; check_period&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 24x7<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; contacts&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; larry,standard<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; contact_groups&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; admins<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; notification_interval&nbsp;&nbsp; 120<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; notification_period&nbsp;&nbsp;&nbsp;&nbsp; 24x7<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is how a host entry with the minimal parameters looks like in nagios.&nbsp; You can put all your hosts into a single file.&nbsp; But for management I recommend creating an individual file for each of your hosts.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Test your new config then restart nagios if there are no warnings<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>nagios -v \/etc\/nagios\/nagios.cfg<br>systemctl restart nagios<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Go back to your browser and hit refresh, you will see two entries.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"986\" height=\"390\" src=\"https:\/\/my.apolonio.tech\/wp-content\/uploads\/2021\/03\/Part-1-First-Nagios-Host.jpg\" alt=\"\" class=\"wp-image-201\" srcset=\"https:\/\/my.apolonio.tech\/wp-content\/uploads\/2021\/03\/Part-1-First-Nagios-Host.jpg 986w, https:\/\/my.apolonio.tech\/wp-content\/uploads\/2021\/03\/Part-1-First-Nagios-Host-300x119.jpg 300w, https:\/\/my.apolonio.tech\/wp-content\/uploads\/2021\/03\/Part-1-First-Nagios-Host-768x304.jpg 768w\" sizes=\"auto, (max-width: 986px) 100vw, 986px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Normally within 5 minutes (the default), a check would have cycled through and the new host will go from pending to up.&nbsp; But there is a missing parameter, check_command, which is not required, but if it is not defined then the default is to not actively check the host.&nbsp; So we will add the <a>check_command <\/a>parameter with the check-host-alive value, so your config file looks like this.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>define host{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; host_name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alpha<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 192.168.80.10<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; max_check_attempts&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 10<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; check_period&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 24x7<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; check_command&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; check-host-alive<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; contacts&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; larry,standard<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; contact_groups&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; admins<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; notification_interval&nbsp;&nbsp; 120<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; notification_period&nbsp;&nbsp;&nbsp;&nbsp; 24x7<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Test your new config then restart nagios if there are no warnings<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>nagios -v \/etc\/nagios\/nagios.cfg<br>systemctl restart nagios<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Wait (max time is 5 minutes) and the status should switch to up.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Before you go nuts with this new information, read a bit more before adding all of your hosts.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">The Host Configuration<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">I am going to look at the configuration file a bit deeper.&nbsp; If you want the official document and all of the various parameters, see<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/assets.nagios.com\/downloads\/nagioscore\/docs\/nagioscore\/3\/en\/objectdefinitions.html#host\">https:\/\/assets.nagios.com\/downloads\/nagioscore\/docs\/nagioscore\/3\/en\/objectdefinitions.html#host<\/a><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>host_name &#8211; is a short simple name used to identify itself throughout the nagios configs.<\/li><li>address &#8211; can be an ip or FQDN<\/li><li>max_check_attempts &#8211; This is how many times the check will had<\/li><li>check_period &#8211; This is the time when checks happen, these timelines are defined in \/etc\/nagios\/objects\/timeperiods.cfg with 24&#215;7 a stock value to continuously check<\/li><li>check_command \u2013 This value is the command used to check if a host is alive or not.&nbsp; Most use a ping and a ping is defined as check-host-alive in \/etc\/nagios\/objects\/commands.cfg, you will see it uses the check_ping command.<\/li><li>contacts &#8211; larry,standard , this is a comma separated list of who should be notified when this host goes up or down.&nbsp; You can specify BOTH OR EITHER contacts or contact_groups, but AT LEAST ONE must be defined.<\/li><li>contact_groups &#8211; this is a group of contacts defined in \/etc\/nagios\/objects\/contacts.cfg, see contacts above<\/li><li>notification_interval \u2013 This is how many minutes to wait before sending a notification (caveat, there is a value in the configs called interval_length with a value of 60, which is how many seconds in a minute, so if you want a minute to 3600, then the notification interval will be multiplied but 3600 to give you the time in seconds between notices, keep it simple leave interval_length a 60)<\/li><li>notification_period \u2013 where check_period is the times a server is checked, notification_period is the time notices are sent.&nbsp; You may have check_period set to 24&#215;7, but only need to be notified during business hours if there is an outage.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">These are the minimum values needed (other than check_command)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Hold on for one more topic before you go ahead and create entries for all your hosts.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">The Host Template<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">You can simply create a master file and copy the file for each host you are monitoring, then change the host_name and address to match the host.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The problem is if you change something, say the contacts or the contact_groups, it is a pain to iterate through each file and change the contacts value.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So setting up a host template (located in \/etc\/nagios\/objects\/templates.cfg) may be easier.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Edit \/etc\/nagios\/objects\/templates.cfg<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>vi \/etc\/nagios\/objects\/templates.cfg<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Look for the generic-host entry and make the following changes<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>define host {<br>&nbsp;&nbsp;&nbsp; name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; generic-host<br>&nbsp;&nbsp;&nbsp; notifications_enabled&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1<br>&nbsp;&nbsp;&nbsp; event_handler_enabled&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1<br>&nbsp;&nbsp;&nbsp; flap_detection_enabled&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1<br>&nbsp;&nbsp;&nbsp; process_perf_data&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1<br>&nbsp;&nbsp;&nbsp; retain_status_information&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1<br>&nbsp;&nbsp;&nbsp; retain_nonstatus_information&nbsp;&nbsp;&nbsp; 1<br>&nbsp;&nbsp;&nbsp; notification_period&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 24x7<br>&nbsp;&nbsp;&nbsp; register&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; JUST A TEMPLATE!<br>&nbsp;&nbsp;&nbsp; max_check_attempts&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;10<br>&nbsp;&nbsp;&nbsp; check_period&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;24x7<br>&nbsp;&nbsp;&nbsp; check_command&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;check-host-alive<br>&nbsp;&nbsp;&nbsp; contacts&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;larry,standard<br>&nbsp;&nbsp;&nbsp; contact_groups&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;admins<br>&nbsp;&nbsp;&nbsp; notification_interval&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;120<br>}<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Modify your host to use the template, you can override the template values if you need to.&nbsp; But now you have a nice short sweet host entry.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>define host{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; use&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; generic-host<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; host_name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alpha<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; alias&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Main DHCP DNS Server<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 192.168.80.10<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Note how I added an alias<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Test your new config then restart nagios if there are no warnings<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>nagios -v \/etc\/nagios\/nagios.cfg<br>systemctl restart nagios<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then go back to the browser<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In 5 minutes you should see a new host that is OK<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"679\" height=\"393\" src=\"https:\/\/my.apolonio.tech\/wp-content\/uploads\/2021\/03\/Part-1-First-Nagios-Green-Host.jpg\" alt=\"\" class=\"wp-image-202\" srcset=\"https:\/\/my.apolonio.tech\/wp-content\/uploads\/2021\/03\/Part-1-First-Nagios-Green-Host.jpg 679w, https:\/\/my.apolonio.tech\/wp-content\/uploads\/2021\/03\/Part-1-First-Nagios-Green-Host-300x174.jpg 300w\" sizes=\"auto, (max-width: 679px) 100vw, 679px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">And if you click the new host, you will see some interesting information at the top.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"330\" height=\"166\" src=\"https:\/\/my.apolonio.tech\/wp-content\/uploads\/2021\/03\/Part-1-Alpha-Info.jpg\" alt=\"\" class=\"wp-image-203\" srcset=\"https:\/\/my.apolonio.tech\/wp-content\/uploads\/2021\/03\/Part-1-Alpha-Info.jpg 330w, https:\/\/my.apolonio.tech\/wp-content\/uploads\/2021\/03\/Part-1-Alpha-Info-300x151.jpg 300w\" sizes=\"auto, (max-width: 330px) 100vw, 330px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Go nuts add entries for all your hosts, make it easy on yourself and simply copy and modify the existing file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When you are done, test your new config then restart nagios if there are no warnings<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>nagios -v \/etc\/nagios\/nagios.cfg<br>systemctl restart nagios<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"495\" height=\"850\" src=\"https:\/\/my.apolonio.tech\/wp-content\/uploads\/2021\/03\/Part-1-Multiple-Hosts.jpg\" alt=\"\" class=\"wp-image-204\" srcset=\"https:\/\/my.apolonio.tech\/wp-content\/uploads\/2021\/03\/Part-1-Multiple-Hosts.jpg 495w, https:\/\/my.apolonio.tech\/wp-content\/uploads\/2021\/03\/Part-1-Multiple-Hosts-175x300.jpg 175w\" sizes=\"auto, (max-width: 495px) 100vw, 495px\" \/><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\">Host Groups<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Congratulations you now have a bunch of servers being monitors.&nbsp; One thing you might want to do is organize them by duty.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Similar to how we created a folder for servers we are going to create one for hostgroups<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>mkdir \/etc\/nagios\/hostgroups<br>chown nagios:nagios \/etc\/nagios\/hostgroups<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then modify \/etc\/nagios\/nagios.cfg<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>vi \/etc\/nagios\/nagios.cfg<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And add<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>cfg_dir=\/etc\/nagios\/hostgroups<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Test your new config then restart nagios if there are no warnings<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>nagios -v \/etc\/nagios\/nagios.cfg<br>systemctl restart nagios<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now you can create hostgroups cfg files for the different servers, the format is<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>define hostgroup {<br>&nbsp;&nbsp;&nbsp; hostgroup_name&nbsp;&nbsp;&nbsp;&nbsp; linux-servers&nbsp; ; The name of the hostgroup<br>&nbsp;&nbsp;&nbsp; alias&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Linux Servers&nbsp; ; Long name of the group<br>&nbsp;&nbsp;&nbsp; members&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; localhost&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; Comma separated list of hosts<br>}<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here is an example of my hostgroup entries<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">define hostgroup {\n     hostgroup_name     domain-controllers\n     alias              Domain Controllers\n     members            DC,BC\n }\n define hostgroup {\n     hostgroup_name     dns-servers\n     alias              DNS Controllers\n     members            DC,BC,alpha,beta,pihole\n }\n define hostgroup {\n     hostgroup_name     network\n     alias              Network Gear\n     members            gateway,wap\n }\n define hostgroup {\n     hostgroup_name     file-servers\n     alias              File Servers\n     members            beta,gamma,delta\n }\n define hostgroup {\n     hostgroup_name     desktops\n     alias              Windows Desktops\n     members            origin, win7a, win7b\n }\n define hostgroup {\n     hostgroup_name     terminal-servers\n     alias              Terminal Servers\n     members            sushi,terminal\n }<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here is one of the hostgroup views<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1003\" height=\"517\" src=\"https:\/\/my.apolonio.tech\/wp-content\/uploads\/2021\/03\/Part-1-hostgroups.jpg\" alt=\"\" class=\"wp-image-205\" srcset=\"https:\/\/my.apolonio.tech\/wp-content\/uploads\/2021\/03\/Part-1-hostgroups.jpg 1003w, https:\/\/my.apolonio.tech\/wp-content\/uploads\/2021\/03\/Part-1-hostgroups-300x155.jpg 300w, https:\/\/my.apolonio.tech\/wp-content\/uploads\/2021\/03\/Part-1-hostgroups-768x396.jpg 768w\" sizes=\"auto, (max-width: 1003px) 100vw, 1003px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">This concludes part 1 of the Configuring Nagios series.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Setting Up Hosts Introduction You followed the minimal installation of Linux, then proceeded to install monitoring software, now you are ready for the next step.&nbsp; First off, What is nagios? Before I jump on&#46;&#46;&#46;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[6],"tags":[],"class_list":["post-198","post","type-post","status-publish","format-standard","hentry","category-linux-server"],"_links":{"self":[{"href":"https:\/\/my.apolonio.tech\/index.php?rest_route=\/wp\/v2\/posts\/198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/my.apolonio.tech\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/my.apolonio.tech\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/my.apolonio.tech\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/my.apolonio.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=198"}],"version-history":[{"count":2,"href":"https:\/\/my.apolonio.tech\/index.php?rest_route=\/wp\/v2\/posts\/198\/revisions"}],"predecessor-version":[{"id":207,"href":"https:\/\/my.apolonio.tech\/index.php?rest_route=\/wp\/v2\/posts\/198\/revisions\/207"}],"wp:attachment":[{"href":"https:\/\/my.apolonio.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/my.apolonio.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/my.apolonio.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}