Forum: CFEngine Help
Subject: Unexpectedly large number of connections when using readtcp
Author: aleksey_c
Link to topic: https://cfengine.com/forum/read.php?3,27143,27143#msg-27143
Hello!
I encountered with unexpectedly large number of connections when using readtcp
built-in function.
The code
body common control
{
bundlesequence => { "cftest" };
}
bundle agent cftest
{
vars:
"http_get" string => readtcp("1.1.1.1","80","GET /getstatus
HTTP/1.0$(const.r)$(const.n)Host:
1.1.1.1$(const.r)$(const.n)$(const.r)$(const.n)","512");
classes:
"http_ok" expression => regcmp("[^\n]*200 OK.*","$(http_get)");
reports:
http_ok::
"http is up";
!http_ok::
"http is down";
}
Then execute command
# cf-agent -f ./cftest9.cf -K
R: http is up
netstat shows many TIME_WAIT sockets on every execution
tcp 0 0 192.168.33.254:55208 192.168.37.153:80 TIME_WAIT
tcp 0 0 192.168.33.254:55212 192.168.37.153:80 TIME_WAIT
tcp 0 0 192.168.33.254:55209 192.168.37.153:80 TIME_WAIT
tcp 0 0 192.168.33.254:55203 192.168.37.153:80 TIME_WAIT
tcp 0 0 192.168.33.254:55206 192.168.37.153:80 TIME_WAIT
tcp 0 0 192.168.33.254:55210 192.168.37.153:80 TIME_WAIT
tcp 0 0 192.168.33.254:55204 192.168.37.153:80 TIME_WAIT
tcp 0 0 192.168.33.254:55211 192.168.37.153:80 TIME_WAIT
tcp 0 0 192.168.33.254:55205 192.168.37.153:80 TIME_WAIT
tcp 0 0 192.168.33.254:55207 192.168.37.153:80 TIME_WAIT
tcpdump shows many queries on every cf-agent execution
# tcpdump -n host 1.1.1.1 -A -s 0 | grep "GET /getstatus HTTP/1.0"
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), capture size 65535 bytes
......c.GET /getstatus HTTP/1.0
......c.GET /getstatus HTTP/1.0
......c.GET /getstatus HTTP/1.0
......c.GET /getstatus HTTP/1.0
......c.GET /getstatus HTTP/1.0
......c.GET /getstatus HTTP/1.0
......c.GET /getstatus HTTP/1.0
......c.GET /getstatus HTTP/1.0
Is it expected behaviour of cf-agent or is it bug and should be fixed?
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine