-
Notifications
You must be signed in to change notification settings - Fork 5
Zabbix: Add idle_connections monitoring item #1
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
base: staging
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
|
|
||
|
|
||
| #!/bin/bash | ||
|
|
||
| # Managed by Ansible : don't edit ! | ||
| # Purposes : checks some services locally (like kojira or others) and send status to zabbix | ||
| # Called by: cron | ||
| # | ||
|
|
||
| # Check idle_connections in PostgreSQL | ||
| cd /tmp # avoid dir_read issues with sudo | ||
| idle=$(sudo -u postgres psql koji -A -t -F" " \ | ||
| -c "select state, count(*) from pg_stat_activity where state = 'idle' and pid <> pg_backend_pid() group by 1 order by 1;" |\ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wondering (just another metric) selecting active, idle , others, and the three together == count() from pg_stat_activity , or just count() from pg_activity ? There can be time were there is no active connections and that's fine too (so sending zero)
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think all three are useful. I can probably do it as a single raw metric + dependant items in zabbix |
||
| cut -f2 -d" ") | ||
|
|
||
| zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k psql.idle_connections -o $idle >/dev/null 2>&1 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| - name: Add host in Zabbix UI | ||
| block: | ||
| - name: Configuring agent in Zabbix server | ||
| ansible.builtin.include_role: | ||
| name: zabbix-server | ||
| tasks_from: agent_config | ||
| vars: | ||
| zabbix_templates: "{{ psql_zabbix_templates }}" | ||
| zabbix_groups: "{{ psql_zabbix_groups }}" | ||
| tags: | ||
| - monitoring | ||
| delegate_to: "{{ zabbix_api_srv }}" | ||
| when: zabbix_api_srv is defined | ||
|
|
||
| - name: Distribute local PostgreSQL idle_connections check | ||
| copy: | ||
| src: files/psql-monitoring-checks.sh | ||
| dest: /usr/lib/zabbix/psql-monitoring-checks.sh | ||
| mode: 0750 | ||
| owner: root | ||
|
|
||
| - name: Zabbix cron jobs | ||
| ansible.builtin.cron: | ||
| name: PostgreSQL monitoring | ||
| job: /usr/lib/zabbix/psql-monitoring-checks.sh | ||
| minute: "*/5" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need/want to hardcode a db name for postgresql activity itself, as
kojidb doesn't exist everywhere :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, let me template that