Forum Discussion
dan_19334
Nimbostratus
Jan 15, 2009Match TCP::payload to Newline
How do you match the TCP::payload to a Newline?
I would like to load balance individual syslog messages across a pool of servers. The syslog client connects to the VIP and maintains a persistent TCP connection and sends many syslog messages, I would like to take each message and send to a different backend node.
This is the iRule I am using to perform this function but can't seem to figure out how to collect until a newline is read.
when CLIENT_ACCEPTED {
TCP::collect
}
when CLIENT_DATA {
if { [TCP::payload] contains "\x0D\x0A" } {}
if { [TCP::payload] contains "\r\n" } {
LB::detach
TCP::release
TCP::collect
}
}
Thanks,
-Dan
7 Replies
- Nicolas_Menant
Employee
Cannot you activate LB datagram within the UDP profile to do this ? - wolfpack_98881
Nimbostratus
If this is syslog-ng, it may be TCP? - hoolio
Cirrostratus
I would have thought looking for \x0D\x0A would have worked. Could you try \x0d\x0a as well? Else, you could try converting \x0D\x0A to binary and looking for that in the binary payload or (less efficiently?) converting the payload to hex using 'binary scan [TCP::payload] H* payload_hex' and then looking for 0d0a. - dan_19334
Nimbostratus
This is using TCP via syslog-ng. - hoolio
Cirrostratus
What do you actually see in the hex payload? Maybe the client isn't using CR and LF?when CLIENT_ACCEPTED { TCP::collect } when CLIENT_DATA { save payload set payload [TCP::payload] log local0. "\$payload: $payload" if {$payload contains [binary format a* "\r\n"]}{ log local0. "Found CRLF in binary payload!" } convert payload to HEX binary scan $payload H* payload_hex log local0. "\$payload_hex: $payload_hex" if {$payload contains "0d0a"]}{ log local0. "Found CRLF in hex payload!" } }
- dan_19334
Nimbostratus
Thanks Aaron, you where on the right track...syslog doesn't terminate it's messages with CRLF, only with LF (my bad). - hoolio
Cirrostratus
Hi Dan,
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects