Nagios XI--Monitoring Configuration Using Auto-Discovery In Nagios XI
This document describes how to use Auto-Discovery in Nagios XI to locate hosts and devices that are not already being monitored by Nagios XI.
Overview
The Auto-Discovery feature in Nagios XI comprises of two components:
This performs the discovery of hosts and devices in your network environment
A network scan is performed using ping and nmap
Using the results of an Auto-Discovery job you can start monitoring these hosts and devices
Auto-Discovery Jobs
The management of Auto-Discovery jobs is located by navigating to Configure > Configuration Tools > Auto-Discovery.
Create A New Job
To create a new job click the + New Auto-Discovery Job button.
The options required when creating a job are self explanatory. The screenshot to the right shows the additional options available after clicking the Show Advanced Options + link.
This example shows a class C subnet being scanned with an excluded IP. It has been scheduled to run daily and the System DNS option has been selected to resolve the addresses to DNS records.
Click the Submit button to create the job.
The new job will appear on the Auto-Discovery page when it reloads.
When a job is running, or scheduled and hasn't run yet, the Status column will show a icon. In the Actions column you can click the icon to delete the job.
When the job has finished running it will show how many new devices were found.
In the screenshot above, if you click the 12 New link you will be taken to the Auto-Discovery configuration wizard which is explained in the Configuration Wizard section of this document.
Job Actions
On the Auto-Discovery Jobs page, the Action column provides the following functionality:
Edit Job - Adjust the settings for the job
Re-Run Job - Force the job to run now
View Job - View detailed information about the scan results and deploy agent Delete Job - Discard the job and it's history
View Job
The View Job icon allows you to view detailed information about the network scan that was performed and deploy an agent to selected hosts.
You can view all the hosts, or just the new hosts discovered.
You can show the services that were discovered.
This job can be exported as a CSV.
Configuration Wizard
The Auto-Discovery configuration wizard is what turns the Auto-Discovery job results into monitored devices. When on the Auto-Discovery page, click the New link in the Devices Found column to start the Wizard. You can also run the wizard by navigating to Configure > Configuration Wizards > Auto-Discovery wizard.
The job will be automatically selected. The available options are clearly explained in the screenshot above, this example will be showing New Hosts and the Host Addresses option is set to DNS Names.
Click Next to proceed to Step 2.
Step 2 of the wizard allows you to select exactly what host and service objects will be created. The following screenshot is of the first host in the list.
You can change the name of the host and also the services. The services created are basic port monitoring services, more specific monitoring like Load and Disk Space will require you to run a configuration wizard that provides that functionality.
You can select or deselect a host by using the check box next to the host address in the left column.
Deselecting a host means that none of the services selected to the right will be monitored.
The check box in the upper left corner will select ALL hosts in the wizard. The same applies to the Services check box.
After making your selections click Next and then complete the wizard by choosing the required options in Step 3 - Step 5.
To finish up, click on Finish in the final step of the wizard. This will create the new hosts and services and begin monitoring.
Newly Discovered Hosts
In the future, re-running the Auto-Discovery job (manually or scheduled) will detect new hosts that are not already being monitored by Nagios XI. Here is that job again after two hosts were brought online:
You can see now there are 15 in total with 2 New devices being detected. Clicking the 2 New will allow you to start monitoring these new devices.
Monitoring Websites With Nagios XI
This document describes how to monitor websites effectively with Nagios XI. There are three different wizards to help you monitor the health of websites and to be notified when unexpected changes occur on the website or processes are not working as expected.
Considerations
When monitoring websites, it is often recommended to check the operational status of several key metrics, including:
Your monitoring needs will vary depending on the complexity of your website, its purpose, and its intended end-user.
Running A Wizard
To begin using one of the wizards, navigate via the top menu bar to Configure > Run a configuration wizard and select the required wizard from the list. In the following screenshot you can see how the search field allows you to quickly find a wizard.
The Website Wizard
This is the wizard you will use for most types of sites, where you are checking common server/site metrics.
The best way to understand its capabilities is to see them, so a walk through of using this wizard follows.
Select the Website wizard from the list of wizards.
On Step 1 enter the URL to your website. This can be either the front page of your the domain or any sub-page. The latter will only have a purpose of checking of existence of that page and content monitoring on it.
Click Next once you've entered a URL.
Step 2 is where you define the monitoring options. Here you can define which services you want to add for this site, including whether:
To use SSL (HTTPS) and what port to use
What to do if a redirect response is received, in this example follow was chosen
Credentials if required
Test is responds with a valid HTTP response
The option of a ping check
DNS resolution check
The DNS response matches the IP address that was resolved when you ran the wizard
A particular string is found on the page (either literally or as a regular expression)
The SSL certificate's expiry date is sufficiently far away
The Use SSL option and SSL Certificate check will only be available if the URL you gave in Step 2 began with https.
Once you've finished making your selections click Next and then complete the wizard by choosing the required options in Step 3 – Step 5.
To finish up, click on Finish in the final step of the wizard. This will create the new hosts and services and begin monitoring. Once the wizard applies the configuration, click the View status details for your website link to see the new host and services that were created.
The Website URL Wizard
The Website URL wizard is very similar to the Website wizard. Select the Website URL wizard from the list of wizards.
On Step 1 enter the URL to your website.
Click Next once you've entered a URL.
Step 2 is where you define the monitoring options. Here you can define which services you want to add for this site:
Service Name Prefix
To use SSL (HTTPS) and what port to use
Credentials if required
A URL Status service
A particular string is found in the content of the page
A particular string is found in the content of the page using a regular expression
Once you've finished making your selections click Next and then complete the wizard by choosing the required options in Step 3 – Step 5.
To finish up, click on Finish in the final step of the wizard. This will create the new hosts and services and begin monitoring. Once the wizard applies the configuration, click the View status details for your website link to see the new host and services that were created.
The Web Transaction wizard
A more complex use case of website monitoring would be if you expect the content to be dynamic with user input and actions, and want to test that those actions complete as expected. For instance, you might test that a search box works (and what results are returned), whether the purchase and checkout process of your web store is behaving properly, or that a user can log in successfully. The Web Transaction wizard can be used for these types of checks. Additionally, it allows for checking all three of those in succession, and other multi-step procedures where each stage may be dependent on the previous one.
This wizard relies on a tool called WebInject, which handles the transition logic between stages of the transaction. Therefore you will need to understand how to write the configuration XML in the WebInject syntax to configure these kinds of checks.
Note that certain special characters need to be escaped. For instance, the < should be replaced with \x3C so as not to interfere with the XML. Within POST data URL escapes are used, so for instance @ becomes %40.
Providing an example of such a process can get pretty complicated somewhat quickly. Here is a simple example where we will search the Nagios Exchange for "box293". I know that the search results will come back with the word "box293" in the result so I am going to look for this. If for some reason "box293" was not present on the web page the service will go into a critical state.
Select the Website Transaction wizard from the list of wizards.
On Step 1 enter the Transaction Name you want to assign to this WebInject test. You will also need to provide the Primary URL for this website. Click Next.
On Step 2 you will need to make sure the Host Name and IP Address fields are correctly populated.
You will then need to provide the Test Case Data that will be used for this transaction. The text field will be already be populated with the first case of id 1.
In the screenshot to the right you can see an additional case of id 2 has been added. The full text is included on the following page.
The magic being performed here is: url = This is the URL that is being used for this test case.
postbody = These are the fields / commands that are posted to the url. This varies depending on your actual
website. In this example it is searching for the word box293.
verifypositive = This is what needs to exist in the data returned, in this example the word box293 must exist for this case to be completed successfully.
You can also specify the timeout periods that apply.
Once you've finished making your selections click Next and then complete the wizard by choosing the required options in Step 3 – Step 5. To finish up, click on Finish in the final step of the wizard. This will create the new hosts and services and begin monitoring.
Once the wizard applies the configuration, click the View status details for the Nagios Exchange link to see the new host and services that were created.
Here is the test case data shown on the screenshot on step 2 of the wizard.
<testcases repeat="1">
<case
id="1"
url="https://exchange.nagios.org/"
/>
<case
id="2"
method="post"
url="https://exchange.nagios.org/index.php"
postbody="option=com_mtree&task=search&searchword=box293"
verifypositive="box293"
/>
</testcases>
Troubleshooting WebInject Transactions
If for some reason the transaction did not work correctly, you will need to go and adjust the test case data in the configuration file that was created by the wizard. You may also want to run the transaction at the command line to see exactly what is happening. All transaction configuration files are located in the following directory on the Nagios XI server:
/usr/local/nagiosxi/etc/components/webinject/
In the wizard that was just run, two files were created:
exchange_nagios_org__Nagios_Exchange_Search___box293_config.xml exchange_nagios_org__Nagios_Exchange_Search___box293_testdata.xml
The file that ends in _testdata.xml is what contains the test case data, it's exactly as you pasted it into the configuration wizard. The file that ends in _config.xml is what tells WebInject how to run the test data.
To demonstrate that the test case data is actually working, I will change the postbody = line to search for the word "box294", which should return a critical result as there is nothing on the Nagios Exchange contaminating the word "box294".
Once I've made the change I'll run the test from the command line using the following commands:
cd /usr/local/nagiosxi/etc/components/webinject/ ./webinject.pl -c exchange_nagios_org__Nagios_Exchange_Search___box293_config.xml
You should receive the following output:
WebInject CRITICAL - Test case number 2 failed |time=10.126;30;;0
If you wanted more verbose output, you need to edit the _config.xml file and change the reporttype to
standard:
<reporttype>standard</reporttype>
Now when you run the command above the output will be something like:
Starting WebInject Engine...
-------------------------------------------------------
Test: exchange_nagios_org__Nagios_Exchange_Search___box293_testdata.xml - 1 Passed HTTP Response Code Verification (not in error range) TEST CASE PASSED
Response Time = 3.482 sec
-------------------------------------------------------
Test: exchange_nagios_org__Nagios_Exchange_Search___box293_testdata.xml - 2
Verify : "box293"
Failed Positive Verification
Passed HTTP Response Code Verification (not in error range)
TEST CASE FAILED
Response Time = 3.337 sec
-------------------------------------------------------
Start Time: Thu Dec 8 17:09:14 2016
Total Run Time: 6.862 seconds
Test Cases Run: 2
Test Cases Passed: 1
Test Cases Failed: 1
Verifications Passed: 2
Verifications Failed: 1
When you've finished troubleshooting don't forget to change the reporttype back to nagios:
<reporttype>nagios</reporttype>
Example: Using An Online Store
This example provides an more comprehensive demonstration of how WebInject could use on online store and put an item in a shopping cart via the O'Reilly Media's web site. It's worth noting that this example was created some time in the past and may not actually work now due to the fact that the website may have been updated by now, however the concept is still the same and worth retaining in the documentation.
By carefully crafting the different steps and plenty of sufficiently specific verifypositive and verifynegative parameters, a great deal of information can be confirmed through this single Nagios service.
1rc94d+86yw3m9jrqj18@sharklasers.com holden123
id="1"
description1="Login page"
url="https://members.oreilly.com/account/login"
parseresponse='_authentication_token" type="hidden" value="|"|escape' verifypositive="Sign in"
/>
id="2"
description1="Sign in"
url="https://members.oreilly.com/account/login"
method="post"
postbody="email=${USER}&password=${PASS}&_authentication_token={PARSEDRESULT}"
verifypositive="https://members.oreilly.com/account/benefits"
parseresponse="found at |;"
/>
id="3"
description1="Members page"
url="{PARSEDRESULT}"
verifypositive="view or edit your account information"
/>
id="4"
description1="Book price"
url="http://oreilly.com/catalog/9781593271794/"
verifypositive="59.95"
/>
id="5"
description1="Book added to cart"
url="https://epoch.oreilly.com/shop/cart.orm?prod=9781593271794.BOOK"
verifypositive="Nagios, 2Ed"
/>
id="6"
description1="Book still in cart"
url="https://epoch.oreilly.com/shop/cart.orm"
verifypositive="Nagios, 2Ed"
verifynegative="Backorder"
/>
id="7"
description1="Logout"
url="https://members.oreilly.com/account/logout"
verifypositive="http://oreilly.com/"
parseresponse="found at |;"
/>
id="8"
description1="Main page"
url="{PARSEDRESULT}"
verifypositive="News & Commentary"
/>
© Copyright 2000-2023 COGITO SOFTWARE CO.,LTD. All rights reserved