Remove 'disable notifications' quick action

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Remove 'disable notifications' quick action

Post by WillemDH »

I'm a bit tired of people using the 'disable notification' quick action. is there some way to remove this "Disable notifications" quick action?
Nagios XI 5.8.1
https://outsideit.net
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Remove 'disable notifications' quick action

Post by mcapra »

Officially, no.

If you were feeling ambitious, In the following files:

Code: Select all

/usr/local/nagiosxi/html/includes/components/xicore/ajaxhelpers-servicestatus.inc.php
/usr/local/nagiosxi/html/includes/components/xicore/ajaxhelpers-hoststatus.inc.php
You might comment out blocks of code that look like this:

Code: Select all

#ajaxhelpers-hoststatus.inc.php line 609
            // 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>';
            }

#ajaxhelpers-servicestatus.inc.php line 766
            // 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>';
            }
Though those alterations are likely to be overwritten on upgrades. You could probably write a custom JS includes file to achieve a similar effect and have more staying power.
Former Nagios employee
https://www.mcapra.com/
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Remove 'disable notifications' quick action

Post by mcapra »

Javascript is actually a much more elegant solution in my opinion. With the understanding that I threw this together in a few minutes with minimal testing, you could try throwing this in a .js file and uploading it via the Custom Includes component:

Code: Select all

$(document).ajaxComplete(function () {
	$("div.service_state_quick_actions").children("li").each(function () {
		if ($(this).find("a").attr("onclick")) {
			if ($(this).find("a").attr("onclick").match(/("cmd":23)/)) {
				$(this).hide();
			}
		}
	});
	$("div.host_state_quick_actions").children("li").each(function () {
		if ($(this).find("a").attr("onclick")) {
				if ($(this).find("a").attr("onclick").match(/("cmd":25)/)) {
				$(this).hide();
			}
		}	
	});
});

We have to use ajaxComplete as the trigger unfortunately since the page is constantly updating which regenerates the quick actions.

EDIT: updated the code to account for a thing
Former Nagios employee
https://www.mcapra.com/
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

Re: Remove 'disable notifications' quick action

Post by SteveBeauchemin »

Willem,

Suggestion - edit the php and make the ability to disable notifications for 'Everyone' just go away. As suggested already.

Then - put them back - but just for you or whoever you designate...

I like the disable all service notifications feature that Nagios core provided. Since I missed it so much I added it back. As a Quick Action.
These open a separate tab, make your selection, and close the tab.
action3.PNG
Disable the notification feature that you don't want everyone to have. Set up a Quick Action and allow the specific users that you decide should have it.

I have some notes I took from when I did this. go to Admin --> Manage Components --> Actions -- Edit Settings
At the bottom, fill in a new action.
To Enable Notifications for ALL services on a Host

Code: Select all

Object Type: Host
Host: /.*/
Service: [blank]
Hostgroup: [blank]
Servicegroup: [blank]

Action Type: URL
URL / Command: http://[Nagios Host]/nagiosxi/includes/components/nagioscore/ui/cmd.php?cmd_typ=28&host=%host%
Target: _blank
Action Text: Enable Notifications for all Services on the host

On the far right - choose Custom - and you control who can see and use the command
To Disable Notifications for ALL services on a Host

Code: Select all

Object Type: Host
Host: /.*/
Service: [blank]
Hostgroup: [blank]
Servicegroup: [blank]

Action Type: URL
URL / Command: http://[Nagios Host]/nagiosxi/includes/components/nagioscore/ui/cmd.php?cmd_typ=29&host=%host%
Target: _blank
Action Text: Disable Notifications for all Services on the host

On the far right - choose Custom - and you control who can see and use the command
for other actions, choose your poison... these URLs work.

Code: Select all

turn off Service Notify
http://[Nagios Host]/nagiosxi/includes/components/nagioscore/ui/cmd.php?cmd_typ=23&host=%host%&service=%servicedisplayname%
turn on Service Notify
http://[Nagios Host]/nagiosxi/includes/components/nagioscore/ui/cmd.php?cmd_typ=22&host=%host%&service=%servicedisplayname%

turn off host notify
http://[Nagios Host]/nagiosxi/includes/components/nagioscore/ui/cmd.php?cmd_typ=25&host=%host%
turn on host notify
http://[Nagios Host]/nagiosxi/includes/components/nagioscore/ui/cmd.php?cmd_typ=24&host=%host%
Just keep in mind that if you converted your Nagios instance to use SSL, then remember to change these http to https.
The URL from Nagios Core uses cmd.cgi, but I choose to use the Nagios XI cmd.php instead.

I gotta say, that Nagios is some flexible system huh.

Steve B
You do not have the required permissions to view the files attached to this post.
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Remove 'disable notifications' quick action

Post by dwhitfield »

@WillemDH, what do you think of the solutions provided? Ready to lock this up?
Locked