Hello.
I'm running Nagios XI 2014R1.5 on a pre-built VM (CentOS release 6.3, x64). I don't have any proxy server or other weird configuration.
I'm trying to import a list of several hundred URLs that I'd like to monitor by DNS Resolution, Ping, HTTP Response, and Web Page Content. I've compiled all information into a spreadsheet. What is the best way to go about importing that into nagios?
I've tried the "Bulk Host Cloning and Import" Wizard, but it will only allow customization of a couple of variables for the host itself, it will not allow customization of any variables for the services attached to the website (host), and specifically allows no customization of the text string to look for in the page for the Web Page Content check.
I really don't want to enter these all by hand. Is there a better way to do this?
Thanks!
Bulk Import of hosts for URL monitoring
-
jdalrymple
- Skynet Drone
- Posts: 2620
- Joined: Wed Feb 11, 2015 1:56 pm
Re: Bulk Import of hosts for URL monitoring
There is no better "supported" way to do it. If the data can be somewhat normalized though it can be fed into the database in an autonomous fashion.
Probably the best way to go about it would be to create as much using bulk clone wizard as you can, then just script replacing the necessary bits. Creating whole hosts/services by hands is very error prone. You could create a single host with a single service that is monitoring "http://www.replaceme.com/" and then script the replacement using database access tools.
Does this make sense?
Again - I have to caution you that this isn't officially supported and furthermore you should always make sure you have good backups.
Probably the best way to go about it would be to create as much using bulk clone wizard as you can, then just script replacing the necessary bits. Creating whole hosts/services by hands is very error prone. You could create a single host with a single service that is monitoring "http://www.replaceme.com/" and then script the replacement using database access tools.
Does this make sense?
Again - I have to caution you that this isn't officially supported and furthermore you should always make sure you have good backups.
Re: Bulk Import of hosts for URL monitoring
Rats. I was hoping that wasn't the case. If there's a feature request list for that bulk import thing, I'd think that would be something that many folks would like. I guess I have a whole lot of typing and clicking in my future...
-
jdalrymple
- Skynet Drone
- Posts: 2620
- Joined: Wed Feb 11, 2015 1:56 pm
Re: Bulk Import of hosts for URL monitoring
What I described is not wildly complicated, as a matter of fact it's not complicated at all, it will likely just be a bash 1-liner with an associated CSV file. Here is a sample 1-liner I wrote for a gentleman to feed a Tab Separated Value file into the notes field of his instances:
while read line; do echo "UPDATE tbl_host SET notes='`echo $line | awk '{print $2}'`' WHERE host_name='`echo $line | awk '{print $1}'`';" | mysql -u root -pnagiosxi nagiosql; done < hosts.tsv
The file looked like this:
This is very doable - with proper forethought. Do you have enterprise features? The bulk clone tool would help you quite a lot.
while read line; do echo "UPDATE tbl_host SET notes='`echo $line | awk '{print $2}'`' WHERE host_name='`echo $line | awk '{print $1}'`';" | mysql -u root -pnagiosxi nagiosql; done < hosts.tsv
The file looked like this:
Code: Select all
localhost 123,456
noisy1 123,789
noisy2 456,789
noisy3 456,123
quiet1 789,123
quiet2 789,456
win7 321,987
linux-server-2 654,321
linux-server-3 987,654
linux-server-4 987,321Re: Bulk Import of hosts for URL monitoring
Thanks for the idea. No, I do not have enterprise. I did figure out a way to do it, however. CCM has a utility to import cfg files, and you can include multiple hosts and services in the cfg files. So, I took the spreadsheet I was given, pulled out the URL, person to be notified, and the string to search the webpage for, and manually created a .cfg file for the list of hosts and services under those hosts. The .cfg files are human-readable, and I tossed together a quick vbscript to do the creation. At that point, I uploaded the files to the proper places on the nagios server, imported the files through CCM and all the hosts and services I want to monitor now appear in XI. I can update this process by updating the spreadsheet, then deleting all the services I imported through CCM (there's an option to filter by config file). Then, I have to manually check and delete all the hosts through CCM (I only have 102 so far, so that's not totally out of the question.) I know I'm not doing this "right", because I cannot edit these services through XI, only through CCM, and I cannot, "apply" my configurations. nagios writes the host configs out each to a separate file, then chokes on writing the services out. I think that means that the configs are live in the database, but I can't write the database back out to the .cfg files on the disk. Oh well - it works and it is manageable.
Re: Bulk Import of hosts for URL monitoring
Can you post the error when you try to Apply the Configuration?
Be sure to check out our Knowledgebase for helpful articles and solutions!