Skip to content

Instantly share code, notes, and snippets.

@donalod
Last active August 29, 2015 14:06
Show Gist options
  • Save donalod/7ad7dddab35289767830 to your computer and use it in GitHub Desktop.
Save donalod/7ad7dddab35289767830 to your computer and use it in GitHub Desktop.
LogMashJuniperPoETelemetry
#!/usr/bin/env bash
# This script takes the input from a manual PoE dump of telemetries of interfaces on a Juniper EX2200.
# As the date command is doing a parsing function that only GNU date can do, this bit must be
# run on linux or some such and not OSX. Your log file name in this example would be 'p'.
while read line; do
#echo "$line"
cleanline=$(echo $line|tr -s ' '|cut -f2,3,5,6 -d" ")
#echo "$cleanline"
date=$(echo $cleanline| cut -f1 -d" ")
#echo $date
reversedate=$(echo $date|awk -F'-' '{print $3"-"$1"-"$2}')
#echo $reversedate
time=$(echo $cleanline| cut -f2 -d" ")
#echo $time
watts=$(echo $cleanline| cut -f3 -d" " | sed 's/.$//')
#echo $watts
volts=$(echo $cleanline| cut -f4 -d" " | sed 's/.$//')
#echo $volts
timezone="-1000"
newline=$(/bin/date "+%Y-%m-%d_%H:%M:%S" -d "${reversedate} ${time} ${timezone}"| sed 's/:/\./g')
echo $newline $watts $volts
done < p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment