PEM command line interface v8

New Feature

PEM command line interface (CLI) support is available in PEM 8.5.0 and later for Linux platforms. You can also access PEM 8.2 to 8.4 servers using the PEM CLI.

The PEM CLI allows you to export/import the alert templates or probes from one PEM server to another.

You can install the PEM CLI using the package edb-pem-cli-8.5.0-1-<platform_name> separately from edb.repo repository. It creates the binary file /usr/edb/pem/cli/bin/pem and the license file /usr/edb/pem/edb-pem-cli-license.txt.

After installing PEM CLI package, use the ./pem -h command to see all the available options.

$ ./pem -h
Output
PEM CLI (Postgres Enterprise Manager Command Line Interface)
Usage: ./pem [OPTIONS] [SUBCOMMAND]

Options:
  -h,--help                   Print this help message and exit
  -v,--version                Show the app version and exit


Logging:
  --log-file [/home/asheshvashi/.pem-cli.log] 
                              Set the log file
                              
                              NOTE: Directory must exist
                              
  -l,--log-level :value in {FATAL->1,ERROR->2,WARNING->3,DEBUG->5,INFO->4,VERBOSE->6} OR {1,2,3,5,4,6} [INFO] 
                              Set the log level


PEM Information:
  -p,--pem-url REQUIRED (Env:PEM_SERVER_URL)
                              Set the URL for accessing Postgres Enterprise Manager
                              e.g.
                              https://127.0.0.1:8443/pem
                              https:://pem_host:8443/pem
                              
  -u,--pem-user REQUIRED (Env:PEM_API_USER)
                              User to access the PEM REST API
                              
  -f,--password-file (Env:PEM_PASSWORD_FILE)
                              Location of the file, which contains the password.
                              The permission on a password file must disallow any access to world or group.
                              
                              NOTE:
                              * The first non-empty line in the file will be treated as a
                                password.
                              * Environment variable 'PEM_API_PASSWORD' can be used for
                                providing the password instead of the password file
                              
  -i,--insecure               Set the insecure connection
                              

Subcommands:
  import-alert-templates      Import the alert template(s) into the PEM server.
  list-alert-templates        List the alert templates in the PEM server.
  export-alert-templates      Export the custom (user-defined) alert templates from the PEM server.
  import-probes               Import the probe(s) into the PEM server.
  export-probes               Export the custom (user-defined) probes from the PEM server.
  list-probes                 List the probes in the PEM server.

You can see all the available options with the import-alert-templates subcommand:

$ ./pem import-alert-templates -h
Output
Import the alert template(s) into the PEM server.
Usage: ./pem import-alert-templates [OPTIONS]

Options:
  -h,--help                   Print this help message and exit
  -i,--in-file                Alert template file
  --ignore-existing           Ignore the existing alert template in the PEM server
  --ignore-existing-probes    Ignore the existing probes in the PEM server

You can see all the available options with the list-alert-templates subcommand:

$ ./pem list-alert-templates -h
Output
List the alert templates in the PEM server.
Usage: ./pem list-alert-templates [OPTIONS]

Options:
  -h,--help                   Print this help message and exit
  -c,--alert-template-category :value in {ALL->2,CUSTOM->1,SYSTEM->0} OR {2,1,0} [CUSTOM] 
                              List down the alert templates of this category

You can see all the available options with the export-alert-templates subcommand:

$ ./pem export-alert-templates -h
Output
Export the custom (user-defined) alert templates from the PEM server
Usage: ./pem export-alert-templates [OPTIONS]

Options:
  -h,--help                   Print this help message and exit
  -i,--id INT ...             List of id for the custom alert templates to be exported
  -o,--out-file [Standard output (console)] 
                              Output file name
  -w,--overwrite              Overwrite the existing output file

You can see all the available options with the import-probes subcommand:

$ ./pem import-probes -h
Output
Import the probe(s) into the PEM server.
Usage: ./pem import-probes [OPTIONS]

Options:
  -h,--help                   Print this help message and exit
  -i,--in-file                Probes file
  --ignore-existing           Ignore the existing custom probes in the PEM server

You can see all the available options with the export-probes subcommand:

$ ./pem export-probes -h
Output
Export the custom (user-defined) probes from the PEM server
Usage: ./pem export-probes [OPTIONS]

Options:
  -h,--help                   Print this help message and exit
  -i,--probe-id INT ...       List of the custom probe-ids to be exported
  -o,--out-file [Standard output (console)] 
                              Output file name
  -w,--overwrite              Overwrite the existing output file

You can see all the available options with the list-probes subcommand:

$ ./pem list-probes -h
Output
List the probes in the PEM server.
Usage: ./pem list-probes [OPTIONS]

Options:
  -h,--help                   Print this help message and exit
  -c,--probe-category :value in {ALL->2,CUSTOM->1,SYSTEM->0} OR {2,1,0} [CUSTOM] 
                              List down the probes of this category

Example

To list all the probes (system as well as custom probes) use the -c all option:

$ PEM_PASSWORD_FILE=/tmp/pass PEM_API_USER=postgres PEM_SERVER_URL=https://172.17.0.4/pem ./pem -i list-probes -c all

Where,

  • PEM_PASSWORD_FILE=/tmp/pass is the password file with password of the postgres user.
  • PEM_API_USER=postgres is the username through which we are running the PEM CLI.
  • PEM_SERVER_URL=https://172.17.0.4/pem is the URL of the PEM server containing the probes.
  • -i list-probes is the insecure option with list-probes subcommand to allow insecure connection and to list the probes.
  • -c all is the -c option with all value to list all the system as well as custom probes.