forked from paulmezz/slurm-stats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
process_section.sh
executable file
·41 lines (28 loc) · 1.04 KB
/
process_section.sh
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
#!/bin/bash
# Author: Aaron Herting
# License: MIT
LOCK_FILE="/var/lock/slurmplot/$BASHPID"
mkdir -p /var/lock/slurmplot
touch $LOCK_FILE
while read line ; do
JOB_ID=`echo "$line" | awk -F'|' '{ print $1 ; }'`
PARTITION=`echo "$line" | awk -F'|' '{ print $2 ; }'`
USERNAME=`echo "$line" | awk -F'|' '{ print $3 ; }'`
ELAPSED=`echo "$line" | awk -F'|' '{ print $4 ; }'`
SUBMIT=`echo "$line" | awk -F'|' '{ print $5 ; }'`
START=`echo "$line" | awk -F'|' '{print $6 ; }'`
END=`echo "$line" | awk -F'|' '{print $7 ; }'`
U_SUBMIT=`echo "$SUBMIT" | date --file - '+%s'`
U_START=`echo "$START" | date --file - '+%s'`
U_END=`echo "$END" | date --file - '+%s'`
S_ELAPSED=`echo -e "$U_END\t$U_START" | awk '{ print $1 - $2 ; }'`
# Calculate a "date stamp"
# 1. Take unix time
# 2. sec -> min
# 3. min -> hour
# 4. hour -> day
# 5. truncate
D_START=`echo "$U_START" | awk '{ print ( $1 / ( 60 * 60 * 24 )) ; }' | awk -F'.' '{ print $1 }'`
echo -e "$PARTITION\t$USERNAME\t$S_ELAPSED\t$U_SUBMIT\t$U_START\t$U_END\t$D_START"
done
rm -f $LOCK_FILE