-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmonitor.sh
More file actions
35 lines (33 loc) · 733 Bytes
/
monitor.sh
File metadata and controls
35 lines (33 loc) · 733 Bytes
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
#!/bin/bash
input="credentials";
negates=();
while getopts ":n:" opt; do
case $opt in
n) negates+=("$OPTARG");;
esac
done
shift $((OPTIND -1));
skip=0;
while read -r line; do
data=($line);
if [ -z $data ]; then
continue;
fi
for neg in "${negates[@]}"; do
if [[ ${data[0]} =~ .*$neg.* ]]; then
skip=1;
break;
fi
done
if [ $skip -eq 1 ]; then
skip=0;
continue;
fi
echo ${data[0]};
ret=$(curl -s -H "X-Api-Key:${data[1]}" "https://${data[0]}/api/job");
echo $ret | jq -r '.state';
echo "$(echo $ret | jq -r '.progress.completion')%";
left=$(echo $ret | jq -r '.progress.printTimeLeft');
echo "$(echo "scale=2 ; $left / 60" | bc) minutes left.";
echo;
done < $input;