Forum Discussion

VladT's avatar
Icon for Nimbostratus rankNimbostratus
Feb 27, 2023

External monitor for SFTP

Hello F5 Community,

I am trying to set up an external monitor for SFTP and i need some help to make it work.
For authentication i specified the path for the private key.
I am trying to run the sftp with -b option and specifing the path for the command i want to run after authentication.
In the cmd file i added the version command.

May I ask you to have a look and advise what i am missing here in order to make it work?

# these arguments supplied automatically for all external pingers:
# $1 = IP (::ffff:nnn.nnn.nnn.nnn notation or hostname)
# $2 = port (decimal, host byte order)
# $3 and higher = additional arguments
# $MONITOR_NAME = name of the monitor


# Remove the IPv6/IPv4 compatibility prefix
IP=`echo $1 | sed 's/::ffff://'`



# Name of the pidfile

# Send signal to the process group to kill our former self and any children
# as external monitors are run with SIGHUP blocked
if [ -f $pidfile ]
kill -9 -`cat $pidfile` > /dev/null 2>&1

echo "$$" > $pidfile

output=$(sftp -i /config/filestore/files_d/Common_d/certificate_key_d/:Common:SFTP-TEST-unprotected_66821_1 -o StrictHostKeyChecking=no -b /config/filestore/files_d/Common_d/certificate_key_d/cmd $user@$IP)

if echo "$output" | grep -q "version 3"; then
echo "UP"

rm -f "${pidfile}"

2 Replies

  • Can you run this command manually and share the output?

  • VladT's avatar
    Icon for Nimbostratus rankNimbostratus

    Found the issue.
    When trying to run the script manually, noticed this error : bad interpreter: No such file or directory
    Used this command < sed -i -e 's/\r$//'>  to remove the DOS line endings from Text files and the external monitor is working now

    Thank you very much
    Wish you a nice day