aboutsummaryrefslogtreecommitdiff
path: root/monitor_daemon.sh
blob: e18720fcd4e6acd61257ab219be9ace27e7b5a87 (plain) (blame)
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
#!/bin/bash

#if [[ "$#" -eq 0 ]]; then
#    echo "you must specify the triggered command"
#    exit 1
#fi
if [[ -e client_settings.sh ]]; then
    source client_settings.sh
    SOCKET_SPEC="--host $SOCKET_HOST --port $SOCKET_PORT"
fi
echo "Reporting to $SOCKET_SPEC"
CLIENT="python lab_monitor_client.py $SOCKET_SPEC"
function on_exit {
    $CLIENT --drop "$JID"
    exit 0
}

JID=$($CLIENT --create "$JMNAME" --type "$JTYPE")
if [[ "$JID" == "" ]]; then
    echo "failed to create monitor"
    exit 1
fi
trap on_exit SIGINT SIGTERM
while [ 1 ]; do
    trigger
    sleep 1
done