Page 1 of 2

Set API key for NagosXI

Posted: Wed May 24, 2017 11:34 am
by nagwindmon
I have created scripts utilizing APIs and it works great in my testing... using my user key to access the API and my login credentials into NagosXI based off my AD account
Now I'm ready to move those into prod environment where scripts will be running on several different windows boxes so is there a way to set the key on each XI server and it wont be tied to individual user?
NagiosXI ver 5.4.4
Thanks!

Re: Set API key for NagosXI

Posted: Wed May 24, 2017 11:44 am
by dwhitfield
You can just create a separate account for API usage. If you have another account other than nagiosadmin, you could just use nagiosadmin.

Re: Set API key for NagosXI

Posted: Wed May 24, 2017 12:01 pm
by nagwindmon
dwhitfield wrote:You can just create a separate account for API usage. If you have another account other than nagiosadmin, you could just use nagiosadmin.
I'm not sure I got this... may need more of your help here please, so if I go ahead and use nagiosadmin then where API key for this user can be found, is this something I can view thru UI, or database query into nagios?

Re: Set API key for NagosXI

Posted: Wed May 24, 2017 12:34 pm
by dwhitfield
Apologies. It's in the same place for each user: http://YOURSERVER/nagiosxi/account/

You'll need to be logged in as that user (masquerading or otherwise) to access their account page.

Please let us know if you need any additional info.

Re: Set API key for NagosXI

Posted: Wed May 24, 2017 1:08 pm
by nagwindmon
I'm new to Nagios and the API, so let me rephrase my question:
We will have quite a few of XI servers so keeping track of the individual api keys is prohibitive.
Is there a way to set the key on each XI?

Re: Set API key for NagosXI

Posted: Wed May 24, 2017 3:30 pm
by tgriep
You could set the Backend Ticket to the same on your server and use that for your API ticket number.
Run the following as root, but change '12345678' to the API key you want to use and this will set the backend ticket key for the nagiosadmin backend API.

Code: Select all

mysql -u root -pnagiosxi nagiosxi -e "UPDATE xi_users SET backend_ticket = '12345678' WHERE username='nagiosadmin'";
Then, you can use this API as the ticket number in the calls and not the user unique API key.

Re: Set API key for NagosXI

Posted: Thu May 25, 2017 10:43 am
by nagwindmon
looks like our set up is different from standard, no nagiosxi db?
Please advise

Re: Set API key for NagosXI

Posted: Thu May 25, 2017 10:58 am
by dwhitfield
It's possible your db is offloaded.

Can you PM me your Profile? You can download it by going to Admin > System Config > System Profile and click the ***Download Profile*** button towards the top. If for whatever reason you *cannot* download the profile, please put the output of View System Info (5.3.4+, Show Profile if older) in the thread (that will at least get us some info). This will give us access to many of the logs we would otherwise ask for individually. If security is a concern, you can unzip the profile take out what you like, and then zip it up again. We may end up needing something you remove, but we can ask for that specifically.

After you PM the profile, please update this thread. Updating this thread is the only way for it to show back up on our dashboard.

Re: Set API key for NagosXI

Posted: Thu May 25, 2017 1:40 pm
by nagwindmon
*cannot* download the profile:
PROFILE BUILD FAILED
Array
(
[0] => Request rejected by Privilege Manager
)

CODE: 1

System Info file has been attached

Re: Set API key for NagosXI

Posted: Thu May 25, 2017 2:04 pm
by dwhitfield
nagwindmon wrote: [0] => Request rejected by Privilege Manager
That is likely to be the case in a lot of situations. For now, see https://support.nagios.com/kb/article.p ... ategory=44