Copy frontend user accounts to other servers

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
ks6764
Posts: 58
Joined: Thu Aug 20, 2015 10:42 am

Copy frontend user accounts to other servers

Post by ks6764 »

I have 20 Nagios XI 5.2.3 monitoring servers. The login accounts for the GUI are not using LDAP authentication, but a manual password that is set when the account is created.

Is there a way of copying front end, GUI logins from one server to other servers while retaining the same password and permissions ?

I spend way too much time manually creating logins on Server A and then manually creating the same logins on Server B, Server C, etc. I am talking about 100 to 300 users or more per server for a large company.

Is there a script that will do this for me or a table from the database that can be backed up and restored on the other servers as a means of copying the user accounts ?

Any help would be appreciated.
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Copy frontend user accounts to other servers

Post by dwhitfield »

Can you post the output of the following two commands?

Code: Select all

echo '\d;' | psql nagiosxi nagiosxi
echo 'show databases;' | mysql -t -u root -pnagiosxi
Thanks!
ks6764
Posts: 58
Joined: Thu Aug 20, 2015 10:42 am

Re: Copy frontend user accounts to other servers

Post by ks6764 »

The first command you listed, the command psql cannot be found as we are on a version of Nagios XI that no longer requires Postgres. For the second command you listed, see output below.

Code: Select all

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| nagios             |
| nagiosql           |
| nagiosxi           |
| performance_schema |
| test               |
+--------------------+
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Copy frontend user accounts to other servers

Post by rkennedy »

It looks like everything is on SQL so that's a good sign.

There was actually this functionality added into a newer version. 5.3.x. It works with an API call by using something like this -

Code: Select all

curl -XPOST "http://192.168.3.115/nagiosxi/api/v1/system/user?apikey=32klfcka&pretty=1" -d "username=jmcdouglas&password=test&name=Jordan%20McDouglas&email=jmcdouglas@localhost"
which returns -

Code: Select all

{
    "success": "User account jmcdouglas was added successfully!",
    "userid": "16"
}
Former Nagios Employee
ks6764
Posts: 58
Joined: Thu Aug 20, 2015 10:42 am

Re: Copy frontend user accounts to other servers

Post by ks6764 »

Is there a way to use curl to obtain a list of users from the GUI ?
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Copy frontend user accounts to other servers

Post by mcapra »

Something like this should do the trick:

Code: Select all

curl -XGET "http://<xi_host>/nagiosxi/api/v1/system/user?apikey=<api_key>&pretty=1"
Former Nagios employee
https://www.mcapra.com/
ks6764
Posts: 58
Joined: Thu Aug 20, 2015 10:42 am

Re: Copy frontend user accounts to other servers

Post by ks6764 »

I have another question on this same topic if I can append it here without opening a new topic.

On a Nagios XI 5.2.3 server, I can paste the following into my browser and see a list of all the users in the GUI.

http://myserver:8085/nagiosxi/backend/?cmd=getusers

I want to get the same output from the command line using curl, but so far I can only retrieve a single account by running the following for example. If I try to curl the http line above, I will get an authentication error.

curl -XGET "http://myserver:8085/nagiosxi/backend/? ... cketnumber" -o myfile

There is reference in this topic and others as to using: curl -XGET "http://<xi_host>/nagiosxi/api/v1/system/user?apikey=<api_key>&pretty=1" but this path does not exist on my 5.2.3 Nagios XI server.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Copy frontend user accounts to other servers

Post by lmiltchev »

There are many REST API improvements in the latest revisions of Nagios XI. I would recommend upgrading your Nagios XI instance to the latest. Then, you will be able to run something like this:

Code: Select all

curl -XGET "http://myserver:8085/nagiosxi/api/v1/system/user?apikey=xxx&pretty=1" -o myfile
where you substitute "xxx" with the actual API key.
Be sure to check out our Knowledgebase for helpful articles and solutions!
ks6764
Posts: 58
Joined: Thu Aug 20, 2015 10:42 am

Re: Copy frontend user accounts to other servers

Post by ks6764 »

Our company installs Nagios XI differently and so an upgrade path isn't always easy. I won't go into all the details, but is what I am attempting to do in anyway possible in the 5.2.3 version ?
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Copy frontend user accounts to other servers

Post by dwhitfield »

rkennedy wrote: There was actually this functionality added into a newer version. 5.3.x.
Complicated or not, if you want to use the modern API, you'll need to upgrade to at least 5.3.x.
Locked