Remove 'disable notifications' quick action
Remove 'disable notifications' quick action
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
https://outsideit.net
Re: Remove 'disable notifications' quick action
Officially, no.
If you were feeling ambitious, In the following files:
You might comment out blocks of code that look like this:
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.
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
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>';
}
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
Re: Remove 'disable notifications' quick action
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:
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
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();
}
}
});
});
EDIT: updated the code to account for a thing
Former Nagios employee
https://www.mcapra.com/
https://www.mcapra.com/
-
SteveBeauchemin
- Posts: 524
- Joined: Mon Oct 14, 2013 7:19 pm
Re: Remove 'disable notifications' quick action
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. 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
To Disable Notifications for ALL services on a Host
for other actions, choose your poison... these URLs work.
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
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. 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
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
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%
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
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
@WillemDH, what do you think of the solutions provided? Ready to lock this up?