Page 1 of 1

To prevent users from setting disable notification,still

Posted: Wed Jun 10, 2020 10:30 pm
by ahm002
Is there any way to prevent users from using disable notification options,while still let users have the rights to use schedule downtime and acknowledge options?
Thanks a lot.

Re: To prevent users from setting disable notification,still

Posted: Thu Jun 11, 2020 12:01 pm
by jbrunkow
Since the setting to control hosts and services governs access to both of those features, it is not currently possible to allow one of those and disallow the other.
USER RIGHTS DOCUMENT

There may, however, be a workaround by uninstalling, disabling, or even breaking the Monitoring Engine Process dashlet (that contains the disable notification button).

Re: To prevent users from setting disable notification,still

Posted: Fri Jun 12, 2020 7:45 am
by hbouma
What we do is actually remove the "disable notifications" option from the GUI. I have not tested this in Nagios 5.7.0, but it works in 5.6.10.

https://support.nagios.com/forum/viewto ... 36#p210071

Re: To prevent users from setting disable notification,still

Posted: Fri Jun 12, 2020 11:49 am
by jbrunkow
Yes! Thankyou for making that connection, @hbouma.

That topic actually mentions two methods of doing this, one with PHP and another with JavaScript. The same lines of code are present in 5.7, but appear in different lines of the files.

Comment out the following code from /usr/local/nagiosxi/html/includes/components/xicore/ajaxhelpers-hoststatus.inc.php on line 625.

Code: Select all

            // Notifications
            if (intval($xml->hoststatus->notifications_enabled) == 1) {
                $cmd["command_args"]["cmd"] = NAGIOSCORE_CMD_DISABLE_HOST_NOTIFICATIONS;
                $output .= '<li>' . get_host_detail_command_link($cmd, "nonotifications.png", _("Disable notifications")) . '</li>';
            } else {
                $cmd["command_args"]["cmd"] = NAGIOSCORE_CMD_ENABLE_HOST_NOTIFICATIONS;
                $output .= '<li>' . get_host_detail_command_link($cmd, "enablenotifications.png", _("Enable notifications")) . '</li>';
            }

            // Force immediate check
            $cmd["command_args"]["cmd"] = NAGIOSCORE_CMD_SCHEDULE_FORCED_HOST_CHECK;
            $cmd["command_args"]["start_time"] = time();
            $output .= '<li>' . get_host_detail_command_link($cmd, "arrow_refresh.png", _("Force an immediate check")) . '</li>';
        }
...and the following block from /usr/local/nagiosxi/html/includes/components/xicore/ajaxhelpers-servicestatus.inc.php on line 818.

Code: Select all

        // Notifications
        if (intval($xml->servicestatus->notifications_enabled) == 1) {
            $cmd["command_args"]["cmd"] = NAGIOSCORE_CMD_DISABLE_SVC_NOTIFICATIONS;
            $output .= '<li>' . get_service_detail_command_link($cmd, "nonotifications.png", _("Disable notifications")) . '</li>';
        } else {
            $cmd["command_args"]["cmd"] = NAGIOSCORE_CMD_ENABLE_SVC_NOTIFICATIONS;
            $output .= '<li>' . get_service_detail_command_link($cmd, "enablenotifications.png", _("Enable notifications")) . '</li>';
        }

        // Forced immediate check
        $cmd["command_args"]["cmd"] = NAGIOSCORE_CMD_SCHEDULE_FORCED_SVC_CHECK;
        $cmd["command_args"]["start_time"] = time();
        $output .= '<li>' . get_service_detail_command_link($cmd, "arrow_refresh.png", _("Force an immediate check")) . '</li>';
    }

Re: To prevent users from setting disable notification,still

Posted: Fri Jun 12, 2020 12:19 pm
by hbouma
For our company, we have scripted out a set of changes that we want in order to customize the Nagios experience for our end user. This includes disabling the ability to disable notifications from the Host Details, Service Details, and Host Group commands. I am guessing you may want to do the same or something similar.

As part of this scripting, we run the following after every install:

Code: Select all

sed -i '/xml->servicestatus->notifications_enabled/,+6 d' /usr/local/nagiosxi/html/includes/components/xicore/ajaxhelpers-servicestatus.inc.php
sed -i '/xml->hoststatus->notifications_enabled/,+6 d' /usr/local/nagiosxi/html/includes/components/xicore/ajaxhelpers-hoststatus.inc.php
We also run the following to disable the same options for the Host Group commands:
https://support.nagios.com/forum/viewto ... 95#p265982

Code: Select all

sed -i "10i body \> div \> table \> tbody \> tr\:nth-child(1) \> td\:nth-child(2) \> table \> tbody \> tr \> td \> table \> tbody \> tr\:nth-child(3) \{ display\: none \!important\; \}" /usr/local
/nagiosxi/html/includes/components/nagioscore/ui/css/extinfo.css
sed -i "11i body \> div \> table \> tbody \> tr\:nth-child(1) \> td\:nth-child(2) \> table \> tbody \> tr \> td \> table \> tbody \> tr\:nth-child(4) \{ display\: none \!important\; \}" /usr/local
/nagiosxi/html/includes/components/nagioscore/ui/css/extinfo.css
sed -i "12i body \> div \> table \> tbody \> tr\:nth-child(1) \> td\:nth-child(2) \> table \> tbody \> tr \> td \> table \> tbody \> tr\:nth-child(5) \{ display\: none \!important\; \}" /usr/local
/nagiosxi/html/includes/components/nagioscore/ui/css/extinfo.css
sed -i "13i body \> div \> table \> tbody \> tr\:nth-child(1) \> td\:nth-child(2) \> table \> tbody \> tr \> td \> table \> tbody \> tr\:nth-child(6) \{ display\: none \!important\; \}" /usr/local/nagiosxi/html/includes/components/nagioscore/ui/css/extinfo.css
sed -i "14i body \> div \> table \> tbody \> tr\:nth-child(1) \> td\:nth-child(2) \> table \> tbody \> tr \> td \> table \> tbody \> tr\:nth-child(7) \{ display\: none \!important\; \}" /usr/local/nagiosxi/html/includes/components/nagioscore/ui/css/extinfo.css
sed -i "15i body \> div \> table \> tbody \> tr\:nth-child(1) \> td\:nth-child(2) \> table \> tbody \> tr \> td \> table \> tbody \> tr\:nth-child(8) \{ display\: none \!important\; \}" /usr/local/nagiosxi/html/includes/components/nagioscore/ui/css/extinfo.css

Re: To prevent users from setting disable notification,still

Posted: Fri Jun 12, 2020 2:26 pm
by jbrunkow
Very helpful! Thanks again, @hbouma. :D