-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This relies on infrastructure added by PoWA 4. The collector now get the list of datasources from the repository for the given instance, export each datasource's data from the remote instance to a repository table, and call powa_take_snapshot for the instance. Some basic logging and reporting is also added.
- Loading branch information
Showing
12 changed files
with
519 additions
and
177 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"repository": { | ||
"dsn": "postgresql://powa_user@localhost:5432/powa" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env python | ||
|
||
from powa_collector import PowaCollector | ||
import logging | ||
|
||
# app = PowaCollector() | ||
app = PowaCollector(loglevel=logging.DEBUG) | ||
app.main() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import json | ||
|
||
|
||
def get_full_config(conn): | ||
return add_servers_config(conn, parse_options()) | ||
|
||
|
||
def add_servers_config(conn, config): | ||
if ("servers" not in config): | ||
config["servers"] = {} | ||
|
||
cur = conn.cursor() | ||
cur.execute(""" | ||
SELECT id, hostname, port, username, password, dbname, | ||
frequency | ||
FROM powa_servers s | ||
WHERE s.id > 0 | ||
ORDER BY id | ||
""") | ||
|
||
for row in cur: | ||
parms = {} | ||
parms["host"] = row[1] | ||
parms["port"] = row[2] | ||
parms["user"] = row[3] | ||
if (row[4] is not None): | ||
parms["password"] = row[4] | ||
parms["dbname"] = row[5] | ||
|
||
key = row[1] + ':' + str(row[2]) | ||
config["servers"][key] = {} | ||
config["servers"][key]["dsn"] = parms | ||
config["servers"][key]["frequency"] = row[6] | ||
config["servers"][key]["srvid"] = row[0] | ||
|
||
conn.commit() | ||
|
||
return config | ||
|
||
|
||
def parse_options(): | ||
return parse_file('./powa-collector.conf') | ||
|
||
|
||
def parse_file(filepath): | ||
return json.load(open(filepath)) |
Oops, something went wrong.