Hello I am trying to loggin in nagios since a script made in python with this code:
import sys
import requests
URL = 'http://XXX.XXX.XXX.48/nagiosxi/login.php'
client = requests.session()
client.get(URL)
payload = {
'username': 'my_user',
'password': 'my_pass',
'page': 'auth',
'pageopt': 'login',
'debug': ''
}
r = client.post(URL, data=payload, headers=dict(Referer=URL))
print r.text
But when I run it, I only get: "NSP: Sorry Dave, I can't let you do that"
I want to loggin this way because I want check with a script all the Actions set for each service and I have more than 12000 services, that is a lot of work if I do it handly.
So I do not know if there is a way to do it eaiser.
Thanks in advance.
Loggin to Nagios from script in python
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Loggin to Nagios from script in python
This would require you grab the hidden nsp value and other hidden form elements then submit with that.
A better method to get info about the hosts and services would be to use the builtin API with instructions under Help -> REST API Docs
A better method to get info about the hosts and services would be to use the builtin API with instructions under Help -> REST API Docs