CodeShare
Have some code. Share some code.
cancel
Showing results for 
Search instead for 
Did you mean: 
Custom Alert Banner

Problem this snippet solves:

This example shows how to display a list of virtual servers that are currently marked as down.

Code :

modify script virtual_stat.tcl {

proc script::init { } {
}

proc getPartition { partition } {
        puts $partition
        flush stdout
        return [gets stdin]
#Choose the partition you want to be tested
}
proc script::run { } {

   set up ""
   set down ""
   set total 0
   set out 0
   set part [getPartition "Enter the partition you want to be tested"]
   tmsh::cd \/$part
   foreach { virtual } [tmsh::get_status /ltm virtual] {
       set total [expr { $total + 1 }]
       if { "available" ne [tmsh::get_field_value \
                   $virtual ".status.availability-state"] } {
           set out [expr { $out + 1 }]
           append down "    " [tmsh::get_name $virtual] "\n"
       }
   }

   set result "\n\n"
   append result $out " pools are down among " $total "\n Inactive Virtuals:\n\n"
   if { [string length $down] == 0 } {
       append result "    none\n"
   } else {
       append result $down
   }
   tmsh::display $result
}

proc script::help { } {
   tmsh::add_help "display the list of virtual servers that are down"
}

proc script::tabc { } {
   # if this function does nothing then tmsh will (visual) beep
}

}
Comments
jlarger
Cirrus
Cirrus

I'm trying to implement this tcl script in 11.6.3. Apparent the field names have changed. Can anyone tell me how to enumerate the current valid field values (or what this value has changed to)?

 

vs_stat.tcl: script failed to complete: can't eval proc: "script::run" field not present: ".status.availability-state" while executing "tmsh::get_field_value $virtual ".status.availability-state""

 

Lee_Sutcliffe
Nacreous
Nacreous

There is a typo in your codeshare

line 23: $virtual ".status.availability-state"] } {

the "." is throwing an error. should be

$virtual "status.availability-state"] } {

Version history
Last update:
‎10-Mar-2015 12:14
Updated by:
Contributors