Hi,
I just want to share the script I have developed to Blackout Email notifications via groovy script triggered by a Schedule Driven rule.
In our case, we we have a Rule scheduled to be triggered every day at 06:00 AM and at 18:00. The script then, will enable/disable email notifications by emptying&filling the Registry Variable value. During the weekends the value will always be empty.
The idea to develop this was taken from the next Knowledge Article:
How to blackout all of Foglight (155313)
https://support.quest.com/foglight-for-virtualization-enterprise-edition/kb/155313
and the the script is based on the reference code published in the next helpful article:
I hope you will find this useful:
/*
* The script below is used to enable/disable Email notifications by changing the Registry value.
* The script can be triggered via a Schedule Driven rule.
*/
regVar="mail.host"
// Introduce your mail server hostname
regVal="hostname"
regValempty=""
regSvc = server["RegistryService"]
regVariable = regSvc.getRegistryVariable(regVar)
regVariableDefault = regVariable.getGlobalDefault()
defaultValue = regVariableDefault.getDefaultValue()
// Get the name of the day
date = new Date().format("EEE")
// Disable Email notifications during the weekend
if ( (date == "Sat") || (date == "Sun") ) {
regVariableDefault.setDefaultValue(regValempty)
regSvc.saveRegistryVariable(regVariable)
"Changed Registry Variable '"+regVar+"' to '"+regValempty+"'."
}
else {
// Set mail server configuration
if (defaultValue == "") {
regVariableDefault.setDefaultValue(regVal)
regSvc.saveRegistryVariable(regVariable)
"Changed Registry Variable '"+regVar+"' to '"+regVal+"'."
}
// Remove mail server configuration
else {
regVariableDefault.setDefaultValue(regValempty)
regSvc.saveRegistryVariable(regVariable)
"Changed Registry Variable '"+regVar+"' to '"+regValempty+"'."
}
}