Page 2 of 2

Re: extract availability data

Posted: Wed Sep 28, 2016 11:53 am
by smoren
Hi and sorry for delay. While playing around with these commands, I've encountered two issues:
- where can I find file you mentioned - 'htmltocsv.py' ?
- is it somehow possible to consider warnings and scheduled downtimes as OK states? (just like [ ] Hide scheduled downtime option in availability reports)

..and bonus question :-) Do you have any updates on request ID 9208?

Thanks for help.

Re: extract availability data

Posted: Wed Sep 28, 2016 4:57 pm
by ssax

Code: Select all

yum install python-beautifulsoup4
Sorry, this is the code for the htmltocsv.py file:

Code: Select all

#!/usr/bin/python
from bs4 import BeautifulSoup
import sys
import re
import csv

def cell_text(cell):
    return " ".join(cell.stripped_strings)

soup = BeautifulSoup(sys.stdin.read())
output = csv.writer(sys.stdout)

for table in soup.find_all('table'):
    for row in table.find_all('tr'):
        col = map(cell_text, row.find_all(re.compile('t[dh]')))
        output.writerow(col)
    output.writerow([])

Re: extract availability data

Posted: Wed Sep 28, 2016 5:06 pm
by ssax
No, unfortunately those options are only available in the XI interface.

There has been no activity noted on the feature request at this time.

Re: extract availability data

Posted: Thu Sep 29, 2016 8:02 am
by smoren
Thanks. In the meantime I looked again on JSON Query Generator. It seems I'll be able to distinguish scheduled and unscheduled downtimes with it. However, I think I found a bug.
First, I created availability report for one specific service from Nagios Core. See core_avail_result.png file. Data in this table seems to be correct.
Then I tried to use JSON Query generator to get these data. Here's what I got:

Code: Select all

"time_ok": 2527907,
"time_warning": 0,
"time_critical": 132493,
"time_unknown": 0,
"scheduled_time_ok": 0,
"scheduled_time_warning": 0,
"scheduled_time_critical": 411,
"scheduled_time_unknown": 0,
"time_indeterminate_nodata": 0,
"time_indeterminate_notrunning": 0
If you check the ...result.png file, you can see we have 4 non-zero values: scheduled OK, unscheduled OK, scheduled Critical, unscheduled Critical. And if you check result from JSON - we have only 3 non zero values. I did some calculations and data from JSON are exactly the same as data in ...result.png table, except one - scheduled_time_ok (=Scheduled OK). If I'm right, scheduled_time_ok should contain value 17589.

I used this time interval:
JSON report start time: 1470002400
JSON report end time: 1472680800
---> report duration: 2678400

If you sum all values from json, and add missing 17589, you'll get report duration. (2527907+132493+411+17589 = 2678400).
Could you confirm this and check if there are no more miscalculations...
Thanks.

just fyi: this service is configured for scheduled downtime for one hour every week.

Re: extract availability data

Posted: Thu Sep 29, 2016 4:02 pm
by ssax
I'm having trouble replicating this on mine, what is the output of this command:

Code: Select all

/usr/local/nagios/bin/nagios -V
Thank you

Re: extract availability data

Posted: Fri Sep 30, 2016 7:18 am
by smoren
Here's the output:

Code: Select all

Nagios Core 4.1.1
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-19-2015
License: GPL

Website: https://www.nagios.org
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
I'm using Nagios XI 5.2.8. By the way, any hints when 5.3.0 will be released? :-)

Did you tried to replicate this on service that was scheduled for downtime in the past(within reporting period)?

Re: extract availability data

Posted: Fri Sep 30, 2016 1:55 pm
by avandemore
Hi Smoren,

I'm having trouble exactly reproducing your results. Can you provide more details regarding OS/ARCH and specific testing methodology? 5.3.0 is due to be released in the near future and if this is indeed a bug it would be great to get it fixed before then.

Re: extract availability data

Posted: Mon Oct 03, 2016 7:24 am
by smoren
Hi,

here's data: OS: Red Hat Enterprise Linux Server release 6.8 (Santiago) (x86_64)

Try following:

1. choose any service in OK and schedule it for a downtime in near future (I used scheduled downtime feature under Incident management)
2. make two tests: in one case leave service in OK state during scheduled downtime window; in 2nd case, change state of that service to critical for a while.

To get reference (correct) data: create legacy availability report for that service. You should see, that row 'OK-Scheduled' contains non-zero data. If your downtime period was 1 hour, and service was always in OK state, it should contain '1 hour'. In 2nd test (critical state of service during downtime), you should get non-zero data for 'Critical-scheduled'.

Now do the same, but with nagios JSON Query generator (http://NAGIOSSERVER/nagios/jsonquery.html). Enter same settings as in availability report (service, states (e.g. only HARD), report start and end time,..). And you should get some data in the JSON format. Check line 'scheduled_time_ok'. It should contain non-zero value(=number of seconds during scheduled downtime when service was in OK state). But in my case(bug?), this value is zero.
Or in other words, are you able to get a non-zero value for 'scheduled_time_ok'? If so, how?

Thanks.

Re: extract availability data

Posted: Mon Oct 03, 2016 10:09 am
by avandemore
I have created a ticket here https://github.com/NagiosEnterprises/na ... issues/270. Since this is now in the hands of development, these is not much we can do further here. You are free to follow and/or participate in the github ticket. Do you mind if I close this thread?

Re: extract availability data

Posted: Tue Oct 04, 2016 10:49 am
by tmcdonald
I'm going to be closing this since there is an open issue on GitHub. Please PM myself or another member of the team if you would like this thread unlocked.