Skip to content

Instantly share code, notes, and snippets.

@ImBIOS
Last active July 30, 2024 00:56
Show Gist options
  • Save ImBIOS/178afb5b6e6c164677e498aff3f1d756 to your computer and use it in GitHub Desktop.
Save ImBIOS/178afb5b6e6c164677e498aff3f1d756 to your computer and use it in GitHub Desktop.
This bash script retrieves and displays the properties of all free nodes in a PBS (Portable Batch System) cluster.
for node in $(pbsnodes -l free | awk '{print $1}'); do
echo "$node"
pbsnodes "$node" | awk '/state = free/ {state=$0} /properties =/ {prop=$0} END {print " " state; print " " prop}'
echo ""
done
@ImBIOS
Copy link
Author

ImBIOS commented Jul 30, 2024

Get Properties of Free Nodes in PBS

This bash script retrieves and displays the properties of all free nodes in a PBS (Portable Batch System) cluster.

Usage:

Save the script to a file (e.g., free_node_properties.sh) and make it executable (chmod +x free_node_properties.sh). Then, run the script:

./free_node_properties.sh

Output:

The script will print the name of each free node followed by its "state = free" line and its "properties = ..." line, indented for readability. For example:

s001-n086
     state = free
     properties = xeon,skl,gold6128,ram192gb,net1gbe,fpga_runtime,fpga,arria10

s001-n087
     state = free
     properties = xeon,cfl,e-2176g,ram64gb,net1gbe,gpu,gen9

...

How it Works:

  1. The script uses pbsnodes -l free to get a list of free nodes.
  2. For each free node:
    • It runs pbsnodes <node_name> to get the node's detailed information.
    • It uses awk to extract and print the "state = free" and "properties = ..." lines.

Note:

This script assumes that the pbsnodes command is available in your environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment