Forum Discussion

mmelber14_62984's avatar
mmelber14_62984
Icon for Nimbostratus rankNimbostratus
Apr 02, 2014

External Health monitor

Hi,

 

I need some assistance creating shell script for use in a external health monitor. I do to have much experience in creating scripts so if someone could either assist or point me to a good reference that would be a start.

 

We are running an internal app that utilizes msql (proprietary sql language) and I want to create a script that can be called and depending upon the outcome will the service show up or down.

 

echo "remote("") {list library version}" | msql -utgbmin -wtacb201112 -S ?s

 

The service should be marked up if Executing... Success! is shown and it should be marked down if Executing... Error! is shown. I have opened a ticket with websupport and they do not assist with this type of request is all I received back!

 

Your help is appreciated.

 

Thanks, Megan

 

  • Hi Megan,

    LTM health monitors run on you BigIP and communicate with remote services over the network. What you have provided looks like something which runs on a remote box. To be able to use the output from that command to mark a service up or down, you need to get the output to your BigIP. Two solutions come to mind:

    1. On the msql host, create a file with your commands in it, eg mytest. Then create a listener with netcat to run it when it receives a connection from the network

      while : ; do nc -vl -e mytest 1234; done

      Now you can use a TCP monitor on the F5 which sends to port 1234 (in my example), and expects "Success" in the result. You will need to consider how to keep that process started and running on the msql box, and there are probably opportunities for DOS or other security issues.

    2. Create the bash script on your msql box as before. On the F5, create an external monitor (plenty of examples on DevCentral) which uses ssh to execute this. This is more complicated (though is not hard to implement), uses more system resources on both the F5 and your msql box, but more secure, and I suspect more robust too.

    Of course, I might have completely misunderstood your requirement, but I hope that helps.

  • uni's avatar
    uni
    Icon for Altostratus rankAltostratus

    Hi Megan,

    LTM health monitors run on you BigIP and communicate with remote services over the network. What you have provided looks like something which runs on a remote box. To be able to use the output from that command to mark a service up or down, you need to get the output to your BigIP. Two solutions come to mind:

    1. On the msql host, create a file with your commands in it, eg mytest. Then create a listener with netcat to run it when it receives a connection from the network

      while : ; do nc -vl -e mytest 1234; done

      Now you can use a TCP monitor on the F5 which sends to port 1234 (in my example), and expects "Success" in the result. You will need to consider how to keep that process started and running on the msql box, and there are probably opportunities for DOS or other security issues.

    2. Create the bash script on your msql box as before. On the F5, create an external monitor (plenty of examples on DevCentral) which uses ssh to execute this. This is more complicated (though is not hard to implement), uses more system resources on both the F5 and your msql box, but more secure, and I suspect more robust too.

    Of course, I might have completely misunderstood your requirement, but I hope that helps.

    • uni's avatar
      uni
      Icon for Altostratus rankAltostratus
      I realised after I sent that you don't necessarily need to worry about the while loop, you may be able to use "nc -kl -e myprog 1234" and it will keep listening for more connections.
    • mmelber14_62984's avatar
      mmelber14_62984
      Icon for Nimbostratus rankNimbostratus
      Hi uni! Thanks for taking the time to write back. Option 1 sounds more like a workable option in my scenario. I am going to try option 1 and bring that up as a compromise with my unix guys that support that box. I will update this post when I have more information! -Megan
  • Hi Megan,

    LTM health monitors run on you BigIP and communicate with remote services over the network. What you have provided looks like something which runs on a remote box. To be able to use the output from that command to mark a service up or down, you need to get the output to your BigIP. Two solutions come to mind:

    1. On the msql host, create a file with your commands in it, eg mytest. Then create a listener with netcat to run it when it receives a connection from the network

      while : ; do nc -vl -e mytest 1234; done

      Now you can use a TCP monitor on the F5 which sends to port 1234 (in my example), and expects "Success" in the result. You will need to consider how to keep that process started and running on the msql box, and there are probably opportunities for DOS or other security issues.

    2. Create the bash script on your msql box as before. On the F5, create an external monitor (plenty of examples on DevCentral) which uses ssh to execute this. This is more complicated (though is not hard to implement), uses more system resources on both the F5 and your msql box, but more secure, and I suspect more robust too.

    Of course, I might have completely misunderstood your requirement, but I hope that helps.

    • uni_87886's avatar
      uni_87886
      Icon for Cirrostratus rankCirrostratus
      I realised after I sent that you don't necessarily need to worry about the while loop, you may be able to use "nc -kl -e myprog 1234" and it will keep listening for more connections.
    • mmelber14_62984's avatar
      mmelber14_62984
      Icon for Nimbostratus rankNimbostratus
      Hi uni! Thanks for taking the time to write back. Option 1 sounds more like a workable option in my scenario. I am going to try option 1 and bring that up as a compromise with my unix guys that support that box. I will update this post when I have more information! -Megan