Report for current status of hosts?

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
peter.zanetti
Posts: 90
Joined: Wed Oct 01, 2014 8:34 am

Report for current status of hosts?

Post by peter.zanetti »

When looking at the hosts you can see how many devices are offline and see the list of them. However there is no way to export that list. Is there a way to create an exportable report that shows just the current state of the hosts instead of the % of up and down time?
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: Report for current status of hosts?

Post by jolson »

Have you looked into the 'Schedule Page' button?
file.png
Using this page, you can schedule a PDF report to be sent out of any page in XI - you are able to choose the delivery interval as well (Daily, Weekly, etc).

Does that work for you?
You do not have the required permissions to view the files attached to this post.
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
peter.zanetti
Posts: 90
Joined: Wed Oct 01, 2014 8:34 am

Re: Report for current status of hosts?

Post by peter.zanetti »

That did work to give me the current status, however is there a way to get that as a csv or excel file? I need to be able to grab the data and use it in some custom reporting through excel.
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: Report for current status of hosts?

Post by jolson »

I don't think that getting a .csv of all current host state information is possible.

The closest I know of is the 'state history' report - is this something that could work for you, or does it need to be live?
2015-04-24 10_37_17-Nagios XI - Reports.png
You do not have the required permissions to view the files attached to this post.
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
peter.zanetti
Posts: 90
Joined: Wed Oct 01, 2014 8:34 am

Re: Report for current status of hosts?

Post by peter.zanetti »

It would need to be the live host states. I'm thinking maybe a database call?
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Report for current status of hosts?

Post by jdalrymple »

Here is some junky python that will do what you want.

Use the argument "h" for hosts and "s" for services.

It can't really do both at the same time since services have hosts (an additional column) but not the reverse.

Code: Select all

#!/usr/bin/python
import sys
import re

# lines to not chuck
#  servicestatus {
#  hoststatus {
#  service_description=
#  host_name=
#       current_state=#
#       }


m1 = re.compile('servicestatus {')
m2 = re.compile('hoststatus {')
m3 = re.compile('\\tcurrent_state=[0-3]')
m4 = re.compile('\\thost_name=')
m5 = re.compile('\\tservice_description=')
with open('/usr/local/nagios/var/status.dat') as f:
        statusdat = f.read().splitlines()
f.close()

# 1 if we're working on a service 2 if we're working on a host, 0 if we're not working on anything
w = 0
services = []
s = 0
hosts = []
h = 0


for line in statusdat:

        if(m1.match(line)):
                services.append([])
                w = 1
        if(m2.match(line)):
                hosts.append([])
                w = 2
        if(m3.match(line)):
                if w == 1:
                        services[s].append(re.sub('^.*=', '', line))
                        w = 0
                        s += 1
                if w == 2:
                        hosts[h].append(re.sub('^.*=', '', line))
                        w = 0
                        h += 1
        if(m4.match(line)):
                if w == 1:
                        services[s].append(re.sub('^.*=', '', line))
                if w == 2:
                        hosts[h].append(re.sub('^.*=', '', line))

        if(m5.match(line)):
                services[s].append(re.sub('^.*=', '', line))


#for host in hosts:
#       print host
#for service in services:
#       print service

if sys.argv[1] == "h":
        for host in hosts:
                if host[1] == "0":
                        host[1] = "OK"
                if host[1] == "1":
                        host[1] = "WARNING"
                if host[1] == "2":
                        host[1] = "CRITICAL"
                if host[1] == "3":
                        host[1] = "UNKNOWN"
                print host[0] + "," + host[1]

if sys.argv[1] == "s":
        for service in services:
                if service[2] == "0":
                        service[2] = "OK"
                if service[2] == "1":
                        service[2] = "WARNING"
                if service[2] == "2":
                        service[2] = "CRITICAL"
                if service[2] == "3":
                        service[2] = "UNKNOWN"
                print service[0] + "," + service[1] + "," + service[2]
Locked