Transceiver DDMI stats via SNMP
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
‎12-14-2016 09:38 AM
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.
:)
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 10
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
‎12-20-2016 11:55 AM
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
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"
This can be used as Nagios plugin (if you add thresholds and appropriate return codes).
Have fun 
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
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"
This can be used as Nagios plugin (if you add thresholds and appropriate return codes).
Have fun 
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
‎12-20-2016 11:55 AM
Oh and remember to do an SSH as the nagios user to the switch once because it wants you to validate the host key.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
‎12-20-2016 11:55 AM
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
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
I know there are inefficient parts in it. Don't tell me 🙂
#!/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
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
I know there are inefficient parts in it. Don't tell me 🙂
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
‎12-16-2016 09:34 AM
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"??
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"??
