alias vov="scontrol -o show nodes | grep -e \"-lkeb\" -e \"-gpu\"| awk '{ printf(\"%-15s%-9s%-7s%-18s%-11s%-9s%s\n\", substr(\$1, 10), substr(\$4, 10), substr(\$5, 8), substr(\$9, 6), substr(substr(\$23, 12)/1024,0,5), substr(substr(\$24, 10)/1024,0,5), substr(\$38, 11))}' | awk '{printf(\"%-15s%-7s%-9s%-18s%-7s%-9s%50-s%2-s%9-s%9-s%9-s\n\", \$1, \$3, \$2, \$4, \$5, \$6, \"|\"\$7, \"|\", \$3-\$2, \$5-\$6, substr(\$4,length(\$4))-substr(\$7,length(\$7)))}' | awk '\$11 != 0' | awk 'BEGIN {print \"NodeName CPUTot CPUAlloc Gres MemTot MemAlloc AllocTres CPUAvail MemAvail GPUAvail CPU/GPU\"}{print \$0 FS \$9/\$11}'"
The above code works well when I write it to my .bashrc
file.
watch "scontrol -o show nodes | grep -e \"-lkeb\" -e \"-gpu\"| awk '{ printf(\"%-15s%-9s%-7s%-18s%-11s%-9s%s\n\", substr(\$1, 10), substr(\$4, 10), substr(\$5, 8), substr(\$9, 6), substr(substr(\$23, 12)/1024,0,5), substr(substr(\$24, 10)/1024,0,5), substr(\$38, 11))}' | awk '{printf(\"%-15s%-7s%-9s%-18s%-7s%-9s%50-s%2-s%9-s%9-s%9-s\n\", \$1, \$3, \$2, \$4, \$5, \$6, \"|\"\$7, \"|\", \$3-\$2, \$5-\$6, substr(\$4,length(\$4))-substr(\$7,length(\$7)))}' | awk '\$11 != 0' | awk 'BEGIN {print \"NodeName CPUTot CPUAlloc Gres MemTot MemAlloc AllocTres CPUAvail MemAvail GPUAvail CPU/GPU\"}{print \$0 FS \$9/\$11}'"
The above code also works well when I paste it to my terminal (/bin/bash
). Actually the code to be watched is just the vov
.
But I met some issues:
- I can not use
watch vov
in my terminal (/bin/bash
). - I can not use
alias
to assign the second code (longer version) to another variable in my.bashrc
. - I can not use
alias
to assignwatch vov
(shorter version) to another variable in my.bashrc
.
Can you help me to solve the 3 issues?