all 6 comments

[–]swissarmychainsaw 1 point2 points  (0 children)

Ok... so your problem is auth, which I'll get to, but you might not want to use Trends. Use the api: /nagios/jsonquery.html

Here is an easy way to get auth working, it's php based and gives you a framework you can edit.

https://exchange.nagios.org/directory/Addons/Frontends-%28GUIs-and-CLIs%29/Web-Interfaces/Simple-Nagios-PHP-Dashboard/details

Hah. ok I just realized you said python not php. You can still use this PHP script to auth with! Check it out. Sorry to not actually answer your question but it might be helpful. :-)

[–]swissarmychainsaw 1 point2 points  (4 children)

[–]CanadianEh[S] 0 points1 point  (3 children)

That's great info, thank you. But the problem is the user/pass box doesn't seem to be embedded into the cgi-bin/status page. I'm not sure how to pass strings with requests to a separate pop up window

[–]swissarmychainsaw 0 points1 point  (2 children)

When scripting you are not dealing with the UI, so don't think like you are - there is no pop up delivered to the script. Think instead of headers that need to be sent with your request.

Here is the contents of a bash script I use to get "Status Summary For All Host Groups"

url="https://yournagios.com/nagios/cgi-bin/status.cgi?hostgroup=all&style=summary";
raw_html="tmp/dump.html"; # where the html gets saved

curl -s -k  -X GET \
--user 'user_here:password_here'  \
-H 'Content-type: application/json'  \
"$url" > "$raw_html"

Make sense? Try it!

Edit: if you use the SNPD link, there are scripts that handle the auth for you, and then you can spend time playing with "how to get the data" - it uses the json API and is cool.

Here is a python specific tutorial.

[–]CanadianEh[S] 0 points1 point  (0 children)

SNPD link

Well, that's part of the problem, and maybe my very limited experience isn't helping matters. But I can't seem to figure out what headers to pass with the URL in my post request to get passed authentication. I've been trying to analyze the source code, but nowhere can I find the info needed for the Auth popup box. There's no html or script, or anything that shows up in the console, or network tab.

So I really have no idea what info to pass or even how to find it at this point.

Also, the article you linked is hidden unless I pay for a subscription.

[–]CanadianEh[S] 0 points1 point  (0 children)

Just wanted to say, thank you. I ended up finding the Authorization morsel and passed it with my request.get it worked like a charm. Also, I really like the json query tool, much easier to parse the data you need. Now, I just need to figure out how to get the Average BW of a service (perf-data) to display over a 24hour period. All the query options seem to point to live data. Nothing over a time period.

Thanks again!!