Skip to main content

A caching qstat that reduces load on the PBS server

Project description

qstat-cache

A cached version of the PBS Pro qstat command that reduces load on the scheduler's database

Details

Most users run the qstat command at reasonable intervals and things work well. However, with the advent of workflow managers more users are running qstat at frequencies much too high for current versions of PBS Pro to support well. This utility creates a simple text-based cache of common qstat output and provides a script to serve that data to users. If an option is not cached (e.g., -Q output), the query is sent to PBS's version of qstat for processing. Usage:

usage: qstat [-h] [-1] [-a] [-D DELIMITER] [-f] [-F {json,dsv}]
             [--format FORMAT] [-H] [-J] [--noheader] [-n] [-s]
             [--status STATUS] [-t] [-T] [-u USER] [-w] [-x]
             [filters ...]

This command provides a lightweight alternative to qstat. Data are queried and
updated every minute from the PBS job scheduler. Options not listed here will
be forwarded to the scheduler. Please use those options sparingly. Job IDs, if
provided, should be numeric only and space delimited. If a destination is
provided, it should be a valid execution queue on the chosen server. This
cached version of qstat does not allow mixed queries from multiple servers -
only one server may be specified per request.

positional arguments:
  filters          job IDs or queues

options:
  -h, --help       show this help message and exit
  -1               display node or comment information on job line
  -a               display all jobs (default unless -f specified)
  -D DELIMITER     specify a delimiter if using -Fdsv (default = '|')
  -f               display full output for a job
  -F {json,dsv}    full output (-f) in custom format
  --format FORMAT  column output in custom format (=help for more)
  -H               all moved or finished jobs / specific job of any state
  -J               only show information for jobs (or subjobs with -t)
  --noheader       disable labels (no header)
  -n               display a list of nodes at the end of the line
  -s               display administrator comment on the next line
  --status STATUS  filter jobs by specific single-character status code
  -t               show information for both jobs and array subjobs
  -T               displays estimated start time for queued jobs
  -u USER          filter jobs by the submitting user
  -w               use wide format output (120 columns)
  -x               all job records in recent history

Installation

There are two methods for installing qstat-cache - using the included Makefile or with pip.

Makefile method

  1. Clone this repository on your system.
  2. Install at your desired path using make install PREFIX=/path/to/qstat-cache.

pip method

  1. If desired, first create a virtual environment with venv or conda/mamba and activate it.
  2. Now run python3 -m pip install qstat-cache.

Site setup

In either case, the following steps are required to finish configuration.

  1. In $PREFIX/lib/qscache/cfg or lib/python3.x/site-packages/qscache/cfg, copy the site.cfg.example file to site.cfg and customize settings as described below. Alternatively, copy the example to <system>.cfg and then set the environment variable QSCACHE_SERVER=<system>. The latter approach allows you to cache multiple servers in a complex at the same time.
  2. Schedule the util/gen_data.sh script to run at regular intervals (typically every minute via a cron job).
  3. Add the cached version of qstat to your (and your users') environment PATH.

site.cfg settings

[paths]
# Temporary data path used by gen_data when creating
# cached output from qstat (fast file system is best)
Temp = ${install_dir}/temp/derecho

# Path where cached data will be stored and accessed
Data = ${install_dir}/data

# Optional path for logging qstat invocations
# If set, a log will be created for each user on each day
#   that records calls to qstat along with arguments
# If blank, logging will be disabled
Logs = ${install_dir}/test/logs

[cache]
# The maximum wait time in seconds before the cache is
# bypassed and the real qstat is called
MaxWait = 20

# The maximum allowed age in seconds of cache data. Beyond
# this age we bypass the cache and call the true qstat
MaxAge = 300

# Delay in seconds to impose on qstat calls that bypass
# the cache due to aged data. Increasing this value can help
# the scheduler when under high load
AgeDelay = 5

# Specify the sub-minute frequency to generate data
# in seconds
Frequency = 10

# If querying data from a remote host, specify the list of
# available hosts here (space-delimited)
Hosts = login1 login2

[history]
# This section allows for some differing settings for caching
# historical data vs active job data. Typically you would
# want to use a slower frequency here since the data size
# can be large
Frequency = 60

[pbs]
# Specify the location of the actual qstat command
Qstat = /opt/pbs/bin/qstat

# Some sites may need to prefix calls to PBS with another
# command (e.g., a sudo operation). Use this variable to
# specify a prefix for PBS calls
Prefix = sudo -u adminuser

[servermap]
# Mapping of long-form server names for peer-scheduling
# user queries (use qstat -Bf to get server names)
casper = casper-pbs
derecho = desched1

[privileges]
# Enable privilege checking according to following user and
# group settings. If false, all queries allowed.
Active = True

[priv.all]
# Permit users and groups from these two lists respectively to
# see "full" job output from other users excluding the user
# environment contained in a job's Variable_List
Users = vanderwb
Groups = csgteam

[priv.env]
# Permit users and groups from these two lists to view all full
# job output, including the user environment
Users = vanderwb
Groups =

Example crontab

Here is a sample crontab that will run the gen_data script every minute (sub-minute scheduled is recommended and enabled via the site.cfg). The idea here is to run often enough that users and their workflows are satisfied, but not so often that we put our own load on PBS.

Here, we use the QSCACHE_SERVER variable to specify a particular system in a multi-server complex.

#   Run qstat cache generation script every minute
#       Added by Joe User on 4 Dec 2019
* * * * * QSCACHE_SERVER=sitename /path/to/qstat-cache/util/gen_data

Some sites have multiple login/admin nodes for redundency that can be used to generate the cache. To ensure that two nodes are not caching at the same time, add one or more hosts to the Hosts field in your site.cfg, and then use the gen_data_remote utility script in your cron job:

#   Run qstat cache generation script every minute
#       Added by Joe User on 4 Dec 2019
* * * * * QSCACHE_SERVER=sitename /path/to/qstat-cache/util/gen_data_remote

Debugging

There are two environment variables you may set to assist in debugging. Setting QSCACHE_DEBUG will cause qstat to print the age of the cache, assuming it can be found.

If you set QSCACHE_BYPASS to true, the cache will be bypassed regardless of which options are set, and the scheduler version of qstat will instead be called.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qstat_cache-3.0.1.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qstat_cache-3.0.1-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file qstat_cache-3.0.1.tar.gz.

File metadata

  • Download URL: qstat_cache-3.0.1.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for qstat_cache-3.0.1.tar.gz
Algorithm Hash digest
SHA256 84da4b6207462eb4eb9a00e53df9389ffd82aabb44e433bb61f70526e7d67ad2
MD5 c6661499513d1d0011da50d3bbae6335
BLAKE2b-256 5da32ae2d1420cf8a951d13dc69aa7196cf79d1e4febade44377be5f21339bc5

See more details on using hashes here.

Provenance

The following attestation bundles were made for qstat_cache-3.0.1.tar.gz:

Publisher: publish-to-pypi.yml on NCAR/qstat-cache

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qstat_cache-3.0.1-py3-none-any.whl.

File metadata

  • Download URL: qstat_cache-3.0.1-py3-none-any.whl
  • Upload date:
  • Size: 18.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for qstat_cache-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2c64ae45319e9ca8be53ca03cafa444a4710c1c963f42bf91abd49545732cc63
MD5 9f0119a85592b34607ffabce74826569
BLAKE2b-256 0e9f141cddd555553153de384b8450f74d7d7d246b82923b8315a4ed5ddba85b

See more details on using hashes here.

Provenance

The following attestation bundles were made for qstat_cache-3.0.1-py3-none-any.whl:

Publisher: publish-to-pypi.yml on NCAR/qstat-cache

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page