Skip to content

Check pip-updates

Overview

Checks for outdated Python packages installed via pip. Reports the number of packages with available updates and lists them with current and latest versions.

Important Notes:

  • Requires pip v20.3+

Data Collection:

  • Executes python3 -m pip list --outdated --format=json to get the list of outdated packages
  • With --virtualenv, checks the packages of that virtualenv with the interpreter next to its activate script
  • Supports all standard pip options for index URLs, exclusions, and package filtering
  • May take more than 10 seconds to execute depending on the number of installed packages and network latency

Fact Sheet

Fact Value
Check Plugin Download https://github.com/Linuxfabrik/monitoring-plugins/tree/main/check-plugins/pip-updates
Nagios/Icinga Check Name check_pip_updates
Check Interval Recommendation Every week
Can be called without parameters Yes
Runs on Cross-platform
Compiled for Windows No (runs with Python interpreter)
Requirements pip v20.3+

Help

usage: pip-updates [-h] [-V] [--always-ok] [-c CRIT] [--exclude EXCLUDE]
                   [--extra-index-url EXTRA_INDEX_URL]
                   [--find-links FIND_LINKS] [--index-url INDEX_URL] [--local]
                   [--no-index] [--no-perfdata] [--not-required] [--pre]
                   [--user] [--virtualenv VIRTUALENV] [-w WARN]

Checks for outdated Python packages installed via pip. Reports the number of
packages with available updates and lists them. Alerts when the count exceeds
the configured threshold.

options:
  -h, --help            show this help message and exit
  -V, --version         show program's version number and exit
  --always-ok           Always returns OK.
  -c, --critical CRIT   CRIT threshold for the number of outdated packages.
                        Default: 100
  --exclude EXCLUDE     Package name to exclude from the output. Can be
                        specified multiple times.
  --extra-index-url EXTRA_INDEX_URL
                        Extra URL of a package index to use in addition to
                        --index-url. Should follow the same rules as --index-
                        url. Can be specified multiple times.
  --find-links FIND_LINKS
                        URL or path to an HTML file to parse for links to
                        archives (.tar.gz, .whl). If a local path or file://
                        URL pointing to a directory, look for archives in the
                        directory listing. VCS project URLs are not supported.
                        Can be specified multiple times.
  --index-url INDEX_URL
                        Base URL of the Python Package Index (PEP 503
                        compliant repository or local directory in the same
                        format).
  --local               If in a virtualenv that has global access, do not list
                        globally-installed packages.
  --no-index            Ignore the package index and only look at --find-links
                        URLs.
  --no-perfdata         Suppress the performance data section from the output.
                        The status message and the exit code are unaffected,
                        so alerting keeps working while trending data is
                        dropped.
  --not-required        Only list packages that are not dependencies of other
                        installed packages.
  --pre                 Include pre-release and development versions. By
                        default, pip only finds stable versions.
  --user                Only check packages installed in the user-site
                        directory.
  --virtualenv VIRTUALENV
                        Path to the activate script of a virtualenv. The
                        interpreter of that virtualenv is used to check for
                        updates inside it. Example: `--virtualenv=/opt/sphinx-
                        venv/bin/activate`.
  -w, --warning WARN    WARN threshold for the number of outdated packages.
                        Default: 10

Documentation:
https://linuxfabrik.github.io/monitoring-plugins/check-plugins/pip-updates/

Usage Examples

./pip-updates --virtualenv=/path/to/my/venv/bin/activate --local --exclude=pip

Output:

Everything is ok. 2 outdated packages. pip says `[notice] A new release of pip is available: 24.0 -> 26.2.1`. Executed command: `/path/to/my/venv/bin/python3 -m pip list --outdated --exclude=pip --local`

Package ! Version ! Latest ! Type
--------+---------+--------+------
idna    ! 3.4     ! 3.20   ! wheel
six     ! 1.15.0  ! 1.17.0 ! wheel

States

  • OK if the number of outdated packages is below the warning threshold.
  • WARN if the number of outdated packages is >= --warning (default: 10).
  • CRIT if the number of outdated packages is >= --critical (default: 100).
  • --always-ok suppresses all alerts and always returns OK.

Perfdata / Metrics

Name Type Description
pip_outdated_packages Number Number of outdated packages.

Troubleshooting

pip is not installed

pip is not installed for `python3`, so the outdated packages cannot be listed.

The distributions ship pip as a separate package, and a minimal installation does not have it. The check uses the python3 found in PATH, which under sudo is the system interpreter. Install the pip package of the distribution (dnf install python3-pip, apt install python3-pip, zypper install python3-pip), or point --virtualenv at the venv whose packages you want to check.

TypeError: '>' not supported between instances of 'Version' and 'Version'

Your version of pip is below 20.3. Upgrade by running python3 -m pip install --upgrade pip.

Credits, License