From: Tim Bielawa <tbielawa@xxxxxxxxxx> These enable/disable all host and service notifications for the given host via one single command. --- func/minion/modules/nagios.py | 68 +++++++++++++++++++++++++++++++++++++++-- 1 files changed, 65 insertions(+), 3 deletions(-) diff --git a/func/minion/modules/nagios.py b/func/minion/modules/nagios.py index bb686b9..30eecd7 100644 --- a/func/minion/modules/nagios.py +++ b/func/minion/modules/nagios.py @@ -6,7 +6,7 @@ # general public license version 2. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# along with this program. If not, see <http://www.gnu.org/licenses/>. from certmaster.config import BaseConfig, Option import func_module @@ -60,10 +60,16 @@ class Nagios(func_module.FuncModule): # megafrobber host. nagios_server.disable_svc_notifications("megafrobber.mydomain.com", ["foo", "bar"]) + + # Stop all notifications for a host and the services on a host + nagios_server.silence_host("megafrobber.mydomain.com") + + # Enable all notifications for a host and the services on it + nagios_server.unsilence_host("megafrobber.mydomain.com") """ - version = "0.8.0" - api_version = "0.8.0" + version = "0.9.0" + api_version = "0.9.0" description = "Schedule downtime and handle notifications in Nagios." class Config(BaseConfig): @@ -579,3 +585,59 @@ class Nagios(func_module.FuncModule): return notif_str else: return "Fail: could not write to the command file" + + def silence_host(self, host): + """ + This command is used to prevent notifications from being sent + out for the host and all services on the specified host. + + This is equivalent to calling disable_host_svc_notifications + and disable_host_notifications. + + Syntax: DISABLE_HOST_SVC_NOTIFICATIONS;<host_name> + Syntax: DISABLE_HOST_NOTIFICATIONS;<host_name> + """ + + cmd = [ + "DISABLE_HOST_SVC_NOTIFICATIONS", + "DISABLE_HOST_NOTIFICATIONS" + ] + nagios_return = True + return_str_list = [] + for c in cmd: + notif_str = self._fmt_notif_str(c, host) + nagios_return = nagios_return and self._write_command(notif_str) + return_str_list.append(notif_str) + + if nagios_return: + return return_str_list + else: + return "Fail: could not write to the command file" + + def unsilence_host(self, host): + """ + This command is used to enable notifications for the host and + all services on the specified host. + + This is equivalent to calling enable_host_svc_notifications + and enable_host_notifications. + + Syntax: ENABLE_HOST_SVC_NOTIFICATIONS;<host_name> + Syntax: ENABLE_HOST_NOTIFICATIONS;<host_name> + """ + + cmd = [ + "ENABLE_HOST_SVC_NOTIFICATIONS", + "ENABLE_HOST_NOTIFICATIONS" + ] + nagios_return = True + return_str_list = [] + for c in cmd: + notif_str = self._fmt_notif_str(c, host) + nagios_return = nagios_return and self._write_command(notif_str) + return_str_list.append(notif_str) + + if nagios_return: + return return_str_list + else: + return "Fail: could not write to the command file" -- 1.7.4.4 _______________________________________________ Func-list mailing list Func-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/func-list