forked from seL4/machine_queue
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwarn_holders.sh
More file actions
30 lines (26 loc) · 816 Bytes
/
warn_holders.sh
File metadata and controls
30 lines (26 loc) · 816 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
#!/bin/sh
#
# Copyright 2021 UNSW, Sydney
#
# SPDX-License-Identifier: GPL-2.0-only
export PATH=/usr/local/lib/machine_queue:$PATH
now=`date +'%s'`
timeLimit=7200
warn() {
mail -a 'From: LockBot@trustworthy.systems' $1@trustworthy.systems -s "Lock for $2 held for a long time" <<EOF
Hi $1,
You have now held the machine queue lock for $2 for
over `expr $diff / 3600` hours. That's OK if you're still using $2,
but otherwise, please release the lock
The Lockbot will remind you every four hours ...
Your friendly lockbot.
EOF
}
mq.sh sem dumpall |
while read system lockstate user day time zone key
do
[ $lockstate = FREE ] && continue
secs=$(date -d "$day $time $zone" +'%s')
diff=$(expr $now - $secs)
[ $diff -gt $timeLimit ] && warn "$user" "$system" "$diff"
done