Add Collectd as a Monitor Type
[doctor.git] / tests / lib / monitor
1 #!/bin/bash
2
3 MONITOR_TYPE=${MONITOR_TYPE:-sample}
4
5 function is_monitor_supported {
6     local monitor="$1"
7     [[ -f $TOP_DIR/lib/monitors/$monitor/$monitor ]]
8 }
9
10 function is_monitor {
11     local monitor="$1"
12     [[ $monitor == $MONITOR_TYPE ]]
13 }
14
15 function start_monitor {
16     start_monitor_$MONITOR_TYPE
17 }
18
19 function stop_monitor {
20     stop_monitor_$MONITOR_TYPE
21 }
22
23 function cleanup_monitor {
24     cleanup_monitor_$MONITOR_TYPE
25 }
26
27 if ! is_monitor_supported $MONITOR_TYPE; then
28     die $LINENO "MONITOR_TYPE=$MONITOR_TYPE is not supported."
29 fi
30
31 source $TOP_DIR/lib/monitors/$MONITOR_TYPE/$MONITOR_TYPE