sub alert_threshold_send_syslog { my ($arg_ref) = @_; my $msg; my $thr = $arg_ref->{thr}; my $val = $arg_ref->{val}; # Modify the following parameters. You must set $dest_ip to enable this script. # Refer to the Site Script documentation at www.akips.com for details my $dest_ip = ""; # IP address of remote syslog collector my $priority = "error"; my $facility = "local3"; # Get the IP address of the device which triggered the alert my $dev_ip = adb_result (sprintf ("get %s sys SNMP.ipaddr", $arg_ref->{device})); my $time_str = strftime ("%Y-%m-%d %H:%M:%S%z", localtime ($arg_ref->{tt})); #my $time_utc = strftime ("%Y-%m-%d %H:%M:%SZ", gmtime ($arg_ref->{tt})); # Parse the MIB and object which triggered the alert my ($mib, $obj) = split (/\./m, $arg_ref->{attr}, 2); # The following formats the message similar to Threshold Alerting email messages. if ($mib eq "IF-MIB") { given ($obj) { when (/if.*BitRate/m) { $thr = int_ifspeed ($thr); $val = int_ifspeed ($val); } when (/if.*Util/m) { $thr = int_util ($thr); $val = int_util ($val); } default { $thr = int_metric ($thr); $val = int_metric ($val); } } trim $val; $msg = sprintf ("%s %s %s %s %s %s %s %s %s %s %s", $time_str, $arg_ref->{alias} || "", $arg_ref->{device}, $dev_ip, $arg_ref->{child}, # interface name $arg_ref->{descr}, $arg_ref->{lastn}, $arg_ref->{stat}, # avg or total $val, # calculated value $arg_ref->{state}, # above or below $thr); # threshold value } else { $msg = sprintf ("%s %s %s %s %s %s %s %s %s %s", $time_str, $arg_ref->{alias} || "", $arg_ref->{device}, $dev_ip, $arg_ref->{descr}, $arg_ref->{lastn}, $arg_ref->{stat}, # avg or total $val, # calculated value $arg_ref->{state}, # above or below $thr); # threshold value } # Send the syslog message if ($dest_ip ne "") { syslog ({ ipaddr => $dest_ip, priority => $priority, facility => $facility, message => $msg, }); # Send message to 'alert' log for debugging purposes #errlog ($ERR_ALERT, "syslog $dest_ip $priority $facility $msg"); } }