Transformation scripts link speed cisco

Started by jdowney, April 03, 2017, 07:40:56 PM

Previous topic - Next topic

jdowney

Good Evening,

I'm using the following SNMP  -  .1.3.6.1.2.1.2.2.1.5.10101 to pull down the link speed of a port on as Cisco switch. as we want to be alerted if any device is not running at 1 Gigabit. Unfortunately Cisco send this in different format.  Meaning if you have a Gigabit port and it is connected at 100 Mbps, you will get 100,000,000.  If it is connected at 10 Mbps, you will get 10,000,000, and if it is connected at Gigabit, you get 1,000,000,000.

So I've tried to create a transformation script to convert :-

if ($1 = 1000000000)
return "1 Gbps";
if ($1 = 100000000)
return "100 Mbps";
if ($1 = 10000000)
return "10 Mbps";


This does not seem to be working it always returns 1 Gbps regardless of what the value is. Any ideas on what I'm doing wrong?

Thanks in advance.

Victor Kirhenshtein

Hi,

you are using assignment operator (=) instead of equals operator (==). This script will work:



if ($1 == 1000000000)
return "1 Gbps";
if ($1 == 100000000)
return "100 Mbps";
if ($1 == 10000000)
return "10 Mbps";


Or you can simplify it a bit to


switch($1)
{
   case 1000000000: return "1 Gbps";
   case 100000000: return "100 Mbps";
   case 10000000: return "10 Mbps";
}


Best regards,
Victor

jdowney

Thanks this is perfect and resolved our issue.

John