#!/usr/bin/perl

use Nagios::StatusLog;

my $log = Nagios::StatusLog->new(
Filename => "/var/cache/nagios2/status.dat",
Version => 2.0 
);
print("Content-type: text/xml\n\n");
print("<?xml version='1.0'?>");
print("<status>\n");
foreach my $host ($log->list_hosts()) {
        print("<host>\n<name>$host</name>\n<services>");

        foreach my $serv ($log->list_services_on_host($host)) {
                print ("<service>\n");
                print (ref $serv);
                my $st  = $log->service($host, $serv); 
                foreach $tag ($st->list_tags()) {
                        print("<$tag>$$st{$tag}</$tag>\n");
                }
                print ("</service>\n");
        }
        print("</services>\n</host>\n")
}
print("</status>");

