Page 1 of 1
Copy frontend user accounts to other servers
Posted: Sat Nov 12, 2016 12:18 am
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.
Re: Copy frontend user accounts to other servers
Posted: Mon Nov 14, 2016 11:04 am
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!
Re: Copy frontend user accounts to other servers
Posted: Mon Nov 14, 2016 1:07 pm
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 |
+--------------------+
Re: Copy frontend user accounts to other servers
Posted: Mon Nov 14, 2016 2:33 pm
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"
}
Re: Copy frontend user accounts to other servers
Posted: Wed Dec 07, 2016 1:53 pm
by ks6764
Is there a way to use curl to obtain a list of users from the GUI ?
Re: Copy frontend user accounts to other servers
Posted: Wed Dec 07, 2016 4:49 pm
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"
Re: Copy frontend user accounts to other servers
Posted: Fri Jun 09, 2017 11:53 pm
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.
Re: Copy frontend user accounts to other servers
Posted: Mon Jun 12, 2017 9:15 am
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.
Re: Copy frontend user accounts to other servers
Posted: Mon Jun 12, 2017 10:38 am
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 ?
Re: Copy frontend user accounts to other servers
Posted: Mon Jun 12, 2017 2:10 pm
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.