Debian Codegraph @

debian/tests/metric-varnish-up

raw symbols SCIP
1 #!/bin/sh -e
2 #
3 # This is a functional test which passes if prometheus-varnish-exporter returns
4 # the metric 'varnish_up' with the value 1. This means that:
5 # - prometheus-varnish-exporter.service has been started correctly
6 # - the exporter can run varnishstat(1) successfully
7 # - metrics are being returned as expected
8
9 status_and_exit() {
10 systemctl status vinyl-cache.service
11 systemctl status prometheus-varnish-exporter.service
12 exit 1
13 }
14
15 if [ "$(id --user)" = 0 ] || id --groups --name | grep -qw vinyl; then
16
17 if ! vinylstat -1 -f MGT.uptime; then
18 echo "vinylstat does not work!" >&2
19 status_and_exit
20 fi
21
22 if ! prometheus-varnish-exporter --test; then
23 echo "prometheus-varnish-exporter --test failed!" >&2
24 status_and_exit
25 fi
26
27 fi
28
29 if ! systemctl -q is-active prometheus-varnish-exporter.service; then
30 echo "prometheus-varnish-exporter.service is not active!" >&2
31 status_and_exit
32 fi
33
34 if ! curl 127.0.0.1:9131/metrics > metrics; then
35 echo "Scraping the exporter failed!" >&2
36 status_and_exit
37 fi
38
39 if ! grep -q '^varnish_up 1$' metrics; then
40 echo "The varnish_up metric is missing or != 1!" >&2
41 echo
42 cat metrics
43 status_and_exit
44 fi
45