Skip to content

Commit

Permalink
packaging 2
Browse files Browse the repository at this point in the history
  • Loading branch information
pierky committed Jan 24, 2017
1 parent b477ea1 commit 66c7f0f
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 27 deletions.
9 changes: 9 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Changelog
=========

0.3.0
-----

- Multithreading support.

The ``ReaderThreads`` option in the plugin configuration file sets the number of threads used to process pmacct's output.
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include LICENSE
include README.rst
include CHANGES.rst
include MANIFEST.in
23 changes: 15 additions & 8 deletions README.md → README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,36 @@ pmacct-to-elasticsearch

Optionally, some **data transformations** can be configured, to allow pmacct-to-elasticsearch to **add or remove fields** to/from the output documents that are sent to ElasticSearch for indexing. These additional fields may be useful to enhance graphs and reports legibility, or to add a further level of aggregation or filtering.

## Installation
Installation
------------

Clone the repository and run the ./install script:
Install the program using pip:

pip install pmacct-to-elasticsearch

Then clone the repository and run the ./install script to setup your system:

# cd /usr/local/src/
# git clone https://github.com/pierky/pmacct-to-elasticsearch.git
# cd pmacct-to-elasticsearch/
# ./install

## Configuration
Configuration
-------------

Please refer to the [CONFIGURATION.md](CONFIGURATION.md) file. The [TRANSFORMATIONS.md](TRANSFORMATIONS.md) file contains details about data transformations configuration.

A simple tutorial on pmacct integration with ElasticSearch/Kibana using pmacct-to-elasticsearch can be found at http://blog.pierky.com/integration-of-pmacct-with-elasticsearch-and-kibana.

## Future work
Future work
-----------

- Improve performances by introducing multi-thread processing of input data.
- Add support of more pmacct output formats (CSV, Apache Avro, ...).
- Read input from stdin pipes too.

## Author
Author
------

Pier Carlo Chiodi - http://pierky.com/aboutme
Pier Carlo Chiodi - https://pierky.com/

Blog: http://blog.pierky.com Twitter: [@pierky](http://twitter.com/pierky)
Blog: https://blog.pierky.com/ Twitter: `@pierky <https://twitter.com/pierky>`_
31 changes: 14 additions & 17 deletions install
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,21 @@
# if you change the following CONF_DIR value you must
# change it in pmacct-to-elasticsearch too.
CONF_DIR=/etc/p2es

BIN_DIR=/usr/local/bin

if [ ! -e "$BIN_DIR/pmacct-to-elasticsearch" ]; then
echo "ERROR: pmacct-to-elasticsearch not found in $BIN_DIR."
echo ""
echo "If it is not installed, please install it using "
echo ""
echo " pip install pmacct-to-elasticsearch"
echo ""
echo "otherwise please consider editing this installation script"
echo "to set the BIN_DIR variable to the directory where "
echo "pmacct-to-elasticsearch is currently installed."
exit 1
fi

FORCE="no"

while getopts "F" opt; do
Expand All @@ -17,9 +29,8 @@ done
echo ""
echo "pmacct-to-elasticsearch installation script"
echo ""
echo "The following directories will be used for the installation:"
echo "The following directory will be used for the installation:"
echo " - $CONF_DIR: configuration files"
echo " - $BIN_DIR: the main pmacct-to-elasticsearch program"
echo ""
echo "With -F option, Replace all files without confirmation"
echo ""
Expand Down Expand Up @@ -110,20 +121,6 @@ fi

# -----------------------------------------------------------

echo -n "Copying pmacct-to-elasticsearch program to $BIN_DIR... "

cp pmacct-to-elasticsearch $BIN_DIR/

if [ $? -ne 0 ]; then
echo "ERROR - exit code $?"
exit 1
else
echo "OK"
chmod u+x $BIN_DIR/pmacct-to-elasticsearch
fi

# -----------------------------------------------------------

echo -n "Copying crontab job fragment to /etc/cron.d... "

if [ -d /etc/cron.d ]; then
Expand Down
1 change: 1 addition & 0 deletions pierky/p2es/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.3.0"
9 changes: 7 additions & 2 deletions scripts/pmacct-to-elasticsearch
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ import sys

from pierky.p2es.es import *
from pierky.p2es.transformations import *
from pierky.p2es.version import __version__
from pierky.p2es.workers import *

APP_NAME = 'pmacct-to-elasticsearch'
CURRENT_RELEASE = 'v0.3.0'
CURRENT_RELEASE = 'v{}'.format(__version__)

CONF_DIR = '/etc/p2es'

Expand Down Expand Up @@ -212,7 +213,11 @@ def log(lev, msg, exc_info=False):

def main():
parser = argparse.ArgumentParser(
description="pmacct-to-elasticsearch"
description="pmacct-to-elasticsearch {}: a tool to read "
"pmacct's output and to store it into "
"ElasticSearch.".format(CURRENT_RELEASE),
epilog="Copyright (c) {} - Pier Carlo Chiodi - "
"https://pierky.com".format(2017)
)
parser.add_argument(
"pluginname",
Expand Down
83 changes: 83 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import os
from os.path import abspath, dirname, join
from setuptools import setup, find_packages

"""
New release procedure
- edit pierky/p2es/version.py
- edit CHANGES.rst
- new files to be added to MANIFEST.in?
- python setup.py sdist
- twine upload dist/*
- git push
- edit new release on GitHub
"""

__version__ = None

# Allow setup.py to be run from any path
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))

# Get proper long description for package
current_dir = dirname(abspath(__file__))
description = open(join(current_dir, "README.rst")).read()
changes = open(join(current_dir, "CHANGES.rst")).read()
long_description = '\n\n'.join([description, changes])
exec(open(join(current_dir, "pierky/p2es/version.py")).read())

# Get the long description from README.md
setup(
name="pmacct-to-elasticsearch",
version=__version__,

packages=["pierky", "pierky.p2es"],
namespace_packages=["pierky"],
include_package_data=True,

license="MIT",
description="A Python script designed to read output from pmacct daemons, to process it and to store it into ElasticSearch.",
long_description=long_description,
url="https://github.com/pierky/pmacct-to-elasticsearch",
download_url="https://github.com/pierky/pmacct-to-elasticsearch",

author="Pier Carlo Chiodi",
author_email="[email protected]",
maintainer="Pier Carlo Chiodi",
maintainer_email="[email protected]",

install_requires=[
],

scripts=["scripts/pmacct-to-elasticsearch"],

keywords=['pmacct', 'NetFlow', 'accounting', 'BGP'],

classifiers=[
"Development Status :: 4 - Beta",

"Environment :: Console",

"Intended Audience :: Information Technology",
"Intended Audience :: Science/Research",
"Intended Audience :: System Administrators",
"Intended Audience :: Telecommunications Industry",


"Operating System :: POSIX",
"Operating System :: Unix",

"Programming Language :: Python :: 2.7",

"Topic :: Internet :: WWW/HTTP",
"Topic :: System :: Monitoring",
"Topic :: System :: Networking",
"Topic :: System :: Networking :: Monitoring",
],
)

0 comments on commit 66c7f0f

Please sign in to comment.