How to use the command sshare (with examples)
- Linux
- December 25, 2023
The sshare
command is used to list the shares of associations to a cluster in Slurm. It provides information about how resources are allocated among different users or partitions on the cluster. This command can be helpful for cluster administrators and users to understand the resource distribution and usage.
Use case 1: List Slurm share information
Code:
sshare
Motivation: This use case allows cluster administrators or users to get an overview of the share information in the cluster. By running this command, they can see how the resources are distributed among different users and partitions, which helps them make informed decisions about resource allocation and usage.
Explanation: The sshare
command without any arguments will list the share information for all associations on the cluster.
Example output:
Cluster Name AssocID User Tier Partition PDef Actual SDef Actual
---------- ---------- ---------- ---- ---------- ------ ------ ------ ------
my_cluster 1 user1 1 par1 100% 50% 100% 50%
my_cluster 2 user2 1 par1 0% 0% 0% 0%
In the example output, we can see that the cluster name is “my_cluster” and it has two associations with AssocIDs 1 and 2. For each association, it provides information about the user, tier, partition, PDef (percent of partition allocation), Actual (actual usage), and SDef (percent of share allocation).
Use case 2: Control the output format
Code:
sshare --parsable
Motivation: Sometimes, users may want to process the share information programmatically or in a specific format. By using the --parsable
argument, they can obtain the share information in a machine-readable format.
Explanation: The --parsable
argument is used to control the output format of the sshare
command. When specified, it will display the share information in a parsable format, where each field is separated by tabs.
Example output:
Cluster Name AssocID User Tier Partition PDef Actual SDef Actual
my_cluster 1 user1 1 par1 100% 50% 100% 50%
my_cluster 2 user2 1 par1 0% 0% 0% 0%
In the example output, the share information is separated by tabs, allowing easy parsing and further processing.
Use case 3: Control the fields to display
Code:
sshare --format="%C %A %T %P"
Motivation: When working with the share information, users may only be interested in specific fields like Cluster Name, AssocID, User, and Partition. By using the --format
argument, they can customize the fields to display according to their needs.
Explanation: The --format
argument is used to control the fields to display in the sshare
command output. It takes a format string as an argument, where different placeholders can be used to represent specific fields. The available placeholders are:
%C
: Cluster Name%A
: AssocID%U
: User%T
: Tier%P
: Partition%PD
: PDef (percent of partition allocation)%AD
: Actual (actual usage)%SD
: SDef (percent of share allocation)
Example output:
my_cluster 1 user1 par1
my_cluster 2 user2 par1
In the example output, only the Cluster Name, AssocID, User, and Partition fields are displayed, as specified in the --format
argument.
Use case 4: Display information for the specified users only
Code:
sshare --users=user1,user2
Motivation: Sometimes, users may only want to see the share information for specific users or a subset of users. By using the --users
argument, they can filter the share information based on the specified user IDs.
Explanation: The --users
argument is used to display share information for the specified users only. It takes a comma-separated list of user IDs as an argument.
Example output:
Cluster Name AssocID User Tier Partition PDef Actual SDef Actual
---------- ---------- ---------- ---- ---------- ------ ------ ------ ------
my_cluster 1 user1 1 par1 100% 50% 100% 50%
my_cluster 2 user2 1 par1 0% 0% 0% 0%
In the example output, only the share information for “user1” and “user2” is displayed, as specified in the --users
argument.
Conclusion
The sshare
command is a powerful tool for listing the shares of associations to a cluster in Slurm. By using different arguments, users can control the output format, customize the fields to display, and filter the share information based on specific users. This provides flexibility and convenience when working with the share information in a cluster environment.