Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions snmpparser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,22 @@ while read oid val
do
if [ "$vars" = "" ]
then
vars="$oid = $val"
vars="$oid = $val \r\n"
else
vars="$vars, $oid = $val"
vars="$vars \r\n $oid = $val"
fi
done


[[ ${host} =~ ((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?) ]] && NUM=${BASH_REMATCH}
#[[ ${host} =~ ((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?) ]] && NUM=${BASH_REMATCH}
# printf "%(%H:%M:%S %Y/%m/%d)T ZBXTRAP $NUM\r\n$host $ip $vars\r\n">> /tmp/zabbix_traps.tmp
#echo trap: $1 $host $ip $vars

printf "ZBXTRAP $NUM\r\n$host $ip $vars\r\n">> /tmp/zabbix_traps.tmp


sourceAndDest=$(grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' <<< $ip)
stringarray=($sourceAndDest)
source=${stringarray[0]}
destination=${stringarray[1]}

printf "%(%H:%M:%S %Y/%m/%d)T ZBXTRAP $source \r\n $NUM \r\n $host \r\n $ip \r\n $vars\r\n">> /tmp/zabbix_traps.tmp