Skip to content

Commit 8d99f93

Browse files
committed
- initial commit
0 parents  commit 8d99f93

File tree

8 files changed

+434
-0
lines changed

8 files changed

+434
-0
lines changed

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
*.pyc
2+
*.pyo
3+
*.egg
4+
/build/
5+
/dist/
6+
/docs/build/output/
7+
*.orig
8+
*,cover
9+
/.tox
10+
.venv
11+
*.egg-info
12+
.coverage
13+
coverage.xml
14+
.*,cover
15+
*.class
16+
*.so
17+
*.patch
18+
test.py

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
This is the MIT license: http://www.opensource.org/licenses/mit-license.php
2+
3+
Copyright (C) 2018 by Michael Bayer.
4+
SQLAlchemy is a trademark of Michael Bayer.
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy of this
7+
software and associated documentation files (the "Software"), to deal in the Software
8+
without restriction, including without limitation the rights to use, copy, modify, merge,
9+
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
10+
to whom the Software is furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all copies or
13+
substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
17+
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
18+
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20+
DEALINGS IN THE SOFTWARE.

README.rst

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
===================
2+
sqlalchemy-collectd
3+
===================
4+
5+
Send statistics on SQLAlchemy connection and transaction use (and maybe other
6+
things in the future) to the `collectd <https://collectd.org/>`_ service. collectd is a widely
7+
used system statistics collection tool which is supported by virtually all
8+
graphing and monitoring tools.
9+
10+
11+
hostname/pid-12345/checkouts
12+
13+
host / plugin / plugininstance type / typeinstance
14+
15+
hostname/sqlalchemy-nova/checkouts-12345 derive value=value
16+
hostname/sqlalchemy-nova/transactions-12345 derive value=value
17+
hostname/sqlalchemy-nova/checkedout-12345 gauge
18+
hostname/sqlalchemy-nova/pooled-12345 gauge
19+
hostname/sqlalchemy-nova/connected-12345 gauge
20+
21+
22+
<Plugin "aggregation">
23+
<Aggregation>
24+
# translate from:
25+
#
26+
# <host>/<plugin>-<program-name>/<type>-<process pid>
27+
#
28+
# hostname/sqlalchemy-nova/checkouts-12345
29+
# hostname/sqlalchemy-nova/checkouts-5839
30+
# hostname/sqlalchemy-nova/checkouts-9905
31+
# hostname/sqlalchemy-neutron/checkouts-19385
32+
# hostname/sqlalchemy-neutron/checkouts-6991
33+
#
34+
# to:
35+
#
36+
# <host>/<plugin>-<program-name>/<type>
37+
#
38+
# hostname/sqlalchemy-nova/checkouts
39+
# hostname/sqlalchemy-neutron/checkouts
40+
41+
Plugin "sqlalchemy"
42+
43+
GroupBy "Host"
44+
GroupBy "PluginInstance"
45+
46+
CalculateNum true
47+
CalculateSum true
48+
CalculateAverage true
49+
</Aggregation>
50+
51+
<Aggregation>
52+
# translate from:
53+
#
54+
# <host>/<plugin>-<program-name>/<type>-<process pid>
55+
#
56+
# hostname/sqlalchemy-nova/checkouts-12345
57+
# hostname/sqlalchemy-nova/checkouts-5839
58+
# hostname/sqlalchemy-nova/checkouts-9905
59+
# hostname/sqlalchemy-neutron/checkouts-19385
60+
# hostname/sqlalchemy-neutron/checkouts-6991
61+
#
62+
# to:
63+
#
64+
# <host>/<plugin>-all/<type>
65+
#
66+
# hostname/sqlalchemy-all/checkouts
67+
68+
Plugin "sqlalchemy"
69+
70+
GroupBy "Host"
71+
SetPluginInstance "all"
72+
73+
CalculateSum true
74+
CalculateAverage true
75+
</Aggregation>
76+
77+
78+
</Plugin>
79+
80+
# send all SQLAlchemy messages to the aggregation plugin,
81+
# and don't send them anywhere else, thereby filtering out the
82+
# per-PID messages.
83+
LoadPlugin "match_regex"
84+
<Chain "PostCache">
85+
<Rule>
86+
<Match regex>
87+
Plugin "^sqlalchemy$"
88+
</Match>
89+
<Target write>
90+
Plugin "aggregation"
91+
</Target>
92+
Target stop
93+
</Rule>
94+
</Chain>
95+
96+
97+
[{"values":[1069067],"dstypes":["derive"],"dsnames":["value"],"time":1517512597.320,"interval":10.000,"host":"photon2","plugin":"cpu","plugin_instance":"2","type":"cpu","type_instance":"idle"}]
98+
99+
100+
[{"values":[0.31,0.34,0.28],"dstypes":["gauge","gauge","gauge"],"dsnames":["shortterm","midterm","longterm"],"time":1517512718.495,"interval":10.000,"host":"photon2","plugin":"load","plugin_instance":"","type":"load","type_instance":""}]
101+
102+
103+
hostname/pid-12345/checkins
104+
hostname/pid-12345/checkouts
105+
106+
107+
108+
{
109+
"host": "foobar.host",
110+
"plugin": "sqlalchemy",
111+
"plugin_instance": "<pid>",
112+
"type": "progname",
113+
"type_instance": "nova",
114+
"current_connections": 108, (gauge)
115+
"current_checkouts": 25, (gauge)
116+
"checkouts": 38975, (counter)
117+
"checkins": 38972, (counter)
118+
"transactions": 38932 (counter)
119+
}
120+
121+
122+
123+
[{"values":[0,0],"dstypes":["derive","derive"],"dsnames":["rx","tx"],"time":1517372403.790,"interval":10.000,"host":"photon2","plugin":"interface","plugin_instance":"virbr2","type":"if_errors","type_instance":""}]
124+
Jan 30 23:20:03 photon2 collectd[26416]: write_log values:
125+
[{"values":[0,0],"dstypes":["derive","derive"],"dsnames":["rx","tx"],"time":1517372403.790,"interval":10.000,"host":"photon2","plugin":"interface","plugin_instance":"virbr3-nic","type":"if_packets","type_instance":""}]
126+
Jan 30 23:20:03 photon2 collectd[26416]: write_log values:
127+
[{"values":[0,0],"dstypes":["derive","derive"],"dsnames":["rx","tx"],"time":1517372403.790,"interval":10.000,"host":"photon2","plugin":"interface","plugin_instance":"virbr2","type":"if_dropped","type_instance":""}]
128+
Jan 30 23:20:03 photon2 collectd[26416]: write_log values:
129+
[{"values":[0,0],"dstypes":["derive","derive"],"dsnames":["rx","tx"],"time":1517372403.790,"interval":10.000,"host":"photon2","plugin":"interface","plugin_instance":"virbr3-nic","type":"if_octets","type_instance":""}]
130+
131+
132+

setup.cfg

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[egg_info]
2+
3+
[pytest]
4+
addopts= --tb native -v -r fxX --ignore=sqlalchemy
5+
python_files=sqlalchemy_collectd/*/test_*.py
6+
7+
8+

setup.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from setuptools import setup
2+
from setuptools import find_packages
3+
import os
4+
import re
5+
6+
7+
with open(
8+
os.path.join(
9+
os.path.dirname(__file__), 'sqlalchemy_collectd', '__init__.py')
10+
) as file_:
11+
VERSION = re.compile(
12+
r".*__version__ = '(.*?)'", re.S).match(file_.read()).group(1)
13+
14+
15+
readme = os.path.join(os.path.dirname(__file__), 'README.rst')
16+
17+
requires = [
18+
'SQLAlchemy>=1.1',
19+
]
20+
21+
setup(
22+
name='sqlalchemy-collectd',
23+
version=VERSION,
24+
description="Send database connection pool stats to collectd",
25+
long_description=open(readme).read(),
26+
classifiers=[
27+
'Development Status :: 3 - Alpha',
28+
'Intended Audience :: Developers',
29+
'Programming Language :: Python',
30+
'Programming Language :: Python :: 3',
31+
'Topic :: Database :: Front-Ends',
32+
],
33+
keywords='SQLAlchemy collectd',
34+
author='Mike Bayer',
35+
author_email='[email protected]',
36+
url='http://github.org/zzzeek/sqlalchemy-collectd',
37+
license='MIT',
38+
packages=["sqlalchemy_collectd"],
39+
include_package_data=True,
40+
zip_safe=False,
41+
install_requires=requires,
42+
)

sqlalchemy.conf

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
LoadPlugin "aggregation"
2+
LoadPlugin "match_regex"
3+
LoadPlugin "network"
4+
5+
# set up network listening
6+
<Plugin network>
7+
8+
# change to 0.0.0.0 or a specific IP to allow
9+
# other hosts to send stats
10+
<Listen "127.0.0.1" "25826">
11+
# messages are not signed or encrypted
12+
SecurityLevel None
13+
14+
# optional
15+
# Interface eth0
16+
</Listen>
17+
18+
MaxPacketSize 1452
19+
20+
# proxy setup (client and server as above):
21+
Forward true
22+
23+
# statistics about the network plugin itself
24+
ReportStats false
25+
26+
</Plugin>
27+
28+
29+
<Plugin "aggregation">
30+
<Aggregation>
31+
# translate from:
32+
#
33+
# <host>/<plugin>-<program-name>/<type>-<process pid>
34+
#
35+
# hostname/sqlalchemy-nova/checkouts-12345
36+
# hostname/sqlalchemy-nova/checkouts-5839
37+
# hostname/sqlalchemy-nova/checkouts-9905
38+
# hostname/sqlalchemy-neutron/checkouts-19385
39+
# hostname/sqlalchemy-neutron/checkouts-6991
40+
#
41+
# to:
42+
#
43+
# <host>/<plugin>-<program-name>/<type>
44+
#
45+
# hostname/sqlalchemy-nova/checkouts
46+
# hostname/sqlalchemy-neutron/checkouts
47+
48+
Plugin "sqlalchemy"
49+
50+
GroupBy "Host"
51+
GroupBy "PluginInstance"
52+
53+
CalculateNum true
54+
CalculateSum true
55+
CalculateAverage true
56+
</Aggregation>
57+
58+
<Aggregation>
59+
# translate from:
60+
#
61+
# <host>/<plugin>-<program-name>/<type>-<process pid>
62+
#
63+
# hostname/sqlalchemy-nova/checkouts-12345
64+
# hostname/sqlalchemy-nova/checkouts-5839
65+
# hostname/sqlalchemy-nova/checkouts-9905
66+
# hostname/sqlalchemy-neutron/checkouts-19385
67+
# hostname/sqlalchemy-neutron/checkouts-6991
68+
#
69+
# to:
70+
#
71+
# <host>/<plugin>-all/<type>
72+
#
73+
# hostname/sqlalchemy-all/checkouts
74+
75+
Plugin "sqlalchemy"
76+
77+
GroupBy "Host"
78+
SetPluginInstance "all"
79+
80+
CalculateSum true
81+
CalculateAverage true
82+
</Aggregation>
83+
84+
85+
</Plugin>
86+
87+
<Chain "PostCache">
88+
<Rule>
89+
# send all SQLAlchemy messages to the aggregation plugin,
90+
# and don't send them anywhere else, thereby filtering out the
91+
# per-PID messages.
92+
<Match regex>
93+
Plugin "^sqlalchemy$"
94+
</Match>
95+
<Target write>
96+
Plugin "aggregation"
97+
</Target>
98+
Target stop
99+
</Rule>
100+
</Chain>

sqlalchemy_collectd/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = '0.0.1'

0 commit comments

Comments
 (0)