Fixed script execution after throttling interval.
@@ -85,7 +85,7 @@ import scala.util.control.Breaks._
* 2) Alert condition as string.
* 3, ...) Values of alert conditions ordered as in alert command.
* -i
- * Configure alert notification minimal throttling interval in seconds. Default is 60 seconds.
+ * Configure alert notification minimal throttling interval in seconds. Default is 0 seconds.
*
* -<metric>
* This defines a mnemonic for the metric that will be measured:
@@ -267,7 +267,7 @@ class VisorAlertCommand extends VisorConsoleCommand {
var script: Option[String] = None
val conditions = mutable.ArrayBuffer.empty[VisorAlertCondition]
var freq = DFLT_FREQ
- var interval = DFLT_FREQ
+ var interval = 0L
try {
args.foreach(arg => {
@@ -653,9 +653,11 @@ class VisorAlertCommand extends VisorConsoleCommand {
private def executeAlertScript(alert: VisorAlert, node: ClusterNode, values: Seq[String]) {
val n = alert.notification
+ if (n.notified && System.currentTimeMillis() - n.notifiedTime < n.throttleInterval)
+ return
+
try {
n.script.foreach(script => {
- if (!n.notified && (n.notifiedTime < 0 || (System.currentTimeMillis() - n.notifiedTime) > n.throttleInterval)) {
val scriptFile = new File(script)
if (!scriptFile.exists())
@@ -671,7 +673,6 @@ class VisorAlertCommand extends VisorConsoleCommand {
n.notifiedTime = System.currentTimeMillis()
n.notified = true
- }
})
}
catch {
@@ -865,7 +866,7 @@ object VisorAlertCommand {
" 2) Alert condition as string.",
" 3, ...) Values of alert conditions ordered as in alert command."
),
- "-i" -> "Configure alert notification minimal throttling interval in seconds. Default is 60 seconds.",
+ "-i" -> "Configure alert notification minimal throttling interval in seconds. Default is 0 seconds.",
"-<metric>" -> Seq(
"This defines a mnemonic for the metric that will be measured:",
"",
