Skip to content

Commit 9c8485b

Browse files
committed
[FC-36891] fix varnish monitoring
The default monitoring check relied on varnish to run on a specific address. Since this address can be changed, the Sensu check needs to be adjusted to correctly infer the host and port that varnish is running on The listen address can only be reliably queried at runtime (without reimplementing Varnishd's command line parsing logic in nix) hence why multiple checks - one per address - are not possible.
1 parent f8dfc32 commit 9c8485b

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

nixos/roles/webproxy.nix

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,16 @@ in
6363
};
6464
varnish_http = {
6565
notification = "varnish port 8008 HTTP response";
66-
command = "check_http -H localhost -p 8008 -c 10 -w 3 -t 20 -e HTTP";
66+
command = "${pkgs.writeShellScript "check-varnish-http" ''
67+
ADDRS=$(${cfg.package}/bin/varnishadm debug.listen_address | awk '/([0-9.]+\.)+/ { print $2":"$3; }')
68+
for ADDR in $ADDRS; do
69+
host=$(echo $ADDR | cut -d ":" -f 1)
70+
port=$(echo $ADDR | cut -d ":" -f 2)
71+
72+
echo "checking host '$host' on port '$port'"
73+
${pkgs.monitoring-plugins}/bin/check_http -H $host -p $port -c 10 -w 3 -t 20 -e HTTP
74+
done
75+
''}";
6776
};
6877
};
6978

nixos/services/varnish/default.nix

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ in {
120120
http_address = mkOption {
121121
type = types.str;
122122
default = "*:8008";
123+
description = ''
124+
The http address for the varnish service to listen on.
125+
Unix sockets can technically be used for varnish, but are not currently supported on the FCIO platform due to monitoring constraints.
126+
Multiple addressess can be specified in a comma-separated fashion in the form of `address[:port][,address[:port][...]`.
127+
See `varnishd(1)` for details.
128+
'';
123129
};
124130
virtualHosts = mkOption {
125131
type = types.attrsOf (types.submodule ({ name, config, ... }: {

0 commit comments

Comments
 (0)