-
Notifications
You must be signed in to change notification settings - Fork 0
/
cinfo
executable file
·119 lines (104 loc) · 2.71 KB
/
cinfo
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/bash
# this script goes in each node of our cluster and prints out some information regarding each node
# TODO (vinicius): add more info, for example free space for storage and related.
# TODO (vinicius): leave this as a sysadmin file in the lab github
# TODO (vinicius): use awk to better format output (maybe in tables?)
# debug nodeinfo
nodes=( "elara" "leda" "euante" "amalteia" "himalia" "carme" "helique" "cilene" "ortosia" "euporia" "io" "harpalique" "iocasta" "ganimedes" "tebe" "praxidique" "arque" "lisiteia" "metis" "adrasteia" "carpo" )
help="false"
temperature="false"
memory="false"
nodeinformation="false"
ARGS=$(getopt -a --options ht:m:n: --long "help,temperature:,memory:,nodeinfo:" -- "$@")
eval set -- "$ARGS"
while true; do
case "$1" in
-h|--help)
help="true"
shift;;
-t|--temperature)
temperature="true"
machine+=("$OPTARG")
# machine="$2"
shift 2;;
-m|--memory)
memory="true"
machine="$2"
shift 2;;
-n|--nodes)
nodeinformation="true"
info="$2"
shift 2;;
--)
break;;
*)
printf "Unknown option %s\n" "$1"
exit 1;;
esac
done
Help()
{
# Display Help
echo "Display information on the state of the cluster "
echo
echo "Syntax: cinfo [-h|t|m|n]"
echo "options:"
echo "-h/--help Print this Help and exit."
echo "-t/--temperature Print temperature on all nodes."
echo "-m/--memory Print the total memory on all nodes."
echo "-n/--nodeinfo \$arg Print information about the nodes, requires one positional argument:"
echo " job"
echo " free"
echo " down"
echo " state"
}
Temperature()
{
if [[ $machine == "all" ]]; then
# Displays the temperature of selected nodes
for i in "${nodes[@]}";
do
echo "Temperature check for $i"
# ssh $i "sensors | grep Core 2>/dev/null"
done
else
echo $machine
for i in "${machine[@]}"; do
echo "Temperature check for $i"
# ssh $machine "sensors | grep Core 2>/dev/null"
done
fi
}
Memory()
{
if [[ $machine == "all" ]]; then
# Displays the total memory of all nodes
for i in "${nodes[@]}";
do
echo "Total memory for $machine"
ssh $i "grep MemTotal /proc/meminfo 2>/dev/null"
done
else
echo "Total memory for $machine"
ssh $machine "grep MemTotal /proc/meminfo 2>/dev/null"
fi
}
Nodeinfo()
{
# Displays the nodeinfo required
pbsnodes -a | grep -B4 state\ \=\ $info
}
if [ $help == "true" ]; then
Help
exit
fi
if [ $temperature == "true" ]; then
Temperature
fi
if [ $memory == "true" ]; then
Memory
fi
if [ $nodeinformation == "true" ]; then
Nodeinfo
fi
exit