Loggin to Nagios from script in python
Posted: Tue Aug 07, 2018 7:55 pm
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.
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.