Cloud Native应用交付

  • 首页
  • 关于本站
  • 个人介绍
  • Downloads
  • Repo
    • Github
    • Container
  • F5
    • F5 Python SDK
    • F5-container
    • F5-LBaaS
  • 社交
    • 联系我
    • 微信/微博
    • 公众号
    • 打赏赞助
行至水穷处 坐看云起时
Cloud Native Application Services: cnadn.net
  1. 首页
  2. F5技术
  3. 正文

未命名文章

2008年08月6日 6791点热度 0人点赞 0条评论
    LTM: HTTP Monitoring with POST Request
 

posted @ Wednesday, March 12, 2008 2:55 PM by deb - 2445 views

I recently discovered that you can use LTM's built in HTTP monitor template to send a POST request to a server to verify its health. It's surprisingly straightforward in comparison with the external monitor approach I've used in the past. This article will cover the details you'll need to properly implement an HTTP POST monitor using the built in monitor template.

The built in HTTP monitor template

The HTTP monitor template provides a way to send a single request to the server, monitor the response for an expected string, and mark the pool member down if the expected response isn't seen within the configured timeout. The options of interest for this exercise are the Send string and the Receive string. 

The Send string is where the request is configured.  It should include the method (in this case, POST), the URI to request from the server, the HTTP version, some standard HTTP headers (including Basic Auth, if applicable), and in this case, the POST body.

The server should respond in a predictable way to this request each time it is issued.  The Receive string should include a phrase or non-dictionary word that will appear only in that expected response. The Receive string can use basic regular expressions to accommodate per-server or other minor variations in the expected response.

Capturing the the transaction

The first thing you'll need to do, as with any monitor, is to identify and capture the transaction you'd like to replicate in order to validate the health of your application servers.  You can run tcpdump to watch live production traffic and capture the target request and response, but it's safer to run an isolated test request at the command line to more exactly replicate the action of the LTM monitor.

The approach I recommend uses both techniques.  First capture a trace of production traffic so you have a known-good working example with all the expected headers.  Then log into the LTM command line and use telnet or cURL to send the same request to the server along with the observed headers, and monitor the response, adjusting the request until the expected response is received.

Here's the cURL syntax you'll need to use for command line request submission:

1
curl -N -H &lt;headers&gt; -u &lt;user:password&gt; -d &lt;post body&gt; http://&lt;pool_mmeber_IP&gt;:&lt;pool_mmeber_port&gt;&lt;URI&gt;<br />

You'll need to examine the actual data that's being passed, including whitespace characters.  A packet trace can be used to look directly at the conversation on the wire. Capture on the server-facing interface.  To examine only production traffic, filter for the IP/port of the pool member, excluding the non-floating self IP on the server-facing VLAN:

1
tcpdump -nni &lt;server_vlan&gt; -Xs 0 host &lt;pool_member_IP&gt; and port &lt;pool_member_port&gt; and not host &lt;internal_non-floating_selfIP&gt;

(Filtering out the non-floating self IP prevents monitor traffic from appearing in the trace.)

To examine your command line request, filter instead for the non-floating self IP on the server-facing VLAN and the IP/port of the pool member:

1
tcpdump -nni &lt;server_vlan&gt; -Xs 0 host &lt;internal_non-floating_selfIP&gt; and host &lt;pool_member_IP&gt; and port &lt;pool_member_port&gt; <br />

Here's a sample transaction trace for a SOAP/xml request:

Once you have identified the transaction and validated the required headers, you are ready to build your custom monitor.

Creating the custom HTTP monitor

The information you've gathered so far should be everything you need to configure the custom HTTP monitor. Start by creating a monitor of type "http" in the LTM GUI (Local Traffic -> Monitors -> Create).  Configure Interval and Timeout as appropriate for your application. Set Username and Password if Basic Auth credentials are required by the server. Then you'll need to dig into your transaction trace data to construct the Send string containing all the request details.

For the Send string, the HTTP method must be specified along with the URI and HTTP version v1.1 on the same line, followed by an encoded LF/CR (\r\n), then the Host header (required for HTTP 1.1).  For the trace above, we'll start with:

1
POST /XAIApp/xaiserver HTTP/1.1\r\nHost: 191.168.1.1:4200

Add the other headers, all separated by a single encoded CR/LF.  (Line breaks are only for display. No literal carriage returns are inserted into the Send string.)  Include the Basic Auth header, if applicable, even though it is specified elsewhere in the monitor template.  With headers, the Send string now looks like this:

1
POST /XAIApp/xaiserver HTTP/1.1\r\nHost: 191.168.1.1:4200\r\n Authorization: Basic c3lzdXNlcjpzeXN1c2VyMDA= \r\n<br />Pragma: no-cache\r\nAccept: */*\r\nContent-Length: 673\r\nContent-Type: application/x-www-form-urlencoded

Finally add the POST body, preceded by a double CR/LF to indicate the end of the headers. If the POST body contains double quotes or braces, you will need to escape them with a preceding backslash so they are interpreted correctly by LTM. The completed Send string now looks like this:

1
2
3
4
POST /XAIApp/xaiserver HTTP/1.1\r\nHost: 191.168.1.1:4200\r\n Authorization: Basic c3lzdXNlcjpzeXN1c2VyMDA= \r\n<br />Pragma: no-cache\r\nAccept: */*\r\nContent-Length: 673\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n<br />&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV=\&quot;urn:schemas-xmlsoap-org:envelope\&quot;&gt;<br />&lt;SOAP-ENV:Body&gt;&lt;SSvcInstallationOptionsMaintenance dateTimeTagFormat=\&quot;CdxDateTime\&quot;&nbsp; transactionType =\&quot;READ\&quot; &gt;&lt;SSvcInstallationOptionsMaintenanceService&gt;<br />&lt;SSvcInstallationOptionsMaintenanceHeader InstallationOptionID=\&quot;1\&quot;/&gt;&lt;SSvcInstallationOptionsMaintenanceDetails InstallationOptionID=\&quot;1\&quot;&gt;<br />&lt;InstallMsg&gt;&lt;InstallMsgHeader InstallationOptionID=\&quot;1\&quot;/&gt;&lt;/InstallMsg&gt;&lt;InstallAlg&gt;&lt;InstallAlgHeader InstallationOptionID=\&quot;1\&quot;/&gt;&lt;/InstallAlg&gt;<br />&lt;
 
Module&gt;&lt;/Module&gt;&
lt;/SSvcInstallationOptionsMaintenanceDetails&gt;&lt;/SSvcInstallationOptionsMaintenanceService&gt;&lt;/SSvcInstallationOptionsMaintenance&gt;<br />&lt;/SOAP-ENV:Body&gt;&lt;/SOAP-ENV:Envelope&gt;<br />

To complete the monitor definition, enter the phrase or string expected in a healthy server response into the Receive string field. For the trace above, we'll use:

1
Standard automatic payment creation

The resulting monitor configuration will look like this:

1
monitor http-post-soapenv {<br />&nbsp;&nbsp; defaults from http<br />&nbsp;&nbsp; interval 10<br />&nbsp;&nbsp; timeout 31<br />&nbsp;&nbsp; password &quot;password&quot;<br />&nbsp;&nbsp; recv &quot;Standard automatic payment creation&quot;<br />&nbsp;&nbsp; send &quot;POST /XAIApp/xaiserver HTTP/1.1\r\nHost: 191.168.1.1:4200\r\nAuthorization: Basic c3lzdXNlcjpzeXN1c2VyMDA= \r\n<br />Pragma: no-cache\r\nAccept: */*\r\n Content-Length: 673\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n<br />&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV=\&quot;urn:schemas-xmlsoap-org:envelope\&quot;&gt;<br />&lt;SOAP-ENV:Body&gt;&lt;SSvcInstallationOptionsMaintenance dateTimeTagFormat=\&quot;CdxDateTime\&quot;&nbsp; transactionType =\&quot;READ\&quot; &gt;&lt;SSvcInstallationOptionsMaintenanceService&gt;<br />&lt;SSvcInstallationOptionsMaintenanceHeader InstallationOptionID=\&quot;1\&quot;/&gt;&lt;SSvcInstallationOptionsMaintenanceDetails InstallationOptionID=\&quot;1\&quot;&gt;<br />&lt;InstallMsg&gt;&lt;InstallMsgHeader InstallationOptionID=\&quot;1\&quot;/&gt;&lt;/InstallMsg&gt;&lt;InstallAlg&gt;&lt;InstallAlgHeader InstallationOptionID=\&quot;1\&quot;/&gt;&lt;/InstallAlg&gt;<br />&lt;Module&gt;&lt;/Module&gt;&lt;/SSvcInstallationOptionsMaintenanceDetails&gt;&lt;/SSvcInstallationOptionsMaintenanceService&gt;&lt;/SSvcInstallationOptionsMaintenance&gt;<br />&lt;/SOAP-ENV:Body&gt;&lt;/SOAP-ENV:Envelope&gt;&quot;<br />&nbsp;&nbsp; username &quot;user&quot;<br />}

相关文章

  • 一个很强大很强大的超级http monitor,可惜没怎么看懂
  • 密码保护:F5OS tenant部署后的容器情况、网络接口情况
  • 密码保护:F5OS tenant镜像实例化后信息
  • 密码保护:F5OS docker-compose.yml
  • 密码保护:F5OS 底层容器、网络及k8s状态
本作品采用 知识共享署名-非商业性使用 4.0 国际许可协议 进行许可
标签: http monitor
最后更新:2008年08月6日

纳米

linjing.io

打赏 点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理。

页面AI聊天助手

纳米

linjing.io

☁️迈向Cloud Native ADC ☁️

认证获得:
TOGAF: ID 152743
Kubernetes: CKA #664
Microsoft: MCSE MCDBA
Cisco: CCNP
Juniper: JNCIS
F5:
F5 Certified Solution Expert, Security
F5 Certified Technology Specialist, LTM/GTM/APM/ASM
F5 Certified BIG-IP Administrator
  • 点击查看本博技术要素列表
  • 归档
    分类
    • AI
    • Automation
    • Avi Networks
    • Cisco ACI
    • CISCO资源
    • F5 with ELK
    • F5-Tech tips
    • F5技术
    • Juniper
    • Linux
    • NGINX
    • SDN
    • ServiceMesh
    • WEB编程
    • WINDOWS相关
    • 业界文章
    • 交换机技术
    • 化云为雨/Openstack
    • 协议原理
    • 容器/k8s
    • 我的工作
    • 我的生活
    • 网站技术
    • 路由器技术
    • 项目案例
    标签聚合
    flannel envoy openstack network docker nginx k8s F5 api bigip neutron DNS gtm irule istio
    最近评论
    汤姆 发布于 8 个月前(09月10日) 嗨,楼主,里面的json怎么下载啊,怎么收费啊?
    汤姆 发布于 9 个月前(09月09日) 大佬,kib的页面可以分享下吗?谢谢
    zhangsha 发布于 1 年前(05月12日) 资料发给我下,谢谢纳米同志!!!!lyx895@qq.com
    李成才 发布于 1 年前(01月02日) 麻烦了,谢谢大佬
    纳米 发布于 1 年前(01月02日) 你好。是的,因为以前下载系统插件在一次升级后将所有的下载生成信息全弄丢了。所以不少文件无法下载。DN...
    浏览次数
    • Downloads - 183,945 views
    • 联系我 - 118,966 views
    • 迄今为止最全最深入的BIGIP-DNS/GTM原理及培训资料 - 117,310 views
    • Github - 104,025 views
    • F5常见log日志解释 - 79,913 views
    • 从传统ADC迈向CLOUD NATIVE ADC - 下载 - 75,131 views
    • Sniffer Pro 4 70 530抓包软件 中文版+视频教程 - 74,320 views
    • 迄今为止最全最深入的BIGIP-DNS/GTM原理及培训资料 - 67,770 views
    • 关于本站 - 61,112 views
    • 这篇文档您是否感兴趣 - 55,588 views
    链接表
    • F5SE创新
    • Jimmy Song‘s Blog
    • SDNlab
    • Service Mesh社区
    • 三斗室
    • 个人profile
    • 云原生社区

    COPYRIGHT © 2023 Cloud Native 应用交付. ALL RIGHTS RESERVED.

    Theme Kratos Made By Seaton Jiang

    京ICP备14048088号-1

    京公网安备 11010502041506号