sub alert_threshold_daily { my ($arg_ref) = @_; my $device = $arg_ref->{device}; my $child = $arg_ref->{child}; my $attr = $arg_ref->{attr}; my $lastn = $arg_ref->{lastn}; my $stat = $arg_ref->{stat}; my $state = $arg_ref->{state}; my $thr = $arg_ref->{thr}; # Use this group to keep track of alerts my $group = sprintf ("script_threshold_%s_%s_%s_%s", $lastn, $stat, $state, $thr); # Create group if it doesn't exist adb_send (sprintf ("add threshold group %s", $group)); if (adb_result (sprintf ("check %s %s %s = * * * * any group %s", $device, $child, $attr, $group)) eq "0") { # Record this alert in our group adb_send (sprintf ("assign * %s %s %s = %s", $device, $child, $attr, $group)); # Call another site script function to generate an alert alert_mail_threshold ($arg_ref); } else { #errlog ($ERR_DEBUG, "Duplicate alert: %s %s %s", $device, $child, $attr); } adb_flush (); } sub sched_1h_threshold_daily_reset { my $tm_ref = get_localtime (); # Run daily at 9am return if ($tm_ref->{hour} != 9); # Clear all threshold groups with names that begin with 'script_threshold_' errlog ($ERR_DEBUG, "Clearing script threshold groups"); adb_send ('empty threshold group /^script_threshold_/'); }