Skip to content

powa-team/powa-collector

Repository files navigation

Overview

This repository contains the powa-collector tool, a simple multi-threaded python program that performs the snapshots for all the remote servers configured in a powa repository database (in the powa_servers table).

Requirements

This program requires python 2.7 or python 3.

The required dependencies are listed in the requirements.txt file.

Configuration

Copy the provided powa-collector.conf-dist file to a new powa-collector.conf file, and adapt the dsn specification to be able to connect to the wanted main PoWA repository.

Usage

To start the program, simply run the powa-collector.py program. A SIGTERM or a Keyboard Interrupt on the program will cleanly stop all the thread and exit the program. A SIGHUP will reload the configuration.

Protocol

A minimal communication protocol is implented, using the LISTEN/NOTIFY facility provided by postgres, which is used by the powa-web project. You can send queries to collector by sending messages on the "powa_collector" channel. The collector will send answers on the channel you specified, so make sure to listen on it before sending any query to not miss answers.

The requests are of the following form:

COMMAND RESPONSE_CHANNEL OPTIONAL_ARGUMENTS

- COMMAND: mandatory argument describing the query.  The following commands
  are supported:

  - RELOAD: reload the configuration and report that the main thread
    successfully received the command.  The reload will be attempted even
    if no response channel was provided.

  - WORKERS_STATUS: return a JSON (srvid is the key, status is the content)
    describing the status of each remote server thread.  Command is ignored
    if no response channel was provided.  This command accept an optional
    argument to get the status of a single remote server, identified by its
    srvid.  If no worker exists for this server, an empty JSON  will be
    returned.

- RESPONSE_CHANNEL: mandatory argument to describe the NOTIFY channel the
  client listens a response on.  '-' can be used if no answer should be
  sent.

- OPTIONAL_ARGUMENTS: space separated list of arguments, specific to the
  underlying command.

The answers are of the form:

COMMAND STATUS DATA

- COMMAND: same as the command in the query

- STATUS: OK or KO.

- DATA: reason for the failure if status is KO, otherwise the data for the
  answer.