Forum Discussion

david_MARTINEAU's avatar
david_MARTINEAU
Icon for Nimbostratus rankNimbostratus
Apr 19, 2011

Health monitor to check File on server

Hi,

 

 

I would like to test the presence of file on y server. How can do this ?

 

I didn't view default monitor for this check. Scrpting ? If it's scripting, do you have an example ?

 

 

Regards

 

David

 

6 Replies

  • Hi David,

     

     

    What protocol do you want to use to check for the file?

     

     

    Do you want to check if the file exists or contains a specific string?

     

     

    Is this for LTM or GTM?

     

     

    Aaron
  • Hi Aaron,

     

     

    Thanks for your response.

     

     

    LTM Big IP 6900 v10.2

     

     

    I would check if the file exist.

     

    I test with monitor F5 SMB without success

     

     

    Thanks a lot

     

    Regards

     

    David

     

     

     

  • Hi David,

     

     

    There is an SMB monitor for LTM. You can see it in the LTM monitors section of the GUI when you click create. In looking at past cases, it seems that there might be a problem with it though.

     

     

    If you have any problems testing the inbuilt monitor, I'll upload a SMB/CIFS external monitor script to the monitoring codeshare today. I have a customer who needs this for GTM. I'll reply with a link once I'm done testing it.

     

     

    Aaron
  • Hi,

     

     

    There is a bug for default smb monitor in version 10.2.0

     

     

    You must create a script in /usr/bin/monitors/SMB_Monitor_custom with the rights 755

     

     

    And then add in local traffic/monitors menu an external script with the arguments "login" "password" "path"

     

     

     

    http://devcentral.f5.com/wiki/default.aspx/AdvDesignConfig/Windows_File_Share_Monitor_SMB_CIFS.html

     

     

    or this script

     

     

    !/bin/bash

     

     

    Save as /usr/bin/monitors/SMB_monitor_custom.bash

     

    Make executable using chmod 755 /usr/bin/monitors/SMB_monitor_custom.bash

     

     

    Use a custom shell command to perform a health check of the pool member IP address and port

     

     

    Log debug to local0.debug (/var/log/ltm)?

     

    Check if a variable named DEBUG exists from the monitor definition

     

    This can be set using a monitor variable DEBUG=0 or 1

     

     

    These arguments are supplied for all calls to that monitor

     

    command : smbget -u login -p pass -w domain smb://server/path_to_file

     

    $1 = IP_V6

     

    $2 = port

     

    $3 = login

     

    $4 = pass

     

    $5 = domain

     

    $6 = complete path to the (empty) file to check

     

     

    if [ -n "$DEBUG" ]

     

    then

     

    if [ $DEBUG -eq 1 ]; then logger -p local0.debug "EAV `basename $0`: \$DEBUG: $DEBUG"; fi

     

    else

     

    If the monitor config didn't specify debug, enable/disable it here

     

    DEBUG=0

     

    logger -p local0.debug "EAV `basename $0`: \$DEBUG: $DEBUG"

     

    fi

     

     

    Remove IPv6/IPv4 compatibility prefix (LTM passes addresses in IPv6 format)

     

    IP=`echo $1 | sed 's/::ffff://'`

     

     

    Save the port for use in the shell command

     

    PORT=$2

     

     

    Check if there is a prior instance of the monitor running

     

    pidfile="/var/run/`basename $0`.$IP.$PORT.pid"

     

    if [ -f $pidfile ]

     

    then

     

    kill -9 `cat $pidfile` > /dev/null 2>&1

     

    logger -p local0.error "EAV `basename $0`: exceeded monitor interval, needed to kill ${IP}:${PORT} with PID `cat $pidfile`"

     

    fi

     

     

    Add the current PID to the pidfile

     

    echo "$$" > $pidfile

     

     

    Debug

     

    if [ $DEBUG -eq 1 ]

     

    then

     

    Customize the log statement here if you want to log the command run

     

    logger -p local0.debug "EAV `basename $0`: Running for ${IP}:${PORT} using smbget -u "$3" -p "$4" -w "$5" -O -q smb://${IP}/$6"

     

    fi

     

     

    Send the request request and check the response

     

    smbget -u "$3" -p "$4" -w "$5" -O -q smb://${IP}/$6 >/dev/null 2>&1

     

     

    Check if the command ran successfully

     

    Note that any standard output will result in the script execution being stopped

     

    So do any cleanup before echoing to STDOUT

     

    if [ $? -eq 1 ]

     

    then

     

    if [ $DEBUG -eq 1 ]; then logger -p local0.debug "EAV `basename $0`: Succeeded for ${IP}:${PORT}"; fi

     

    echo "UP"

     

    else

     

    if [ $DEBUG -eq 1 ]; then logger -p local0.debug "EAV `basename $0`: Failed for ${IP}:${PORT}"; fi

     

    fi

     

     

    rm -f $pidfile

     

     

     

    Thx Hoolio for ur help

     

    David

     

     

  • Hi David,

     

     

    Sorry I forgot to post a link to the script here when I finished it. Did you open a case with F5 Support to determine there is a bug with the SMB monitor in 10.2.0? If so, what's the BZ ID?

     

     

    Did you have any problems with the Codeshare example? http://devcentral.f5.com/wiki/AdvDesignConfig.Windows-File-Share-Monitor-SMB-CIFS.ashx

     

     

    Thanks, Aaron
  • Hi Hoolio,

     

     

    I didn't open a case with F5 but with my integrator Télindus.

     

     

    I didn't have any pb with the codeshare example. It works good ;) ;)

     

     

    Thanks a lot

     

    David