For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

jlarger's avatar
jlarger
Icon for Cirrus rankCirrus
Aug 21, 2018

tcl script error

I'm trying to implement the tcl script for server stats at https://devcentral.f5.com/codeshare?sid=314.

 

We're on 11.6.3.

 

The field value appears to be correct, since the output of show ltm virtual field-fmt includes status.availability-state for each virtual.

 

 

Can anyone advise me how to adjust the script?

 

The specific error message is:

 

virtual_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""

 

1 Reply

  • Line 23 has a '.' in front of the

    status.availability-state
    which is incorrect, remove it and it should work find

    Or copy from here:

    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
    }
    
    }