From 4b8f39ae7fb3eb6b030d96978e307f88bfd356a5 Mon Sep 17 00:00:00 2001 From: rene Date: Tue, 22 Mar 2022 18:56:15 +0100 Subject: [PATCH] snmpd extends for postgres --- roles/database/tasks/configure_snmpd.yml | 45 +++++++++++++++++++ .../database/tasks/install_check_postgres.yml | 23 ++++++++++ 2 files changed, 68 insertions(+) create mode 100644 roles/database/tasks/configure_snmpd.yml create mode 100644 roles/database/tasks/install_check_postgres.yml diff --git a/roles/database/tasks/configure_snmpd.yml b/roles/database/tasks/configure_snmpd.yml new file mode 100644 index 0000000..f63ee55 --- /dev/null +++ b/roles/database/tasks/configure_snmpd.yml @@ -0,0 +1,45 @@ +- name: database | snmpd | get script + get_url: + url: "https://github.com/librenms/librenms-agent/raw/master/snmp/postgres" + dest: "/etc/snmp/postgres" + mode: "0755" + owner: "root" + group: "root" + when: postgres == true + +- include_tasks: install_check_postgres.yml + when: postgres == true + +- name: database | snmpd | get script + get_url: + url: "https://github.com/librenms/librenms-agent/raw/master/snmp/mysql" + dest: "/etc/snmp/mysql" + mode: "0755" + owner: "root" + group: "root" + when: mysql == true + +- name: database | snmpd | create configuration + template: + src: "mysql.cnf.j2" + dest: "/etc/snmp/mysql.cnf" + mode: "0644" + when: mysql == true + +- name: database | snmpd | configure extend + lineinfile: + path: "/etc/snmp/snmpd.conf" + state: present + line: "extend postgres /etc/snmp/postgres" + insertafter: "# SECTION: Extends" + notify: restart_snmpd + when: postgres == true + +- name: database | snmpd | configure extend + lineinfile: + path: "/etc/snmp/snmpd.conf" + state: present + line: "extend postgres /etc/snmp/postgres" + insertafter: "# SECTION: Extends" + notify: restart_snmpd + when: mysql == true \ No newline at end of file diff --git a/roles/database/tasks/install_check_postgres.yml b/roles/database/tasks/install_check_postgres.yml new file mode 100644 index 0000000..531da27 --- /dev/null +++ b/roles/database/tasks/install_check_postgres.yml @@ -0,0 +1,23 @@ +- name: database | snmpd | get script + git: + repo: "https://github.com/bucardo/check_postgres.git" + dest: "~/check_postgres" + +- name: database | snmpd | prepare script + command: + cmd: "perl Makefile.PL" + creates: "~/check_postgres/Makefile" + chdir: "~/check_postgres" + +- name: database | snmpd | build script + command: + cmd: "make" + chdir: "~/check_postgres" + creates: "~/check_postgres/pm_to_blib" + +- name: database | snmpd | install script + command: + cmd: "make install" + chdir: "~/check_postgres" + creates: "/usr/local/bin/check_postgres.pl" + become: true