Page 1 of 1

User permissions on Nagios directories

Posted: Mon Dec 17, 2018 2:04 pm
by MOHANREDDY
Hi,

The user and group permissions on these directories are root:root, apache:apache, nagios:nagios.

# ls -ltr /usr/local
drwxr-xr-x 8 root root 79 Oct 16 14:37 nagios
drwxr-xr-x 10 nagios nagios 102 Oct 16 14:38 nagiosxi
drwxrwxr-x 4 nagios nagios 30 Oct 30 13:55 nsis
drwxr-xr-x 6 root root 227 Nov 9 11:07 nagiosmobile
drwxr-xr-x 5 apache apache 70 Nov 9 11:08 nagvis
drwxrwxr-x 7 nagios nagios 121 Nov 9 11:08 nrdp

The nagios directory has nagios:nagios and root:root.

# ls -ltr nagios
total 24
drwxrwxr-x 2 nagios nagios 4096 Nov 9 11:07 sbin
drwxrwxr-x 17 nagios nagios 4096 Nov 9 11:07 share
drwxr-xr-x 2 root root 192 Nov 9 11:08 bin
drwxrwxr-x 7 apache nagios 4096 Dec 14 11:24 etc
drwxrwxr-x 2 nagios nagios 8192 Dec 17 09:40 libexec
drwxrwxr-x 6 nagios nagios 270 Dec 17 13:58 var


i would like to copy all these folders/files from primary to secondary as a part of fail-over using Rsync. but in our organisation we are not allowed to ssh as root. Am i allowed to change the user permissions from root:root to nagios:nagios. Does it cause any issue to nagios performance?

Thanks.

Re: User permissions on Nagios directories

Posted: Mon Dec 17, 2018 3:36 pm
by scottwilkerson
MOHANREDDY wrote:Am i allowed to change the user permissions from root:root to nagios:nagios. Does it cause any issue to nagios performance?
Changing a few of the directories should not affect performance, however there are files that are owned by root that need to remain that way or will not function, at a minimum:

Code: Select all

ls -l /usr/local/nagios/libexec/check_dhcp
ls -l /usr/local/nagios/libexec/check_icmp
I would recommend making a backup using the backup script and restoring on the secondary
https://assets.nagios.com/downloads/nag ... ios-XI.pdf

Re: User permissions on Nagios directories

Posted: Mon Dec 17, 2018 3:50 pm
by bolson
Hello MOHANREDDY,

In addition to what Scott has said, since the mode is read-execute for all users, you should be able to rsync these directories as an ordinary (non-privileged) user without changing permissions. You can run these command from a non-root account to test:

Code: Select all

cd /usr/local
rsync -prl --specials nagios /tmp

Re: User permissions on Nagios directories

Posted: Wed Dec 19, 2018 11:37 am
by MOHANREDDY
scottwilkerson wrote:
MOHANREDDY wrote:Am i allowed to change the user permissions from root:root to nagios:nagios. Does it cause any issue to nagios performance?
Changing a few of the directories should not affect performance, however there are files that are owned by root that need to remain that way or will not function, at a minimum:

Code: Select all

ls -l /usr/local/nagios/libexec/check_dhcp
ls -l /usr/local/nagios/libexec/check_icmp
I would recommend making a backup using the backup script and restoring on the secondary
https://assets.nagios.com/downloads/nag ... ios-XI.pdf

As you suggested, instead of copying files I tried to restore secondary server from primary server backup, and i ran reconfigure.sh, i ran into couple of errors.

#/usr/local/nagiosxi/scripts/reconfigure_nagios.sh

--- reset_config_perms.sh ------------
> Setting CCM script permissions
> Setting script permissions
> Setting special component script permissions
> Setting configuration file/directory permissions
> Setting perfdata directory and RRD permissions
> Setting NOM checkpoint user:group permissions
> + Setting CCM configuration file user:group permissions
> + Setting Recurring Downtime file user:group permissions
> + Setting BPI configuration file user:group permissions
--------------------------------------
PHP Warning: mysqli::mysqli(): (28000/1045): Access denied for user 'nagiosql'@'secondary_app_server' (using password: YES) in /usr/local/nagiosxi/html/includes/components/ccm/classes/db.class.php on line 80
PHP Warning: mysqli::set_charset(): Couldn't fetch mysqli in /usr/local/nagiosxi/html/includes/components/ccm/classes/db.class.php on line 81
PHP Warning: mysqli::query(): Couldn't fetch mysqli in /usr/local/nagiosxi/html/includes/components/ccm/classes/db.class.php on line 82
PHP Warning: mysqli::query(): Couldn't fetch mysqli in /usr/local/nagiosxi/html/includes/components/ccm/classes/db.class.php on line 99
PHP Warning: db::query(): Property access is not allowed yet in /usr/local/nagiosxi/html/includes/components/ccm/classes/db.class.php on line 101
PHP Notice: Trying to get property of non-object in /usr/local/nagiosxi/html/includes/components/ccm/classes/db.class.php on line 112
PHP Fatal error: Call to a member function free() on a non-object in /usr/local/nagiosxi/html/includes/components/ccm/classes/db.class.php on line 117

Importing into the CCM failed!



i have database offloaded to a separate server, I tried to run repair databases script. i saw some errors.

# /usr/local/nagiosxi/scripts/repair_databases.sh
DATABASE: nagios
TABLE:
nagios.nagios_acknowledgements OK
nagios.nagios_commands OK
nagios.nagios_commenthistory OK
nagios.nagios_comments OK
nagios.nagios_configfiles OK
nagios.nagios_configfilevariables OK
nagios.nagios_conninfo OK
nagios.nagios_contact_addresses OK
nagios.nagios_contact_notificationcommands OK
nagios.nagios_contactgroup_members OK
nagios.nagios_contactgroups OK
nagios.nagios_contactnotificationmethods OK
nagios.nagios_contactnotifications OK
nagios.nagios_contacts OK
nagios.nagios_contactstatus OK
nagios.nagios_customvariables OK
nagios.nagios_customvariablestatus OK
nagios.nagios_dbversion OK
nagios.nagios_downtimehistory OK
nagios.nagios_eventhandlers OK
nagios.nagios_externalcommands OK
nagios.nagios_flappinghistory OK
nagios.nagios_host_contactgroups OK
nagios.nagios_host_contacts OK
nagios.nagios_host_parenthosts OK
nagios.nagios_hostchecks OK
nagios.nagios_hostdependencies OK
nagios.nagios_hostescalation_contactgroups OK
nagios.nagios_hostescalation_contacts OK
nagios.nagios_hostescalations OK
nagios.nagios_hostgroup_members OK
nagios.nagios_hostgroups OK
nagios.nagios_hosts OK
nagios.nagios_hoststatus OK
nagios.nagios_instances OK
nagios.nagios_logentries OK
nagios.nagios_notifications OK
nagios.nagios_objects OK
nagios.nagios_processevents OK
nagios.nagios_programstatus OK
nagios.nagios_runtimevariables OK
nagios.nagios_scheduleddowntime OK
nagios.nagios_service_contactgroups OK
nagios.nagios_service_contacts OK
nagios.nagios_service_parentservices OK
nagios.nagios_servicechecks OK
nagios.nagios_servicedependencies OK
nagios.nagios_serviceescalation_contactgroups OK
nagios.nagios_serviceescalation_contacts OK
nagios.nagios_serviceescalations OK
nagios.nagios_servicegroup_members OK
nagios.nagios_servicegroups OK
nagios.nagios_services OK
nagios.nagios_servicestatus OK
nagios.nagios_statehistory OK
nagios.nagios_systemcommands OK
nagios.nagios_timedeventqueue OK
nagios.nagios_timedevents OK
nagios.nagios_timeperiod_timeranges OK
nagios.nagios_timeperiods OK
Issued remote command 'mysqlcheck -f -r -u nagios -pnagios -h Database_server --port=3306 --databases nagios'
DATABASE: nagiosql
TABLE:
nagiosql.tbl_command
note : The storage engine for the table doesn't support repair
nagiosql.tbl_contact
note : The storage engine for the table doesn't support repair
nagiosql.tbl_contactgroup
note : The storage engine for the table doesn't support repair
nagiosql.tbl_contacttemplate
note : The storage engine for the table doesn't support repair
nagiosql.tbl_domain
note : The storage engine for the table doesn't support repair
nagiosql.tbl_host
note : The storage engine for the table doesn't support repair
nagiosql.tbl_hostdependency
note : The storage engine for the table doesn't support repair
nagiosql.tbl_hostescalation
note : The storage engine for the table doesn't support repair
nagiosql.tbl_hostextinfo
note : The storage engine for the table doesn't support repair
nagiosql.tbl_hostgroup
note : The storage engine for the table doesn't support repair
nagiosql.tbl_hosttemplate
note : The storage engine for the table doesn't support repair
nagiosql.tbl_info
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkContactToCommandHost
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkContactToCommandService
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkContactToContactgroup
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkContactToContacttemplate
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkContactToVariabledefinition
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkContactgroupToContact
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkContactgroupToContactgroup
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkContacttemplateToCommandHost
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkContacttemplateToCommandService
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkContacttemplateToContactgroup
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkContacttemplateToContacttemplate
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkContacttemplateToVariabledefinition
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkHostToContact
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkHostToContactgroup
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkHostToHost
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkHostToHostgroup
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkHostToHosttemplate
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkHostToVariabledefinition
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkHostdependencyToHost_DH
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkHostdependencyToHost_H
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkHostdependencyToHostgroup_DH
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkHostdependencyToHostgroup_H
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkHostescalationToContact
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkHostescalationToContactgroup
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkHostescalationToHost
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkHostescalationToHostgroup
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkHostgroupToHost
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkHostgroupToHostgroup
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkHosttemplateToContact
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkHosttemplateToContactgroup
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkHosttemplateToHost
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkHosttemplateToHostgroup
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkHosttemplateToHosttemplate
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkHosttemplateToVariabledefinition
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServiceToContact
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServiceToContactgroup
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServiceToHost
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServiceToHostgroup
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServiceToServicegroup
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServiceToServicetemplate
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServiceToVariabledefinition
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServicedependencyToHost_DH
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServicedependencyToHost_H
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServicedependencyToHostgroup_DH
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServicedependencyToHostgroup_H
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServicedependencyToService_DS
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServicedependencyToService_S
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServiceescalationToContact
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServiceescalationToContactgroup
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServiceescalationToHost
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServiceescalationToHostgroup
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServiceescalationToService
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServicegroupToService
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServicegroupToServicegroup
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServicetemplateToContact
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServicetemplateToContactgroup
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServicetemplateToHost
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServicetemplateToHostgroup
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServicetemplateToServicegroup
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServicetemplateToServicetemplate
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkServicetemplateToVariabledefinition
note : The storage engine for the table doesn't support repair
nagiosql.tbl_lnkTimeperiodToTimeperiod
note : The storage engine for the table doesn't support repair
nagiosql.tbl_logbook
note : The storage engine for the table doesn't support repair
nagiosql.tbl_mainmenu
note : The storage engine for the table doesn't support repair
nagiosql.tbl_permission
note : The storage engine for the table doesn't support repair
nagiosql.tbl_permission_inactive
note : The storage engine for the table doesn't support repair
nagiosql.tbl_service
note : The storage engine for the table doesn't support repair
nagiosql.tbl_servicedependency
note : The storage engine for the table doesn't support repair
nagiosql.tbl_serviceescalation
note : The storage engine for the table doesn't support repair
nagiosql.tbl_serviceextinfo
note : The storage engine for the table doesn't support repair
nagiosql.tbl_servicegroup
note : The storage engine for the table doesn't support repair
nagiosql.tbl_servicetemplate
note : The storage engine for the table doesn't support repair
nagiosql.tbl_session
note : The storage engine for the table doesn't support repair
nagiosql.tbl_session_locks
note : The storage engine for the table doesn't support repair
nagiosql.tbl_settings
note : The storage engine for the table doesn't support repair
nagiosql.tbl_submenu
note : The storage engine for the table doesn't support repair
nagiosql.tbl_timedefinition
note : The storage engine for the table doesn't support repair
nagiosql.tbl_timeperiod
note : The storage engine for the table doesn't support repair
nagiosql.tbl_user
note : The storage engine for the table doesn't support repair
nagiosql.tbl_variabledefinition
note : The storage engine for the table doesn't support repair
Issued remote command 'mysqlcheck -f -r -u nagiosql -pnagiosql -h Database_server --port=3306 --databases nagiosql'
DATABASE: nagiosxi
TABLE:
nagiosxi.xi_auditlog
note : The storage engine for the table doesn't support repair
nagiosxi.xi_auth_tokens
note : The storage engine for the table doesn't support repair
nagiosxi.xi_cmp_trapdata
note : The storage engine for the table doesn't support repair
nagiosxi.xi_cmp_trapdata_log
note : The storage engine for the table doesn't support repair
nagiosxi.xi_commands
note : The storage engine for the table doesn't support repair
nagiosxi.xi_eventqueue
note : The storage engine for the table doesn't support repair
nagiosxi.xi_events
note : The storage engine for the table doesn't support repair
nagiosxi.xi_incidents
note : The storage engine for the table doesn't support repair
nagiosxi.xi_meta
note : The storage engine for the table doesn't support repair
nagiosxi.xi_options
note : The storage engine for the table doesn't support repair
nagiosxi.xi_sessions
note : The storage engine for the table doesn't support repair
nagiosxi.xi_sysstat
note : The storage engine for the table doesn't support repair
nagiosxi.xi_usermeta
note : The storage engine for the table doesn't support repair
nagiosxi.xi_users
note : The storage engine for the table doesn't support repair
Issued remote command 'mysqlcheck -f -r -u nagiosxi -pnagiosxi -h Database_server --port=3306 --databases nagiosxi'

=======================
nagios offloaded database repair succeeded
nagiosql offloaded database repair succeeded
nagiosxi offloaded database repair succeeded

I checked database connection from App server to database server, everything seems good.

# mysql -u nagios -p'nagios' -h secondary_database_server -e STATUS;
--------------
mysql Ver 15.1 Distrib 5.5.52-MariaDB, for Linux (x86_64) using readline 5.1

Connection id: 56310
Current database:
Current user: nagios@secondary_app_server
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server: MariaDB
Server version: 5.5.52-MariaDB MariaDB Server
Protocol version: 10
Connection: secondary_database_server via TCP/IP
Server characterset: latin1
Db characterset: latin1
Client characterset: latin1
Conn. characterset: latin1
TCP port: 3306
Uptime: 1 day 21 hours 4 min 20 sec

Threads: 22 Questions: 945222 Slow queries: 0 Opens: 5296 Flush tables: 2 Open tables: 102 Queries per second avg: 5.825
--------------

]# mysql -u nagiosql -p'nagiosql' -h secondary_database_server -e STATUS;
--------------
mysql Ver 15.1 Distrib 5.5.52-MariaDB, for Linux (x86_64) using readline 5.1

Connection id: 56341
Current database:
Current user: nagiosql@secondary_app_server
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server: MariaDB
Server version: 5.5.52-MariaDB MariaDB Server
Protocol version: 10
Connection: secondary_database_server via TCP/IP
Server characterset: latin1
Db characterset: latin1
Client characterset: latin1
Conn. characterset: latin1
TCP port: 3306
Uptime: 1 day 21 hours 5 min 30 sec

Threads: 22 Questions: 945846 Slow queries: 0 Opens: 5296 Flush tables: 2 Open tables: 102 Queries per second avg: 5.826
--------------


# mysql -u nagiosxi -p'nagiosxi' -h secondary_database_server -e STATUS;
--------------
mysql Ver 15.1 Distrib 5.5.52-MariaDB, for Linux (x86_64) using readline 5.1

Connection id: 56375
Current database:
Current user: nagiosxi@secondary_app_server
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server: MariaDB
Server version: 5.5.52-MariaDB MariaDB Server
Protocol version: 10
Connection: secondary_database_server via TCP/IP
Server characterset: latin1
Db characterset: latin1
Client characterset: latin1
Conn. characterset: latin1
TCP port: 3306
Uptime: 1 day 21 hours 6 min 13 sec

Threads: 22 Questions: 946359 Slow queries: 0 Opens: 5296 Flush tables: 2 Open tables: 102 Queries per second avg: 5.828
--------------

Please help me what to check and where to check on this issue.


Thanks.

Re: User permissions on Nagios directories

Posted: Wed Dec 19, 2018 1:05 pm
by bolson
Does Nagios XI work as expected on the primary server? Are you running the reconfigure and repair scripts on the primary or secondary server? On the secondary server, did you make the necessary edits to /usr/local/nagiosxi/html/config.inc.php as defined in this doc?

https://assets.nagios.com/downloads/nag ... Server.pdf

Re: User permissions on Nagios directories

Posted: Wed Dec 19, 2018 1:24 pm
by MOHANREDDY
bolson wrote:Does Nagios XI work as expected on the primary server? Are you running the reconfigure and repair scripts on the primary or secondary server? On the secondary server, did you make the necessary edits to /usr/local/nagiosxi/html/config.inc.php as defined in this doc?

https://assets.nagios.com/downloads/nag ... Server.pdf
The primary works fine and i have ran the reconfigure and repair scripts on secondary server. I have followed all the steps defined in that doc. I have changed ip's in /usr/local/nagiosxi/html/config.inc.php as well as /usr/local/nagios/etc/ndo2db.cfg.

Re: User permissions on Nagios directories

Posted: Wed Dec 19, 2018 2:13 pm
by bolson
note : The storage engine for the table doesn't support repair
nagiosxi.xi_auth_tokens
These can safely be ignored as they are merely informational.

On the other hand, these are more concerning:
PHP Warning: mysqli::mysqli(): (28000/1045): Access denied for user 'nagiosql'@'secondary_app_server' (using password: YES) in /usr/local/nagiosxi/html/includes/components/ccm/classes/db.class.php on line 80
PHP Warning: mysqli::set_charset(): Couldn't fetch mysqli in /usr/local/nagiosxi/html/includes/components/ccm/classes/db.class.php on line 81
PHP Warning: mysqli::query(): Couldn't fetch mysqli in /usr/local/nagiosxi/html/includes/components/ccm/classes/db.class.php on line 82
PHP Warning: mysqli::query(): Couldn't fetch mysqli in /usr/local/nagiosxi/html/includes/components/ccm/classes/db.class.php on line 99
PHP Warning: db::query(): Property access is not allowed yet in /usr/local/nagiosxi/html/includes/components/ccm/classes/db.class.php on line 101
PHP Notice: Trying to get property of non-object in /usr/local/nagiosxi/html/includes/components/ccm/classes/db.class.php on line 112
PHP Fatal error: Call to a member function free() on a non-object in /usr/local/nagiosxi/html/includes/components/ccm/classes/db.class.php on line 117
The bottom Fatal error iappears to be the result of the reconfigure script being unable to connect using the credentials passed. At this point, without more information, I would have to ask you to doublecheck your configuration on the secondary server.

Re: User permissions on Nagios directories

Posted: Wed Dec 19, 2018 2:48 pm
by MOHANREDDY
I have a question, can we restore everything except databases from the backups using restore script as we have replication between databases? i need a way to make secondary be in sync with secondary in respect to config files, other files/folders.

Thanks,

Re: User permissions on Nagios directories

Posted: Wed Dec 19, 2018 4:34 pm
by bolson
While in theory, the scenario you've described should work, there's no substitute for thorough testing to determine if things will work as expected.