Sometimes you need to alter the output you get from a command. Divide ResultsUsing awk you can get the values and divide them by a number (like 1000) and then print out the adjusted values. This command produces the default output of: Command:
./check_snmp -H ups01 -C box293 -o 1.3.6.1.4.1.318.1.1.1.4.2.3.0
Output:
SNMP OK - 13 | iso.3.6.1.4.1.318.1.1.1.4.2.3.0=13
Using awk I can change "13" to "0.013" Command: ./check_snmp -H ups01 -C box293 -o 1.3.6.1.4.1.318.1.1.1.4.2.3.0 | awk -F'|' '{split($1,array_left,"-");} {split($2,array_right,"=");} {print array_left[1]"- "array_left[2]/1000"|"array_right[1]"="array_right[2]/1000;}'
Output: SNMP OK - 0.013| iso.3.6.1.4.1.318.1.1.1.4.2.3.0=0.013
|