Forum Discussion
iRule Assistance for Logging client to VIP connections for a specific VIP.
A number of years ago, i had to do something similar. We needed to graph numbers of internal versus external connections to a particular virtual server. I'm sure there are easier ways of achieving the same results today but here's what i did..
i made the following shell script and chmod-ed it to be executable:
set the class file where the final output is written to
classfile=/var/class/pcms_active_conns.class
set the tmpfile where the output from the b conn is sent so we can count stuff
tmpfile=/var/class/pcms_active_conns.tmp
change to ai partition
`b shell partition ai`
get existing internal connections
oldint=`sed -n '1p' $classfile`
delete the old internal connection count from our class
`b class pcms_active_connections $oldint delete`
get existing external connections
oldext=`sed -n '2p' $classfile`
delete the old external connections from our class
`b class pcms_active_connections $oldext delete`
get the number of current active connections for the pcms VIP
`b conn server 130.220.xx.yy | awk -F":" '{print $1}' | sort > $tmpfile`
mathematical crap
total=`wc -l $tmpfile | awk '{print $1}'`
internal=`grep -c '^10.\|^130.220' $tmpfile`
external=$(($total - $internal))
do stuff with the final results
echo "\"internal $internal\"" > $classfile
echo "\"external $external\"" >> $classfile
`b class pcms_active_connections "\"internal $internal\"" add`
`b class pcms_active_connections "\"external $external\"" add`
A crontab entry was setup to run the above script once a minute. Created a new data group called pcms_active_connections, make it of type string.
Created the following iRule and applied it to my virtual server:
when HTTP_REQUEST {
if {[HTTP::uri] eq "/connection-stats"} {
set connlist [class get pcms_active_connections ]
HTTP::respond 200 content $connlist "Content-Type" "text/html"
}
}
Then set up a probe in our monitoring software (we use Intermapper) to query the virtual server for the /connection-stats uri and graph the results for external and internal connections.
Hopefully you can use some of this or it helps in some way.
- Ron_130795Jul 21, 2014
Nimbostratus
Thanks Ryan. What a huge help. I will take a close look at your script and see if I can apply it to our environment.
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