listen 5667 script listen_nagios proc listen_nagios {idx} { control $idx nagios_event_log } proc nagios_event_log {idx arg} { global botnick nagios ignore_alert_hosts global shut_the_fuck_up if { ${arg} == "" } { return 0 } if {"${shut_the_fuck_up}" == 1} { return 0 } set alert_host [lindex $arg 5] foreach host ${ignore_alert_hosts} { if {${host} == ${alert_host}} { return 0 } } # putlog "(nagios) ${arg}" if {[onchan ${botnick} "#gentoo-infra" ] != 1} { return 0 } puthelp "NOTICE #gentoo-infra :(nagios) ${arg}" } set ignore_alert_hosts {} bind pub - !nagios pub:nagios set shut_the_fuck_up 0 proc pub:nagios {nick uhost hand chan arg} { global ignore_alert_hosts global shut_the_fuck_up if {$chan != "#gentoo-infra"} { return 0 } if {$arg == "off" } { set shut_the_fuck_up 1 set notifications "off" putserv "PRIVMSG $chan :Turnning $arg notifications (Note: all settings are lost on a rehash or a restart and will default to \[on\])" } elseif {$arg == "on" } { set shut_the_fuck_up 0 set notifications "on" putserv "PRIVMSG $chan :Turnning $arg notifications (Note: all settings are lost on a rehash or a restart and will default to \[on\])" } elseif {$arg == "status" } { if {$shut_the_fuck_up == 0} { set notifications "on" } else { set notifications "off" } putserv "PRIVMSG ${chan} :notifications are \[${notifications}\], and the following hosts are off: [join $ignore_alert_hosts]" return 1 } elseif {"[llength $arg]" == 2} { set machine "[lindex $arg 0]" set switch "[lindex $arg 1]" if {$switch == "off"} { #putlog "(nagios) single-host $machine off" lappend ignore_alert_hosts $machine } elseif {$switch == "on"} { #putlog "(nagios) single-host $machine on" set hostindex "[lsearch $ignore_alert_hosts $machine]" set ignore_alert_hosts [lreplace $ignore_alert_hosts $hostindex $hostindex] } putlog "(nagios) ignore_alert_hosts: [join $ignore_alert_hosts]" putserv "PRIVMSG $chan :Turning $switch notifications for host $machine (Note: all settings are lost on a rehash or a restart and will default to \[on\])" return 1 } }