Skip to content

Commit

Permalink
change into a Python package and add specfile for RPM building
Browse files Browse the repository at this point in the history
  • Loading branch information
micah.yoder committed Jun 11, 2015
1 parent 64266d5 commit e001c60
Show file tree
Hide file tree
Showing 10 changed files with 236 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .gitignore
@@ -0,0 +1,58 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
bin/
build/
develop-eggs/
dist/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Translations
*.mo

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# Rope
.ropeproject

# Django stuff:
*.log
*.pot

# Sphinx documentation
docs/_build/

# RPM stuff
rpm-build/
rpms/

36 changes: 36 additions & 0 deletions 10-impstats.conf
@@ -0,0 +1,36 @@
# Switch back to default ruleset
$RuleSet RSYSLOG_DefaultRuleset

# Input Module to Generate Periodic Statistics of Internal Counters
# http://www.rsyslog.com/doc/impstats.html
# http://www.rsyslog.com/impstats-analyzer/
module(load="impstats" interval="60" severity="7" format="json")
module(load="omprog")

template (name="JustTheMSG" type="string" string="%msg%\n")

if $programname == "rsyslogd-pstats" then {
action(name="action-impstats" type="omfile" file="/var/log/rsyslogd-impstats.log"
# queue configuration
queue.type="LinkedList"
queue.checkpointinterval="0"
queue.discardmark="90"
queue.size="100"
queue.timeoutenqueue="10"
queue.dequeuebatchsize="50"
)

# monitoring template="JustTheMSG"
action(name="action-omprog-impstats" type="omprog" binary="/etc/zabbix/clientscripts/rsyslog-impstats.py" template="JustTheMSG"
# queue configuration
queue.type="LinkedList"
queue.checkpointinterval="0"
queue.discardmark="900"
queue.size="1000"
queue.timeoutenqueue="10"
queue.dequeuebatchsize="50"
)

stop
}

6 changes: 6 additions & 0 deletions MANIFEST.in
@@ -0,0 +1,6 @@
recursive-include zabbix_rsyslog
include README.md
include rsyslogdiscovery.conf
include 10-impstats.conf
include rsyslogd-impstats

49 changes: 49 additions & 0 deletions Makefile
@@ -0,0 +1,49 @@
PACKAGE := $(shell basename *.spec .spec)
ARCH = noarch
RPMBUILD = rpmbuild --define "_topdir %(pwd)/rpm-build" \
--define "_builddir %{_topdir}" \
--define "_rpmdir %(pwd)/rpms" \
--define "_srcrpmdir %{_rpmdir}" \
--define "_sourcedir %{_topdir}"
PYTHON = $(which python)

all: rpms

clean:
rm -rf dist/ build/ rpm-build/ rpms/
rm -rf docs/*.gz MANIFEST *~ *.egg-info
find . -name '*.pyc' -exec rm -f {} \;

#manpage:
# gzip -c docs/${PACKAGE}.1 > docs/${PACKAGE}.1.gz

build: clean
python setup.py build -f

install: build
python setup.py install -f

reinstall: uninstall install

uninstall: clean
rm -f /usr/bin/${PACKAGE}
rm -rf /usr/lib/python2.*/site-packages/${PACKAGE}

uninstall_rpms: clean
rpm -e ${PACKAGE}

sdist:
python setup.py sdist

prep_rpmbuild: build sdist
mkdir -p rpm-build
mkdir -p rpms
cp dist/*.gz rpm-build/

rpms: prep_rpmbuild
${RPMBUILD} -ba ${PACKAGE}.spec

srpm: prep_rpmbuild
${RPMBUILD} -bs ${PACKAGE}.spec


12 changes: 12 additions & 0 deletions rsyslogd-impstats
@@ -0,0 +1,12 @@
/var/log/rsyslogd-impstats.log {
missingok
sharedscripts
notifempty
daily
rotate 0
size 10M
postrotate
invoke-rc.d rsyslog rotate > /dev/null
endscript
}

2 changes: 2 additions & 0 deletions rsyslogdiscovery.conf
@@ -0,0 +1,2 @@
UserParameter=rsyslog.discovery[*],/usr/bin/rsyslog-impstats.py --discover $1

28 changes: 28 additions & 0 deletions setup.py
@@ -0,0 +1,28 @@
from setuptools import setup
from sys import path

path.insert(0, '.')

NAME = "zabbix_rsyslog"

if __name__ == "__main__":

setup(
name = NAME,
version = "1.0.0",
author = "facastagnini",
author_email = "",
url = "https://github.com/facastagnini/zabbix-rsyslog",
license = 'APL 2.0',
packages = [NAME],
package_dir = {NAME: NAME},
data_files = [ ('/etc/rsyslog.d', ['10-impstats.conf']),
('/etc/zabbix_agentd.d', ['rsyslogdiscovery.conf']),
('/etc/logrotate.d', ['rsyslogd-impstats']) ],
description = "Send rsyslog impstats output to zabbix",

entry_points={
'console_scripts': [ 'rsyslog-impstats.py = zabbix_rsyslog.rsyslog_impstats:main' ],
}
)

45 changes: 45 additions & 0 deletions zabbix_rsyslog.spec
@@ -0,0 +1,45 @@
%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}

%define module_name zabbix_rsyslog

Name: %{module_name}
Version: 1.0.0
Release: 4
Group: Applications/System
Summary: Send rsyslog queue stats to Zabbix

License: Apache 2.0
URL: https://github.com/facastagnini/zabbix-rsyslog
Source0: %{module_name}-%{version}.tar.gz

BuildArch: noarch
BuildRequires: python-setuptools
Requires: python-setuptools rsyslog
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

%description
Takes rsyslog's impstats, which shows various stats for all the action queues,
and sends them to Zabbix for monitoring.

%prep
%setup -q -n %{module_name}-%{version}


%build


%install
rm -rf $RPM_BUILD_ROOT
%{__python} setup.py install --root $RPM_BUILD_ROOT

%files
%doc README.md
%{python_sitelib}/*
%attr(0755,-,-) %{_bindir}/
%config %{_sysconfdir}/rsyslog.d/10-impstats.conf
%config %{_sysconfdir}/logrotate.d/rsyslogd-impstats
%config %{_sysconfdir}/zabbix_agentd.d/rsyslogdiscovery.conf

%changelog
* Wed Jun 10 2015 Micah Yoder
- Initial spec
Empty file added zabbix_rsyslog/__init__.py
Empty file.
File renamed without changes.

0 comments on commit e001c60

Please sign in to comment.