To prevent users from setting disable notification,still

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
ahm002
Posts: 16
Joined: Mon Jun 01, 2020 4:04 am

To prevent users from setting disable notification,still

Post 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.
User avatar
jbrunkow
Posts: 441
Joined: Fri Mar 13, 2020 10:45 am

Re: To prevent users from setting disable notification,still

Post 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).
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
hbouma
Posts: 483
Joined: Tue Feb 27, 2018 9:31 am

Re: To prevent users from setting disable notification,still

Post 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
User avatar
jbrunkow
Posts: 441
Joined: Fri Mar 13, 2020 10:45 am

Re: To prevent users from setting disable notification,still

Post 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>';
    }
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
hbouma
Posts: 483
Joined: Tue Feb 27, 2018 9:31 am

Re: To prevent users from setting disable notification,still

Post 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
User avatar
jbrunkow
Posts: 441
Joined: Fri Mar 13, 2020 10:45 am

Re: To prevent users from setting disable notification,still

Post by jbrunkow »

Very helpful! Thanks again, @hbouma. :D
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked