Forum Discussion
Using variable to set http file we test in a probe
We are using an http get of a file to validate the listener is up. We are using the port number as the file we are getting. an example today we have the following.
send "GET /8080.active HTTP/1.0\r\n\r\n"
We have hundreds of these listeners on different ports. Is there a way to pull the port from a variable? As an example
send "GET /[IP::client_port].active HTTP/1.0\r\n\r\n"
4 Replies
- Kevin_Stewart
Employee
Can I assume that this is being used in an EAV scripted monitor, and that the monitor works because the assigned pool members are using port 8080 (or 8080 as the alias port)? If so, there isn't a lot of scriptable flexibility in scripted monitors (odd). And generally speaking, you wouldn't be able to use the client port - a real time value from the data plane - in a management plain monitor. An external monitor may be more suitable, but based on the data plane/management plane limitation, where then would you get the port variable?
- Kevin_Stewart
Employee
In a standard HTTP monitor, no.
In an external monitor, using cURL, absolutely. Take a look at the BASH-based sample_monitor in /config/monitors. The external monitor profile sends the IP of the pool member as $1 and the port as $2, and any arguments (potentially your receive string if not hard coded) as $3. So something like this:
!/bin/sh 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 pidfile="/var/run/$MONITOR_NAME.$1..$2.pid" if [ -f $pidfile ] then kill -9 -`cat $pidfile` > /dev/null 2>&1 fi echo "$$" > $pidfile node_ip=`echo $1 | sed 's/::ffff://'` curl -fNs http://$node_ip:$2 |grep $3 1> /dev/null status=$? if [ $status -eq 0 ] then echo "up" fi rm -f $pidfile - hoolio
Cirrostratus
Just make sure to remove the pidfile before echoing anything to STDOUT as bigd kills the process immediately after the echo.
!/bin/sh 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 pidfile="/var/run/$MONITOR_NAME.$1..$2.pid" if [ -f $pidfile ] then kill -9 -`cat $pidfile` > /dev/null 2>&1 fi echo "$$" > $pidfile node_ip=`echo $1 | sed 's/::ffff://'` curl -fNs http://$node_ip:$2 |grep $3 1> /dev/null status=$? if [ $status -eq 0 ] then rm -f $pidfile echo "up" else rm -f $pidfile fi - Kevin_Stewart
Employee
Good call. Perhaps the sample monitor should be updated to reflect that.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com