Giter Site home page Giter Site logo

pysar-1's Introduction

pysar

Small Python utility to provide system activity reports from the sysstat package as PostgreSQL foreign tables.

Provides a generator to parse the output of the sadf tool into named tuples and a Multicorn Foreign Data Wrapper for the next hop into a PostgreSQL database.

sadf/sysstat --> Python --> PostgreSQL foreign table

Scope is limited as this was written purely to allow a common, SQL-based entry point to these data (specifically device IO currently) but it should be easily extendable to similar use cases.

Install

NOTE: Instructions are Debian-focused and semi-tested.

There are a number of ways of setting this up depending on how you want to obtain the packages and where you want to install, but something like the following should work.

Dependencies

There are no dependencies for the first hop, but the second requires Multicorn (Python3; Python2 is untested).

Install sysstat

user@host:~$ sudo apt-get install sysstat

Enable data collection:

user@host:~$ sudo sed -i 's/ENABLED="false"/ENABLED="true"/' /etc/default/sysstat

Install Multicorn

user@host:~$ sudo apt-get install postgresql-9.4-python3-multicorn

You can only have either the python or python3 deb installed.

Install pysar

user@host:~$ sudo su - postgres
postgres@host:~$ mkdir -p ~/.local/lib/python3.4/site-packages
postgres@host:~$ cd /tmp; wget https://github.com/corriander/pysar.git
postgres@host:/tmp$ cd pysar
postgres@host:/tmp/pysar$ python3 setup.py install --user

Restart DB Cluster

postgres@host:~$ pg_ctlcluster 9.4 main restart

Uninstall

rm -rf /var/lib/postgresql/.local/lib/python3.4/site-packages/pysar*

Example Usage

user@host:~$ createdb sysstat
user@host:~$ psql sysstat
sysstat=# CREATE EXTENSION multicorn;
CREATE EXTENSION
sysstat=# \i /tmp/pysar/sql/create_server_pysar_devio.sql
CREATE SERVER
sysstat=# \i /tmp/pysar/sql/create_table_device_io.sql
CREATE FOREIGN TABLE
sysstat=# SELECT * FROM device_io;

pysar-1's People

Contributors

corriander avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.