Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multiple databases and queries handling in dbi and mysql modules #94

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions collectd/files/dbi.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
LoadPlugin dbi

<Plugin dbi>
{%- for query in collectd_settings.plugins.dbi.queries %}
<Query {{ query.name }}>
{%- for name, query in collectd_settings.plugins.dbi.queries.items() | sort %}
<Query {{ name }}>
Statement "{{ query.statement }}"
{%- for res in query.results %}
<Result>
Expand All @@ -30,8 +30,8 @@ LoadPlugin dbi
</Query>
{%- endfor %}

{%- for db in collectd_settings.plugins.dbi.databases %}
<Database {{ db.name }}>
{%- for name, db in collectd_settings.plugins.dbi.databases.items() | sort %}
<Database {{ name }}>
Driver {{ db.driver }}
{%- for driverOption in db.driverOptions %}
DriverOption "{{ driverOption.name }}" {{ driverOption.value }}
Expand Down
4 changes: 2 additions & 2 deletions collectd/files/mysql.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ LoadPlugin mysql

<Plugin mysql>

{% for db in collectd_settings.plugins.mysql.databases %}
<Database "{{ db.name }}">
{% for name, db in collectd_settings.plugins.mysql.databases.items() | sort %}
<Database "{{ name }}">
Host "{{ db.host }}"
{%- if db.port is defined and db.port %}
Port "{{ db.port }}"
Expand Down
12 changes: 6 additions & 6 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ collectd:
pass: pass
dbi:
queries:
- name: mysql_user_connections
mysql_user_connections:
statement: SELECT user, count(*) as nof_connections FROM information_schema.processlist GROUP BY user
results:
- type: gauge
instancePrefix: mysql_user_connections
instancesFrom: user
valuesFrom: nof_connections
databases:
- name: name
name:
driver: mysql
queries:
- mysql_user_connections
Expand All @@ -72,14 +72,14 @@ collectd:
password: 'password'
mysql:
databases:
- host: 'foo'
mydb:
host: 'foo'
port: '3306'
user: 'myuser'
pass: 'mypass'
name: 'mydb'
masterstats: true
- host: 'foo'
name: 'mydb'
mydb:
host: 'foo'
socket: '/var/run/mysql/mysqld.sock'
slavestats: true
slavenotifications: true
Expand Down