User Management inside Postgres

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
technick
Posts: 49
Joined: Tue Feb 04, 2014 10:30 am
Location: Denver, CO

User Management inside Postgres

Post by technick »

I'm not really familiar with postgres and need to figure out how to add / delete / update users from the command line and further more a bash script. I took a look at the table xi_users already and can see some of the information i'll need to modify here. What I don't see is privilege information and not sure where that can be.

I'm also unsur what the colume "backend_ticket" is in xi_user and is it required?

I have about 100 users I need to add and the gui would just be plain torture.

Thanks in advance for the help.
----------------------
Nagios Jedi in training.
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: User Management inside Postgres

Post by slansing »

So, as far as privilege information, do you mean within the web interface? That is handled when new users are pulled into:

Code: Select all

/usr/local/nagios/etc/cgi.cfg
That is done as part of the user creation procedure in the web interface, it can be manually edited, which you would need to end up doing if you are going with a scripted route.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: User Management inside Postgres

Post by abrist »

technick wrote: I'm also unsur what the colume "backend_ticket" is in xi_user and is it required?
This is a unique id that can be used for limited passwordless logins for rapid response and external dashboards.
technick wrote: I have about 100 users I need to add and the gui would just be plain torture.
Apologies for the slow drawn and quartering, but you may run into some issues if you add with the cli - specifically, core contacts need to created, the xi user in the db needs to be created along with all the necessary fields, and the cgis need to be edited. So it may be scriptable, but it will not be easy.

Do you have an intern to do this for you ? :P
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
technick
Posts: 49
Joined: Tue Feb 04, 2014 10:30 am
Location: Denver, CO

Re: User Management inside Postgres

Post by technick »

:roll: haha, I work in one of those agile companies where engineers don't get interns =\.

So just from my testing, this is what I have found so far.

I created a "testuser" from the gui and that user has never been logged into. User is not made a monitoring contact as well, this is strictly for accessing nagios xi web interface, manage monitoring services and manage configurations.

Code: Select all

nagiosxi=> select * from xi_users where username = 'testuser' ;
 user_id | username |             password             |   name    |           email           |                          backend_ticket                          | enabled
---------+----------+----------------------------------+-----------+---------------------------+------------------------------------------------------------------+---------
      55 | testuser | 098f6bcd4621d373cade4e832627b4f6 | test user | [email protected] | h0bd3tjemh4mopneo4micljch9i0m2g63qi3l4gckhvdamovoeg203bfbtguuv2u |       1
(1 row)

Code: Select all

nagiosxi=> select * from xi_usermeta where user_id = 55 ;
usermeta_id|user_id|keyname|keyvalue|autoload
647|55|advanced_user|0|1
645|55|authorized_for_all_object_commands|0|1
643|55|authorized_for_all_objects|0|1
646|55|authorized_for_monitoring_system|0|1
644|55|authorized_to_configure_objects|0|1
641|55|date_format|1|1
624|55|enable_notifications|1|0
639|55|language||1
638|55|name|test user|1
637|55|notification_times|a:7:{i:0;a:2:{s:5:"start";s:5:"00:00";s:3:"end";s:5:"24:00";}i:1;a:2:{s:5:"start";s:5:"00:00";s:3:"end";s:5:"24:00";}i:2;a:2:{s:5:"start";s:5:"00:00";s:3:"end";s:5:"24:00";}i:3;a:2:{s:5:"start";s:5:"00:00";s:3:"end";s:5:"24:00";}i:4;a:2:{s:5:"start";s:5:"00:00";s:3:"end";s:5:"24:00";}i:5;a:2:{s:5:"start";s:5:"00:00";s:3:"end";s:5:"24:00";}i:6;a:2:{s:5:"start";s:5:"00:00";s:3:"end";s:5:"24:00";}}|0
625|55|notify_by_email|1|0
626|55|notify_host_down|1|0
630|55|notify_host_downtime|1|0
629|55|notify_host_flapping|1|0
628|55|notify_host_recovery|1|0
627|55|notify_host_unreachable|1|0
633|55|notify_service_critical|1|0
636|55|notify_service_downtime|1|0
635|55|notify_service_flapping|1|0
634|55|notify_service_recovery|1|0
632|55|notify_service_unknown|1|0
631|55|notify_service_warning|1|0
642|55|number_format|2|1
648|55|readonly_user|0|1
640|55|theme||1
623|55|userlevel|255|1
(26 rows)
So total I will need to insert 27 rows into the database per user. One row into xi_users and the other twenty six into xi_usermeta, all with the associated user_id of the the new user i'm injecting. Afterwords, i'll need to append their username to the cgi.cfg which I believe sed would do the trick for me.

Questions... The column for the backend_ticket is "character varying(128)". Can I just use a randomly generated string up to 128 characters or are there limitations to the string length?
I'm not very familiar with postgres, how do I generate the password hash?

Am I missing anything else that would need to be updated?

Thanks!
----------------------
Nagios Jedi in training.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: User Management inside Postgres

Post by abrist »

technick wrote:Questions... The column for the backend_ticket is "character varying(128)". Can I just use a randomly generated string up to 128 characters or are there limitations to the string length?
I'm not very familiar with postgres, how do I generate the password hash?
By banging your head on the keyboard. Get a kitten to help :P
Seriously though, this number is just randomly generated. No hashing of the username/pass required.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked