/
ldmsd_sampler_services
executable file
·88 lines (75 loc) · 1.82 KB
/
ldmsd_sampler_services
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
usage() {
echo "Usage: ldmsd_sampler_services [start|stop|status]"
echo " start Start ldmsd_sampler daemons on the nodes configured to"
echo " collect metrics, e.g., compute nodes, IO nodes and"
echo " management nodes"
echo ""
echo " stop Stop the running ldmsd_sampler daemons on the nodes"
echo " configured to collect metrics"
echo ""
echo " status Return the status of ldmsd_samplers on the nodes"
echo " configured to collect metrics"
}
# Check the number of arguments
if [ $# -le 0 ]; then
usage
exit -1
fi
cmd=$1
# get the hosts that should run ldmsd_samplers
if [ -f "/etc/profile.d/set-ovis-variables.sh" ]; then
. /etc/profile.d/set-ovis-variables.sh
else
echo "Cannot find /etc/profile.d/set-ovis-variables.sh. Please install
OVIS/lib."
exit -1
fi
if [ -f "/etc/ovis/ovis-functions.sh" ]; then
. /etc/ovis/ovis-functions.sh
else
echo "Cannot find /etc/ovis/ovis-functions.sh. Please install
OVIS/lib."
exit -1
fi
if [ "$OVIS_RUN_CONF" = "" ]; then
echo '$OVIS_RUN_CONF is not defined'
exit -1
fi
if [ ! -f "$OVIS_RUN_CONF" ]; then
echo "$OVIS_RUN_CONF does not exist."
exit -1
fi
SQL_SAMPLER_HOST="SELECT DISTINCT(apply_on) FROM templates ORDER BY apply_on;"
HOSTS=`sqlite3 $OVIS_RUN_CONF "$SQL_SAMPLER_HOST"`
if [ ! $? -eq 0 ]; then
exit $?
fi
if [[ "$HOSTS" == "" ]]; then
echo "No host found"
exit -1
fi
HOSTS_S=`collapse_hostnames "$HOSTS"`
HOSTS=`echo $HOSTS`
HOSTS=`echo ${HOSTS// /,}`
case "$cmd" in
start)
echo "Connecting to hosts: $HOSTS_S ..."
pdsh -f 80 -w $HOSTS "service ldmsd_sampler start"
;;
stop)
echo "Connecting to hosts: $HOSTS_S ..."
pdsh -f 80 -w $HOSTS "service ldmsd_sampler stop"
;;
status)
echo "Connecting to hosts: $HOSTS_S ..."
pdsh -f 80 -w $HOSTS "service ldmsd_sampler status" | sort
;;
usage)
usage
;;
*)
usage
exit -1
;;
esac