Skip to content

Commit 3c717da

Browse files
committed
- OK, aggregation plugin is not going to work. am going to
rethink this into a total python plugin and just go all the way (as usual)
1 parent 57d6a68 commit 3c717da

File tree

3 files changed

+113
-61
lines changed

3 files changed

+113
-61
lines changed

sqlalchemy.conf

Lines changed: 106 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -26,62 +26,112 @@ LoadPlugin "network"
2626
</Plugin>
2727

2828

29+
LoadPlugin "aggregation"
30+
LoadPlugin "match_regex"
2931
<Plugin "aggregation">
30-
<Aggregation>
31-
# translate from:
32-
#
33-
# <host>/<plugin>-<program-name>/<type>-<process pid>
34-
#
35-
# hostname/sqlalchemy-nova/sqlalchemy_pool-12345
36-
# hostname/sqlalchemy-nova/sqlalchemy_pool-5839
37-
# hostname/sqlalchemy-nova/sqlalchemy_pool-9905
38-
# hostname/sqlalchemy-neutron/sqlalchemy_pool-19385
39-
# hostname/sqlalchemy-neutron/sqlalchemy_pool-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-
32+
<Aggregation>
33+
Plugin "sqlalchemy"
34+
Type "sqlalchemy_numpools"
35+
GroupBy "Host"
36+
SetPlugin "sqlalchemy_aggregated"
37+
SetTypeInstance "processes"
38+
CalculateNum true
39+
</Aggregation>
40+
<Aggregation>
41+
Plugin "sqlalchemy"
42+
Type "sqlalchemy_numpools"
43+
GroupBy "Host"
44+
SetPlugin "sqlalchemy_aggregated"
45+
CalculateSum true
46+
</Aggregation>
47+
<Aggregation>
48+
Plugin "sqlalchemy"
49+
Type "sqlalchemy_checkedout"
50+
GroupBy "Host"
51+
SetPlugin "sqlalchemy_aggregated"
52+
CalculateSum true
53+
CalculateAverage true
54+
</Aggregation>
55+
<Aggregation>
56+
Plugin "sqlalchemy"
57+
Type "sqlalchemy_checkedin"
58+
GroupBy "Host"
59+
SetPlugin "sqlalchemy_aggregated"
60+
CalculateSum true
61+
CalculateAverage true
62+
</Aggregation>
63+
<Aggregation>
64+
Plugin "sqlalchemy"
65+
Type "sqlalchemy_detached"
66+
GroupBy "Host"
67+
SetPlugin "sqlalchemy_aggregated"
68+
CalculateSum true
69+
CalculateAverage true
70+
</Aggregation>
71+
<Aggregation>
72+
Plugin "sqlalchemy"
73+
Type "sqlalchemy_invalidated"
74+
GroupBy "Host"
75+
SetPlugin "sqlalchemy_aggregated"
76+
CalculateSum true
77+
CalculateAverage true
78+
</Aggregation>
79+
<Aggregation>
80+
Plugin "sqlalchemy"
81+
Type "sqlalchemy_connections"
82+
GroupBy "Host"
83+
SetPlugin "sqlalchemy_aggregated"
84+
CalculateSum true
85+
CalculateAverage true
86+
</Aggregation>
87+
<Aggregation>
88+
Plugin "sqlalchemy"
89+
Type "sqlalchemy_newconnections"
90+
GroupBy "Host"
91+
SetPlugin "sqlalchemy_aggregated"
92+
CalculateSum true
93+
CalculateAverage true
94+
</Aggregation>
95+
<Aggregation>
96+
Plugin "sqlalchemy"
97+
Type "sqlalchemy_checkouts"
98+
GroupBy "Host"
99+
SetPlugin "sqlalchemy_aggregated"
100+
CalculateSum true
101+
CalculateAverage true
102+
</Aggregation>
103+
<Aggregation>
104+
Plugin "sqlalchemy"
105+
Type "sqlalchemy_commits"
106+
GroupBy "Host"
107+
SetPlugin "sqlalchemy_aggregated"
108+
CalculateSum true
109+
CalculateAverage true
110+
</Aggregation>
111+
<Aggregation>
112+
Plugin "sqlalchemy"
113+
Type "sqlalchemy_rollbacks"
114+
GroupBy "Host"
115+
SetPlugin "sqlalchemy_aggregated"
116+
CalculateSum true
117+
CalculateAverage true
118+
</Aggregation>
119+
<Aggregation>
120+
Plugin "sqlalchemy"
121+
Type "sqlalchemy_invalidated"
122+
GroupBy "Host"
123+
SetPlugin "sqlalchemy_aggregated"
124+
CalculateSum true
125+
CalculateAverage true
126+
</Aggregation>
127+
<Aggregation>
128+
Plugin "sqlalchemy"
129+
Type "sqlalchemy_transactions"
130+
GroupBy "Host"
131+
SetPlugin "sqlalchemy_aggregated"
132+
CalculateSum true
133+
CalculateAverage true
134+
</Aggregation>
85135
</Plugin>
86136

87137
<Chain "PostCache">
@@ -97,4 +147,5 @@ LoadPlugin "network"
97147
</Target>
98148
Target stop
99149
</Rule>
150+
Target write
100151
</Chain>

sqlalchemy_collectd/sender.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ def __init__(self, hostname, stats_name):
2121
self.hostname = hostname
2222
self.stats_name = stats_name
2323

24-
def send(self, connection, collection_target, timestamp, pid):
24+
def send(self, connection, collection_target, timestamp, interval, pid):
2525
for collectd_type, sender in senders:
2626
message_sender = collectd.MessageSender(
2727
collectd_type, self.hostname, "sqlalchemy",
28-
plugin_instance=self.stats_name, type_instance=str(pid)
28+
plugin_instance=str(pid), type_instance=self.stats_name,
29+
interval=interval
2930
)
3031
value = sender(collection_target)
3132
message_sender.send(connection, timestamp, value)

sqlalchemy_collectd/worker.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ def _check_threads_started():
1818
if _WORKER_THREAD is None or _PID != ospid:
1919

2020
_PID = ospid
21-
_WORKER_THREAD = threading.Thread(target=_process)
21+
_WORKER_THREAD = threading.Thread(target=_process, args=(5, ))
2222
_WORKER_THREAD.daemon = True
2323
_WORKER_THREAD.start()
2424

2525

26-
def _process():
26+
def _process(interval):
2727
pid = os.getpid()
2828
log.info("Starting process thread in pid %s", pid)
2929

@@ -32,9 +32,9 @@ def _process():
3232
for (
3333
collection_target, connection,
3434
sender, last_called) in _collection_targets:
35-
if now - last_called[0] > 5: # TODO configurable send interval
35+
if now - last_called[0] > interval:
3636
last_called[0] = now
37-
sender.send(connection, collection_target, now, pid)
37+
sender.send(connection, collection_target, now, interval, pid)
3838

3939
time.sleep(.2)
4040

0 commit comments

Comments
 (0)