cancel
Showing results for 
Search instead for 
Did you mean: 
Nojan_Moshiri_4
Historic F5 Account

Problem this snippet solves:

This TMSH script quickly and easily creates a monitor for Citrix XenDesktop on an LTM. Instructions for importing and executing this TMSH script are found in the F5 deployment guide. The script takes four inputs, username, password, farm name and domain name , and then automatically calculates the POST Content-Length to create a customized, specialized monitor for your Citrix environment.

Code :

################## TMSH Script Loader ##################
## ## This code will load the script below onto a  ## ##
## ## BIG-IP: just copy this entire file to the    ## ##
## ## BIG-IP and run "sh this_file.tcl"            ## ##
                                                   ## ##
if cat $0 | grep -v '## ##$' | b merge - ; then    ## ##
   echo "TMSH script loaded successfully."         ## ##
   exit 0                                          ## ##
else                                               ## ##
   echo "Failed to load TMSH script."              ## ##
   exit -1                                         ## ##
fi                                                 ## ##
                                                   ## ##
################## TMSH Script Loader ##################

script create-citrix-xendesk-monitor.tcl {
proc script::help { } {
    tmsh::add_help "Create a monitor for Citrix XenDesktop version 5.x \n\
           "
}

proc script::run { } {
    if { $tmsh::argc < 4 } {
        puts "Requires four arguments:      you have not supplied via the command line. Switching to Interactive Mode.\n"
        set username [getFeedback "What is the username " "g.washington"]
        set password [getFeedback "What is the password?" "password"]
        set farm [getFeedback "What is the name of the Desktop Farm?" "Home"]
        set domain [getFeedback "What is the domain name?" "corpdomain"]
    }
    if { $tmsh::argc == 5 } {
        set username [lindex $tmsh::argv 1]
        set password [lindex $tmsh::argv 2]
        set farm [lindex $tmsh::argv 3]
        set domain [lindex $tmsh::argv 4]
    }

    set ver [tmsh::version]
   
# Create the Web Interface Monitor

    set wipostcontent "all$username$password$domain"

    set length [string length $wipostcontent]
    set escapes [regexp -all {\B} $wipostcontent]
    # Adding an extra 4 here for the \r\n\r\n automatically added by TMOS <= 10.1
    set contentlength [expr [string length $wipostcontent] - $escapes + 4]
    # For TMOS >= 10.2, we will now manually add these characters after calculating the content length
    if { $ver >= "10.2" } {
        append wipostcontent "\\r\\n\\r\\n"
    }

    set xmlbrokermonitor "POST /scripts/WPnBr.dll HTTP/1.1\\r\\nContent-Length: $contentlength\\r\\nContent-Type: text/xml\\r\\nConnection: close\\r\\nHost: citrix\\r\\n\\r\\n$wipostcontent"

    set monitor_type "http"
    set monitor_name "$farm-CitrixWICredentials"
    set monitor_interval "3"
    set monitor_timeout "19"
    set send '$xmlbrokermonitor'
    set receive 'ResponseValidateCredentials'
    set receive_disabled "failed-credentials"

    tmsh::create / ltm monitor $monitor_type $monitor_name interval $monitor_interval timeout $monitor_timeout send $send recv $receive recv-disable $receive_disabled
    puts "Created monitor $monitor_name, please attach to the Web Interface pool."

# Create the XenDesktop App Monitor

    set ddcpostcontent ""

    set length [string length $ddcpostcontent]
    set escapes [regexp -all {\B} $ddcpostcontent]
    # Adding an extra 4 here for the \r\n\r\n automatically added by TMOS <= 10.1
    set contentlength [expr [string length $ddcpostcontent] - $escapes + 4]
    # For TMOS >= 10.2, we will now manually add these characters after calculating the content length
    if { $ver >= "10.2" } {
        append ddcpostcontent "\\r\\n\\r\\n"
    }

    set desktopappmonitor "POST /scripts/WPnBr.dll HTTP/1.1\\r\\nContent-Length: $contentlength\\r\\nContent-Type: text/xml\\r\\nConnection: close\\r\\nHost: citrix\\r\\n\\r\\n$ddcpostcontent"

    set monitor_type "http"
    set monitor_name "$farm-CitrixDDCFarm"
    set monitor_interval "3"
    set monitor_timeout "19"
    set send '$desktopappmonitor'
set receive "$farm"

    tmsh::create / ltm monitor $monitor_type $monitor_name interval $monitor_interval timeout $monitor_timeout send $send recv $receive
    puts "Created monitor $monitor_name, please attach to the Desktop Delivery Controller pool."

}

proc getFeedback { question default } {
   puts -nonewline $question
   puts -nonewline " (Default: $default) "
   flush stdout
   set input [gets stdin]
   if { $input equals "" } {
      return $default
   } else {
      return $input
   }
}
}
Version history
Last update:
‎10-Mar-2015 11:54
Updated by:
Contributors