Bugzilla – Bug 12062
implement PING
Last modified: 2020-02-05 13:25:48 EST
the clamd protocol knows a command "PING". clamd MUST respond with "PONG" see "man clamd" Feature Request: Please enhance clamdscan to support this command. Usecase: Docker implement health checks. see https://docs.docker.com/engine/reference/builder/#healthcheck One possible health check could be "clamdscan --ping --quiet" If the configured clamd respond, clamdscan will just exit 0 and docker know "this container is healthy" I tried to implement that with "clamdscan --version" but that don't work with current code: - clamdscan exit code is always 0 - clamdscan print a version itself, if communication with clamd failed ( see function "print_server_version" in clamdscan/clamdscan.c )
Sounds like a simple enough request. We can look at this and your other requests for 0.101 as we begin feature planning and wrap up 0.100
It's very easy to achieve the objective with existing tools: mail6:~# >>> crontab -l | grep PING * * * * * /bin/echo 'PING'|/bin/nc localhost 3311|/usr/bin/logger -p mail.debug 2>&1 I'd suggest that implementing this request would be a waste of effort.
Hello Ged, while it is as simple as you say on a usual Unix host it has some consequences while implementing this as Docker container for example as healthcheck. - one have to "know" clamd's servicepoint * localhost/tcp port * /path/to/socket -> separate parsing of clamd.conf required - Tools required Docker images are supposed to not contain the full unix toolchains while this require netcat and probably sed/awk to parse clamd.conf - many people implementing such stuff reinventing the wheel again and again to simplify such a healthcheck I asked for an implementation in clamdscan itself. Andreas
Hi Andreas, Sorry we overlooked this in version planning... it just slipped by :(. I'm going to create a ticket in Jira now and associate it with 0.103. -Micah
Andreas, I was working on some internal test harness stuff and found a need to use clamdscan to do a ping. I realized I could achieve this by doing: echo "PING" | clamdscan --stream - Exit code < 2 is a pong. Exit code >= 2 is no response. The timeout in testing appears to be 2 seconds, but I haven't really peeked at the code to confirm. I'll be using this technique to verify that clamd is up and ready for clamdscan tests on Windows, where I can't just verify that clamd forked. This ticket was fresh on my mind as I've been reviewing & prioritizing Jira & Bugzilla tickets recently and I wanted to share. I still hope to add a `--ping` command line option for v0.103. -Micah
Added a ping and a wait implementation to both clamdscan and clamonacc via: https://github.com/Cisco-Talos/clamav-devel/commit/f3e895c949ef3c87305f1d7f3f169ece8b806b97 The wait will have the client hold off on server communication until a PONG is received from clamd (until the specified timeout is reached)