Transceiver DDMI stats via SNMP


Userlevel 2
I found several posts on this, most of the time with a final comment like "not YET available".
So when will it be? 🙂

This would be great to have on EOS and EXOS platforms.
I see that you can at least do webservice-kindof requests to EXOS, that alleviates the problem a little bit. But I still think this doesn't "abolish" SNMP. 🙂

Why we need this: We want to know what is happening on the fibers without having to drive there, take down the links, plug in the power meter, clean the fiber afterwards, drive to the other DC, same thing, etc. etc.

🙂

10 replies

Userlevel 5
While you're waiting for SNMP, would (for EXOS, I do not know EOS) this command help you?
# sh port transceiver information [detail]?

The short (no "detail") version's output looks like this:

Port Temp TxPower RxPower TxBiasCurrent Voltage-Aux1/ Voltage-Aux2
(Celsius) (dBm) (dBm) (mA) Vcc (Volts) (Volts)
================================================================================
1:1 32.59 -2.33 -2.42 5.84 3.36 N/A

Of course, SNMP queries would be nicer for easy graphing in cacti etc. And I have to admit, I haven't looked/tested if it might have sneaked in to SNMP yet.

Frank
Userlevel 2
Frank wrote:

While you're waiting for SNMP, would (for EXOS, I do not know EOS) this command help you?
# sh port transceiver information [detail]?

The short (no "detail") version's output looks like this:

Port Temp TxPower RxPower TxBiasCurrent Voltage-Aux1/ Voltage-Aux2
(Celsius) (dBm) (dBm) (mA) Vcc (Volts) (Volts)
================================================================================
1:1 32.59 -2.33 -2.42 5.84 3.36 N/A

Of course, SNMP queries would be nicer for easy graphing in cacti etc. And I have to admit, I haven't looked/tested if it might have sneaked in to SNMP yet.

Frank

Thanks. I know it exists in the CLI. But that is not very interesting. 🙂
Userlevel 2
Wouldn't be possible to do something by scripting with python? While Extreme don't implemented that yet...
Userlevel 2
Julian Eble wrote:

Wouldn't be possible to do something by scripting with python? While Extreme don't implemented that yet...

Sure there are workarounds. My point is: there are millions of things in the MIB, some of which probably noone ever uses. Now I have something that would actually make sense 🙂
Userlevel 7
Here's the thread with information on how to get this information from the switch via a JSON API.
https://community.extremenetworks.com/extreme/topics/get-info-by-snmp-about-ports-trainciever-inform...

It can be tweaked to get specific items rather than the entire output of the command. Adding SNMP support is on "the list" but I don't know its current status.
Userlevel 2
Drew C. wrote:

Here's the thread with information on how to get this information from the switch via a JSON API.
https://community.extremenetworks.com/extreme/topics/get-info-by-snmp-about-ports-trainciever-inform...

It can be tweaked to get specific items rather than the entire output of the command. Adding SNMP support is on "the list" but I don't know its current status.

Yup, but that's EXOS only.
Userlevel 2
If you could at least do:

root@nms:~$ ssh rw@1.2.3.4 show transceiver
rw@1.2.3.4's password:
Write failed: Broken pipe

Do we really have to work with "expect"??
Userlevel 2
FWIW Here is an expect script for the show transceiver command

I highly recommand using the ro login for the switch!!

#! /usr/bin/expect

set host [lrange $argv 0 0]
set port [lrange $argv 1 1]

spawn ssh ro@$host
expect {
{word:?} {send "password\r"}
}
expect {
{)->} {send "show port transceiver $port\r"}
}
expect {
{)->} {send "exit\r"}
}
exit[/code]
And here is the wrapper in bash

#!/bin/bash

if [ $# -ne 2 ]; then
echo "Syntax: $0 host port"
exit 1
fi

TMPF=/dev/shm/$0.$1.$2.tmp
rm -f $TMP

host=$1
port=$2

/usr/local/nagios/libexec/show-transceiver.xp $1 $2 > $TMPF

VOLT=$(awk '{if ($2=="Voltage") print $4}' $TMPF)
TEMP=$(awk '{if ($2=="Temp") print $4}' $TMPF)
TX=$(awk '{if ($2=="TX" && $4=="(dBm)") print $5}' $TMPF)
RX=$(awk '{if ($2=="RX" && $4=="(dBm)") print $5}' $TMPF)

echo "$TEMP degrees C, $VOLT Volt, $RX dBm RX, $TX dBm TX|v=$VOLT t=$TEMP tx=$RX rx=$TX"[/code]
This can be used as Nagios plugin (if you add thresholds and appropriate return codes).

Have fun 🙂
Userlevel 2
jeronimo wrote:

FWIW Here is an expect script for the show transceiver command

I highly recommand using the ro login for the switch!!

#! /usr/bin/expect

set host [lrange $argv 0 0]
set port [lrange $argv 1 1]

spawn ssh ro@$host
expect {
{word:?} {send "password\r"}
}
expect {
{)->} {send "show port transceiver $port\r"}
}
expect {
{)->} {send "exit\r"}
}
exit[/code]
And here is the wrapper in bash

#!/bin/bash

if [ $# -ne 2 ]; then
echo "Syntax: $0 host port"
exit 1
fi

TMPF=/dev/shm/$0.$1.$2.tmp
rm -f $TMP

host=$1
port=$2

/usr/local/nagios/libexec/show-transceiver.xp $1 $2 > $TMPF

VOLT=$(awk '{if ($2=="Voltage") print $4}' $TMPF)
TEMP=$(awk '{if ($2=="Temp") print $4}' $TMPF)
TX=$(awk '{if ($2=="TX" && $4=="(dBm)") print $5}' $TMPF)
RX=$(awk '{if ($2=="RX" && $4=="(dBm)") print $5}' $TMPF)

echo "$TEMP degrees C, $VOLT Volt, $RX dBm RX, $TX dBm TX|v=$VOLT t=$TEMP tx=$RX rx=$TX"[/code]
This can be used as Nagios plugin (if you add thresholds and appropriate return codes).

Have fun :)

I just noticed that you might want to implement the wrapper in a more sophisticated language than a shell script because (at least when using bash) it won't even work with decimals.... Anyway here is my current version of a nagios plugin

#!/bin/bash

if [ $# -ne 2 ]; then
echo "Syntax: $0 host port"
exit 1
fi

STATE_UNKN=3
STATE_CRIT=2
STATE_WARN=1
STATE_OK=0

TMPF=/dev/shm/$(basename $0).$1.$2.tmp
rm -f $TMP

host=$1
port=$2

/usr/local/nagios/libexec/show-transceiver.xp $1 $2 > $TMPF

VOLT=$(awk '{if ($2=="Voltage") print $4}' $TMPF)
VOLTHW=$(awk '{if ($2=="Voltage") print $7}' $TMPF)
VOLTLW=$(awk '{if ($2=="Voltage") print $8}' $TMPF)
VOLTHC=$(awk '{if ($2=="Voltage") print $6}' $TMPF)
VOLTLC=$(awk '{if ($2=="Voltage") print $9}' $TMPF)

TEMP=$(awk '{if ($2=="Temp") print $4}' $TMPF)
TEMPHW=$(awk '{if ($2=="Temp") print $7}' $TMPF)
TEMPLW=$(awk '{if ($2=="Temp") print $8}' $TMPF)
TEMPHC=$(awk '{if ($2=="Temp") print $6}' $TMPF)
TEMPLC=$(awk '{if ($2=="Temp") print $9}' $TMPF)

TX=$(awk '{if ($2=="TX" && $4=="(dBm)") print $5}' $TMPF)
TXHW=$(awk '{if ($2=="TX" && $4=="(dBm)") print $8}' $TMPF)
TXLW=$(awk '{if ($2=="TX" && $4=="(dBm)") print $9}' $TMPF)
TXHC=$(awk '{if ($2=="TX" && $4=="(dBm)") print $7}' $TMPF)
TXLC=$(awk '{if ($2=="TX" && $4=="(dBm)") print $10}' $TMPF)

RX=$(awk '{if ($2=="RX" && $4=="(dBm)") print $5}' $TMPF)
RXHW=$(awk '{if ($2=="RX" && $4=="(dBm)") print $8}' $TMPF)
RXLW=$(awk '{if ($2=="RX" && $4=="(dBm)") print $9}' $TMPF)
RXHC=$(awk '{if ($2=="RX" && $4=="(dBm)") print $7}' $TMPF)
RXLC=$(awk '{if ($2=="RX" && $4=="(dBm)") print $10}' $TMPF)

STATE=$STATE_UNKN

function set_state() {
# only set it if it gets worse... (UNKNOWN is an exception)
if [ $STATE -lt $1 -o $STATE -eq $STATE_UNKN ]; then
STATE=$1
fi
}

for i in VOLT TEMP TX RX; do
# it=i*1000 without decimals
# must use (/1) for it to consider scale=0
it=$(echo "scale=0; ${!i}*1000/1" | bc)
# get content of variable "${i}XXX"
LC="$(eval "echo \${$(echo ${i}LC)}")"
LW="$(eval "echo \${$(echo ${i}LW)}")"
HC="$(eval "echo \${$(echo ${i}HC)}")"
HW="$(eval "echo \${$(echo ${i}HW)}")"
# bash can't do float
# must use (/1) for it to consider scale=0
LC=$(echo "scale=0; $LC*1000/1" | bc)
LW=$(echo "scale=0; $LW*1000/1" | bc)
HC=$(echo "scale=0; $HC*1000/1" | bc)
HW=$(echo "scale=0; $HW*1000/1" | bc)
if [ $it -le $LC ]; then
set_state $STATE_CRIT
prob_crit="$prob_crit ${i}:LOW"
elif [ $it -le $LW ]; then
set_state $STATE_WARN
prob_warn="$prob_warn ${i}:LOW"
fi
if [ $it -ge $HC ]; then
set_state $STATE_CRIT
prob_crit="$prob_crit ${i}:HIGH"
elif [ $it -ge $HW ]; then
set_state $STATE_WARN
prob_warn="$prob_warn ${i}:HIGH"
fi
done

set_state $STATE_OK

case $STATE in
$STATE_CRIT)
STATUS="CRITICAL"
;;
$STATE_WARN)
STATUS="WARN"
;;
$STATE_OK)
STATUS="OK"
;;
😉
STATE=$STATE_UNKN
STATUS="UNKN"
;;
esac

if [ ! -z "$prob_warn" ]; then
STATUS="$STATUS $prob_warn"
fi
if [ ! -z "$prob_crit" ]; then
STATUS="$STATUS $prob_crit"
fi

echo "$STATUS: $TEMP degrees C, $VOLT Volt, $RX dBm RX, $TX dBm TX|v=$VOLT t=$TEMP tx=$RX rx=$TX"

chown nagios: $TMPF

exit $STATE
[/code]Example:

# ./show-transceiver.sh 1.2.3.4 tg.1.22
OK: 36 degrees C, 3.237 Volt, -9.281 dBm RX, -2.000 dBm TX|v=3.237 t=36 tx=-9.281 rx=-2.000

[/code]I know there are inefficient parts in it. Don't tell me 🙂
Userlevel 2
jeronimo wrote:

FWIW Here is an expect script for the show transceiver command

I highly recommand using the ro login for the switch!!

#! /usr/bin/expect

set host [lrange $argv 0 0]
set port [lrange $argv 1 1]

spawn ssh ro@$host
expect {
{word:?} {send "password\r"}
}
expect {
{)->} {send "show port transceiver $port\r"}
}
expect {
{)->} {send "exit\r"}
}
exit[/code]
And here is the wrapper in bash

#!/bin/bash

if [ $# -ne 2 ]; then
echo "Syntax: $0 host port"
exit 1
fi

TMPF=/dev/shm/$0.$1.$2.tmp
rm -f $TMP

host=$1
port=$2

/usr/local/nagios/libexec/show-transceiver.xp $1 $2 > $TMPF

VOLT=$(awk '{if ($2=="Voltage") print $4}' $TMPF)
TEMP=$(awk '{if ($2=="Temp") print $4}' $TMPF)
TX=$(awk '{if ($2=="TX" && $4=="(dBm)") print $5}' $TMPF)
RX=$(awk '{if ($2=="RX" && $4=="(dBm)") print $5}' $TMPF)

echo "$TEMP degrees C, $VOLT Volt, $RX dBm RX, $TX dBm TX|v=$VOLT t=$TEMP tx=$RX rx=$TX"[/code]
This can be used as Nagios plugin (if you add thresholds and appropriate return codes).

Have fun :)

Oh and remember to do an SSH as the nagios user to the switch once because it wants you to validate the host key.

Reply