• BIGIP F5 iRule — Return Splash Page When No Members Are Available

    I wrote a iRule post located here, where I describe the essentials behind how beneficial iRules can be and the many use cases they have. I stumbled across a situation the other day for a client. This client had an F5 VIP load balancing 2 web servers of theirs. Now if those web servers for some reason are not available due to their healthcheck monitor failing, the users of that web site will receive a white page as the F5 will not proxy the traffic because there are no available pool members. I thought what if this was a big site, should users be left in the dark about a web site they use frequently when it’s not available? Then the idea of having the F5 LTM bounce back a well-formed splash page. This splash page would inform the user that the web site temporarily down, and if they believe this result is in error to contact their helpdesk.

    This situation can be remedied with a couple of lines in an iRule.

    when HTTP_REQUEST {
        #check if no members available
        if { [active_members [LB::server pool]] == 0 } {
           #create data variables with HTML content to send to client
           set httphost [string tolower [HTTP::host]]
           set data "

    $httphost

    NOTICE: Site Unavailable.

    If you believe you are receiving this message in error, contact your site administrator.

    " #send string HTTP::respond 200 content $data } #unset variables unset $httphost unset $data }

     

    Or:

    when HTTP_REQUEST {
       #check if no members available
       if { [active_members [LB::server pool]] == 0 } {
          HTTP::respond 200 content {
          
          Unavailable
          
          

    If you believe you are receiving this message in error, contact your site administrator.

    } #end of content block }

     
    This iRule uses the when HTTP_REQUEST event, and the HTTP::respond function. You could also use the HTTP::redirect function, however for something as small as a few lines, might as well have the F5 handle it directly.

    You could easily use links from other sources to make a more authentic looking page for your users.

  • Sendmail via VBscript

    This is a fun one, you can find numerous examples of this script all over the internet. Figured I’d share…

    
    Set objEmail = CreateObject("CDO.Message")
    objEmail.From = "from@domain.com"
    objEmail.To = "to@domain.com"
    objEmail.Subject = "My Subject"
    objEmail.Textbody = "Only use if you want to send a text email and not an HTML email"
    objEmail.HTMLBody = "" &_
    "
    " &_ "HTMLPretty Font lalallala " &_ "
    AIS-IUS" &_ "More pretty font HTML woot
    " objEmail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 objEmail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _ "{your mail server}" objEmail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = {mail server port} objEmail.Configuration.Fields.Update objEmail.Send

    This sends a pretty simple text email. If you want to send an HTML email simple craft your HTML in your favorite text editor and copy and past it to the line:

    
    
    objEmail.HTMLBody = "HTMLCODE" 
    

    Use &_ to append to the next line.

  • Batch removal of single file from server list….

    Since I posted how to deploys splash page using VBscript I figured it was only appropriate to post an article on how to remove it. Original post here.


    Requirements:
    1. VBscripting skills.
    2. splash.html (HTML file that will be removed).
    3. servers.txt (txt file listing each server to delete/remove the splash.html file from).
    4. Assumes you have appropriate user privileges.

    [Read More…]

  • Batch file copy using VBscripting…

    One of my jobs long ago was to maintain the process for deploying splash pages to MS terminal server users when planned maintenance would be performed. The creation of the splash HTML page was simply a white page with red and black text informing the user when the service would be down. Pretty basic right? The opportunity I saw was to automatically deploy it, rather than remoting in or remotely copying each splash file to each Terminal Server. I wrote the following script to copy the splash page to a list of servers identified in a txt file.“


    Requirements:
    1. VBscripting skills
    2. splash.html (HTML file that will be deployed)
    3. servers.txt (txt file listing each server to push the splash.html file to)
    4. Assumes you have appropriate user privileges.

    [Read More…]

↓