Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In Nagios 2 and 3, I'm looking for a way to export a list of all monitored hosts to either CSV or XML or something similar.

share|improve this question
up vote 0 down vote accepted

How about this...

root@box:/etc/nagios3# cat conf.d/hosts/*.cfg | grep "host_name\|address\|alias" |grep -v localhost | perl -ne '$line = $_; 
if ($line =~ /host_name(.*)/) {
$match = $1 ;
$match =~ s/ |\t//g; 
print "\n".$match."\t";
if ($line =~ /address(.*)/) {
$match = $1 ;
$match =~ s/ |\t//g; 
print $match."\t";
if ($line =~ /alias(.*)/) {
$match = $1 ;
$match =~ s/^\s+//; 
$match =~ s/\t//g; 
print $match."\t";

It ll spit out a tab separated list with hostname, ip address and alias for each host in your nagios config.

share|improve this answer
This worked for me, but for some reason the hosts were in another subfolder. – Lars May 27 '13 at 13:11

If you're not configuring your hosts in conf.d/hosts you may try this:

grep host_name /var/log/nagios/objects.cache | cut -f3 | sort -u | paste -d, -s
share|improve this answer

Take a look at MK Livestatus:

echo -e 'GET hosts\nColumns: address' | unixcat /var/nagios/rw/live
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.