varnish / varnishgather

Information gathering tool for Varnish Cache.
45 stars 36 forks source link

detect Varnish instances and try to be helpful #120

Open gquintard opened 1 week ago

gquintard commented 1 week ago

One Karnaugh map later and I realized that https://github.com/varnish/varnishgather/pull/116#discussion_r1809252878 could have been expressed more simply:

Read on for example outputs.

If varnishadm ping is successful with the current NAME argument, no question asked, go for it:

Info: Working directory: /tmp/varnishgather.Z1LTcYva/varnishgather-flamp-20241106-214646
Info: Complete varnishadm command line deduced to:
Task: 1: varnishd -V
...

If pinging failed, there are a few cases:

If NAME was given, or if NAME wasn't given but there's no varnishd detected, issue a warning, pause a bit, then proceed:

Info: Working directory: /tmp/varnishgather.BBE414gf/varnishgather-flamp-20241106-221201
#######################################################
using: varnishadm    ping,
We couldn't ping varnishd, Is it running and is
./varnishgather running with the right permissions?
#######################################################
Info: Complete varnishadm command line deduced to:
<PAUSE 10s>
Task: 1: varnishd -V
...

if no NAME was given but there's exactly one candidate, and it's pingable, override NAME, warn about it, pause then proceed:

Info: Working directory: /tmp/varnishgather.ZeUDcfg7/varnishgather-flamp-20241106-222151
#######################################################
using: varnishadm    ping,
We couldn't ping varnishd, Is it running and is
./varnishgather running with the right permissions?

There's only one varnishd running and it's pingable.

Overriding -n argument to /tmp/beepboop
#######################################################
<PAUSE 10s>
Info: Complete varnishadm command line deduced to: -n /tmp/beepboop
Task: 1: varnishd -V
...

If no NAME is given, and there's only one candidate but it's not pingable, just error out:

Info: Working directory: /tmp/varnishgather.eZSa78VU/varnishgather-flamp-20241106-224856
#######################################################
using: varnishadm    ping,
We couldn't ping varnishd, Is it running and is
./varnishgather running with the right permissions?
#######################################################
<EXIT>

Finally, if there are no given NAME, and we have more than one candidate, we just propose a list of candidates and error out:

Info: Working directory: /tmp/varnishgather.dkGgfqHe/varnishgather-flamp-20241106-223210
#######################################################
using: varnishadm    ping,
We couldn't ping varnishd, Is it running and is
./varnishgather running with the right permissions?

We've also detected one or more varnishd that
could possibly be pinged with these -n arguments:
                -n /tmp/beepboop
                -n /tmp/beepboop2
#######################################################
<EXIT>

@hermunn and @zackmay, tagging you in as you were part of the original discussion.