stack count

A long time ago I wrote a probe to determine if a Cisco stack of switches was functioning normally and that all the stack cables are plugged in the trouble with it is it is very time consuming since it would go through so many if statements. There is really no good way to handle this since you have to individually check stack cables. What I have decided is once in a while I will change this function to the previous version to assess if there are any stack cable issues and use the trimmed down one at all other times. So to reduced the number of statements only test stack ports if the switch says it is broken… but if a stack cable is not plugged in that is not detected as a stack error. So this reduces it to just detects a broken switch in a stack.

function: swinstk
if(array_size(oid_column(“1.3.6.1.4.1.9.9.500.1.2.1.1.6”,10,5))=9, if(sum(oid_column(“1.3.6.1.4.1.9.9.500.1.2.1.1.6”,10,5))=36,1,stk9prts()),
if(array_size(oid_column(“1.3.6.1.4.1.9.9.500.1.2.1.1.6”,10,5))=8, if(sum(oid_column(“1.3.6.1.4.1.9.9.500.1.2.1.1.6”,10,5))=32,1,stk8prts()),
if(array_size(oid_column(“1.3.6.1.4.1.9.9.500.1.2.1.1.6”,10,5))=7, if(sum(oid_column(“1.3.6.1.4.1.9.9.500.1.2.1.1.6”,10,5))=28,1,stk7prts()),
if(array_size(oid_column(“1.3.6.1.4.1.9.9.500.1.2.1.1.6”,10,5))=6, if(sum(oid_column(“1.3.6.1.4.1.9.9.500.1.2.1.1.6”,10,5))=24,1,stk6prts()),
if(array_size(oid_column(“1.3.6.1.4.1.9.9.500.1.2.1.1.6”,10,5))=5, if(sum(oid_column(“1.3.6.1.4.1.9.9.500.1.2.1.1.6”,10,5))=20,1,stk5prts()),
if(array_size(oid_column(“1.3.6.1.4.1.9.9.500.1.2.1.1.6”,10,5))=4, if(sum(oid_column(“1.3.6.1.4.1.9.9.500.1.2.1.1.6”,10,5))=16,1,stk4prts()),
if(array_size(oid_column(“1.3.6.1.4.1.9.9.500.1.2.1.1.6”,10,5))=3, if(sum(oid_column(“1.3.6.1.4.1.9.9.500.1.2.1.1.6”,10,5))=12,1,stk3prts()),
if(array_size(oid_column(“1.3.6.1.4.1.9.9.500.1.2.1.1.6”,10,5))=2, if(sum(oid_column(“1.3.6.1.4.1.9.9.500.1.2.1.1.6”,10,5))=8 ,1,stk2prts()),
if(array_size(oid_column(“1.3.6.1.4.1.9.9.500.1.2.1.1.6”,10,5))=1, if(sum(oid_column(“1.3.6.1.4.1.9.9.500.1.2.1.1.6”,10,5))=4 ,1,“Switch needs attention”),
“Problem reading Any stack”
)))))))))