-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmonitor.bash
78 lines (59 loc) · 2.38 KB
/
monitor.bash
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# Copyright (c) 2025, Amogh S. Joshi
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# FILENAME: monitor
# system constants. DO NOT CHANGE
QUEUE=kaushik
JOB_FILE_PATH=$HOME/rcac-utils
USER=$(whoami)
# usage help message
usage() {
echo "usage: $0 [-h] [-s SESSION_NAME] [-w WINDOW_NAME]" 1>&2;
echo "-h: Display help message"
echo "-s SESSION_NAME: Name of the tmux session running monitor commands. Defaults to 'monitor'"
echo "-w WINDOW_NAME: Name of the tmux window running monitor commands. Defaults to 'job_status'"
exit 1;
}
# arg init
SESSION_NAME="monitor"
WINDOW_NAME="job_status"
# read args
while getopts "hs:" opts; do
case "${opts}" in
h) usage;;
s) SESSION_NAME=$OPTARG;;
*) usage;;
esac
done
module load monitor
#Get width and lenght size of terminal, this is needed if one wants to resize a detached session/window/pane
#with resize-pane command here
set -- $(stty size) #$1=rows, $2=columns
# create new session
tmux new-session -s $SESSION_NAME -n $WINDOW_NAME -d -x "$2" -y "$(($1 - 1))"
tmux send-keys -t $SESSION_NAME 'watch -n 1 squeue -u $USER' C-m
#rename pane 0
tmux set -p @mytitle "squeue"
# split window vertically
tmux split-window -v
tmux send-keys -t $SESSION_NAME 'squeue -a -p ai' C-m
#rename pane 1
tmux set -p @mytitle "cpu_load"
# attach session
tmux attach -t $SESSION_NAME
# show queue
# tmux new-session -d -s $SESSION_NAME watch -n 1 squeue -u $USER