Page 1 of 1

Export User Information From Manage Users

Posted: Wed Apr 25, 2018 10:07 am
by jkinning
I have over 250 users within Nagios XI and about 75 of these users have a phone number they entered for SMS information along with their cell provider. Nagios will send an email to this address and they get an SMS notification. Is there a way to export this information instead of me masquerading as them to get this number and provider information? I guess export the information under Admin | Manage users whould be great but not sure how to go about doing that.

Re: Export User Information From Manage Users

Posted: Wed Apr 25, 2018 11:36 am
by tmcdonald
Update:

Bryan Heden, our Product Development Manager came along and made it better so it actually gives all the info you want :)

Code: Select all

select t1.username as user, t2.keyvalue as phone, t3.keyvalue as provider from xi_usermeta t2 left join xi_users t1 on t2.user_id = t1.user_id left join xi_usermeta t3 on t3.user_id = t1.user_id where t2.keyname = 'mobile_number' and t3.keyname = 'mobile_provider';
----------

Nothing built in, but if you know how to get into the MySQL DB you can use this:

Code: Select all

use nagiosxi;
select xi_users.username as username,xi_usermeta.keyvalue as phone from xi_usermeta inner join xi_users on xi_usermeta.user_id = xi_users.user_id where keyname = 'mobile_number';
Let me know if you need more of an in-depth explanation. We tend to take the "Don't poke around in the DB" stance on the forums, so I am being intentionally vague :)

Also, it might need to be adjusted if you are using a system that upgraded from a 2014 or older version. Namely, it may be in Postgres still so you will need to log in there instead.

Re: Export User Information From Manage Users

Posted: Wed Apr 25, 2018 11:57 am
by jkinning
I don't have a NagiosXI database.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| nagios |
| nagiosql |
| test |
+--------------------+
5 rows in set (0.00 sec)

I do believe this started out as a 2014 version which has been upgraded to now 5.4.13.

Re: Export User Information From Manage Users

Posted: Wed Apr 25, 2018 12:56 pm
by jkinning
In addition to the sms number each user has configured I would like to export the listing of what host and services they are associated with as well.

I have been poking around but can't figure out where this information is located.

Re: Export User Information From Manage Users

Posted: Wed Apr 25, 2018 2:10 pm
by tmcdonald
jkinning wrote:I don't have a NagiosXI database.

I do believe this started out as a 2014 version which has been upgraded to now 5.4.13.
In that case you will need to run that through Postgres:

Code: Select all

psql -U nagiosxi -d nagiosxi -c "select t1.username as user, t2.keyvalue as phone, t3.keyvalue as provider from xi_usermeta t2 left join xi_users t1 on t2.user_id = t1.user_id left join xi_usermeta t3 on t3.user_id = t1.user_id where t2.keyname = 'mobile_number' and t3.keyname = 'mobile_provider'"
jkinning wrote:In addition to the sms number each user has configured I would like to export the listing of what host and services they are associated with as well.
That will be a bit harder to come up with. The trouble is that half the information is in Postgres and half is in MySQL. If it were all in one that would be easier.

Update: If you want to convert to a MySQL-only install, you can follow this guide: https://support.nagios.com/kb/article/c ... i-560.html

Then you could use the query in my original post to get the phone info.

The associated host+service bit is still more than I would be able to give you over the forum without getting a dev involved.

Re: Export User Information From Manage Users

Posted: Thu Apr 26, 2018 10:16 am
by jkinning
Thanks I was able to get the SMS information so I will stumble around looking at what host and services they were assigned to manually looking at the Nagios WebUI.

Re: Export User Information From Manage Users

Posted: Thu Apr 26, 2018 11:27 am
by lmiltchev
Do you want us to keep the thread open for a while or it is ok to lock it?

Re: Export User Information From Manage Users

Posted: Thu Apr 26, 2018 12:03 pm
by jkinning
You can close.