summaryrefslogtreecommitdiffstats
path: root/test/livestatus/run_queries
blob: c80aa593fcc30f26887b613f6b2947a5aac9b62d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash

NC=`which nc`
LOCALSTATEDIR=`icinga2 variable get LocalStateDir`
LIVESTATUSSOCKET="$LOCALSTATEDIR/run/icinga2/cmd/livestatus"
LIVESTATUSHOST="127.0.0.1"
LIVESTATUSPORT="6558"
LIVESTATUSQUERIES="./queries"

LIVESTATUSTABLE=$1

echo -e "Querying Livestatus socket: $LIVESTATUSSOCKET"

if [ -n "$LIVESTATUSTABLE" ]; then
	cat "$LIVESTATUSTABLE"
	(cat "$LIVESTATUSTABLE"; sleep 1) | $NC -U $LIVESTATUSSOCKET
else

	echo -e "Looking into $LIVESTATUSQUERIES\n"
	for q in $(find $LIVESTATUSQUERIES -type f)
	do
		cat $q
		(cat $q; sleep 1) | $NC -U $LIVESTATUSSOCKET
		echo -e "================================\n\n"
	done
fi