Skip to content

PagerTree/pager_tree-cli

Repository files navigation

PagerTree CLI

GitHub release Python version

The PagerTree CLI is a powerful command-line tool for managing incidents, alerts, and on-call schedules in PagerTree, a modern incident management platform. Designed for sysadmins, DevOps engineers, and IT teams, it lets you interact with PagerTree’s API directly from your terminal, streamlining workflows and automating tasks.

Features

  • Create, view, and manage alerts, teams, broadcasts, and users.
  • Filter and search resources with flexible options.
  • View results in clean, table-formatted output.
  • Configure via environment variables or a simple config file.
  • Cross-platform support for macOS, Linux, and Windows.

Installation

Prerequisites

  • A PagerTree account and API key (get one from the PagerTree User Settings Page).
  • Python 3.8+ (optional, only if not using pre-built binaries).

Option 1: Install Pre-Built Binaries (Recommended)

  1. Visit the releases page.
  2. Download the binary for your operating system (e.g., pagertree, pagertree.exe).
  3. Make the binary executable (Linux/macOS):
    chmod +x pagertree
  4. Move the binary to a directory in your PATH (e.g., /usr/local/bin):
    mv pagertree /usr/local/bin/
  5. Verify installation:
    pagertree --help

Option 2: Install via Python

  1. Clone the repository:
    git clone https://github.com/PagerTree/pager_tree-cli.git
    cd pager_tree-cli
  2. Set up a virtual environment and install dependencies:
    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    pip install -r requirements.txt
  3. Run the CLI:
    python pagertree.py --help

Configuration

To use the PagerTree CLI, you need to configure your PagerTree API key.

Option 1: Environment Variable

Set the API key as an environment variable:

export PAGERTREE_API_KEY=your_api_key_here

Add it to your shell profile (e.g., ~/.bashrc, ~/.zshrc) for persistence.

Option 2: Configuration File

Create a .env file in the current working directory or specify a custom path:

PAGERTREE_API_KEY = your_api_key_here

Specify the config file when running commands:

pagertree --config ../other/path/.env alerts list

Usage

Run pagertree --help to see all available commands and options.

Common Commands

Command Description
pagertree alerts list List all alerts.
pagertree alerts list --status "open" List open alerts.
pagertree alerts create --title "Out of Memory" --team-id "01JT13C98M186XA3QTRFC250MT" Create a new alert.
pagertree alerts create --title "Out of Memory" --alias "oom" --team-id "01JT13C98M186XA3QTRFC250MT" Create a new alert with an alias.
pagertree alerts show "01JT13CYDAMAJDM0G8HR1X8BMY" Show details of an alert.
pagertree alerts acknowledge "01JT13CYDAMAJDM0G8HR1X8BMY" Acknowledge an alert.
pagertree alerts resolve "01JT13CYDAMAJDM0G8HR1X8BMY" Resolve an alert.
pagertree teams list List all teams.
pagertree teams current-oncall "01JT13C98M186XA3QTRFC250MT" List current on-call users for a team.

Advanced Options

  • Filter alerts with search:
    pagertree alerts list --search "NEEDLE IN THE HAYSTACK"
  • Paginate results:
    pagertree alerts list --limit 10 --offset 0
  • Use an alias for alerts:
    pagertree alerts show --alias "oom"

For more commands, see the PagerTree CLI Documentation.

Support

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages