hudson-trading / netbox-nagios

Plugin to show Nagios host and service status in NetBox on the device page.
Other
44 stars 10 forks source link

Allow Basic Auth #4

Closed bernardinosousa closed 2 years ago

bernardinosousa commented 4 years ago

Hi, My nagios server it´s protected with auth, could you add on config: nagios_user and nagios_password ? I already tried changing the plugin but i don´t have knowledge with python language.

Here´s the source i tried: https://stackoverflow.com/questions/2929532/http-basic-authentication-using-sockets-in-python

fabi125 commented 4 years ago

Hi Bernardino18!

Is Basic Auth needed for getting the data from the Nagios livestatus endpoint? If so, do you have an example on how to use it?

Thanks, Fabi

bernardinosousa commented 4 years ago

Thanks for quick response! Yes, i tried with postman and worked with basic auth.

Generated code for Python - Requests

import requests

url = "https://example.com/monitoring/nagios/cgi-bin/status.cgi?host=192.168.1.1"

payload = {}
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'Authorization': 'Basic GENERATED_BASE64'
}

response = requests.request("GET", url, headers=headers, data = payload)

print(response.text.encode('utf8'))

image

fabi125 commented 4 years ago

Ah, looks like you need the MK Livestatus plugin for Nagios: https://exchange.nagios.org/directory/Documentation/MK-Livestatus/details

Which is the endpoint this plugin talks to (and which I don't think supports auth). I'll update the README file to make this clearer.

bernardinosousa commented 4 years ago

Already found the problem. The software installed on my company it´s check_mk and it´s based on nagios. Since it´s not the same software, it´s normal to don´t work.

fabi125 commented 4 years ago

I'm not very familiar with check_mk, but I found these instructions that might help you make livestatus available over the network: https://checkmk.com/cms_livestatus.html#network

bernardinosousa commented 4 years ago

Already done that. I tried testing connection with the livestatus_host with telnet and worked. But plugin still don´t show data. image

fabi125 commented 4 years ago

I'm not sure what the best way for me to help you here is. Is the hostname in Netbox the same as in Nagios?

This is what the plugin sends over to the livestatus_host:

GET hosts
Filter: host_name = <hostname>
OutputFormat: json

Other things you can try is to write a little script that imports livestatus.py to see if that works or run tcpdump on one of the two ends to see what the actual network traffic between the two is.

nikor30 commented 3 years ago

I will let the the plugin also to be installed. And will test it as we are also using check_mk. I let you know when I get the results.. :-)

fabi125 commented 2 years ago

Closing stale issue. Please re-open if needed.