From c5e6fbcfdf2783c43d983ec236af130a73acc427 Mon Sep 17 00:00:00 2001 From: pz2891 Date: Fri, 20 Aug 2021 16:58:28 +0200 Subject: [PATCH] Configuration for monitoring APC PDU --- monitoring.yml | 3 + roles/prometheus/tasks/main.yml | 15 +- roles/prometheus/templates/prometheus.yml.j2 | 17 ++ roles/prometheus/templates/snmp.yml.j2 | 66 +++++ .../prometheus/templates/snmp_apc_pdu.yml.j2 | 68 +++++ .../templates/snmp_procurve_switcs.yml.j2 | 72 +++++ .../templates/snmp_ubiquiti_unifi.yml.j2 | 268 ++++++++++++++++++ 7 files changed, 506 insertions(+), 3 deletions(-) create mode 100644 roles/prometheus/templates/snmp_apc_pdu.yml.j2 create mode 100644 roles/prometheus/templates/snmp_procurve_switcs.yml.j2 create mode 100644 roles/prometheus/templates/snmp_ubiquiti_unifi.yml.j2 diff --git a/monitoring.yml b/monitoring.yml index 629352f..16c0981 100755 --- a/monitoring.yml +++ b/monitoring.yml @@ -58,6 +58,8 @@ prometheus_alertmanager: docker-ovh.adm.auro.re:9093 snmp_unifi_password: "{{ vault_snmp_unifi_password }}" snmp_switch_community: "{{ vault_snmp_switch_community }}" + snmp_pdu_user: "{{ vault_snmp_pdu_user }}" + snmp_pdu_password: "{{ vault_snmp_pdu_password }}" # Prometheus targets.json prometheus_targets: @@ -67,6 +69,7 @@ - targets: "{{ groups['gs_unifi'] | list | sort }}" prometheus_ups_snmp_targets: - ups-gk-1.ups.auro.re + prometheus_pdu_snmp_targets: - pdu-ga-1.ups.auro.re roles: - prometheus diff --git a/roles/prometheus/tasks/main.yml b/roles/prometheus/tasks/main.yml index f4a5b04..790c108 100644 --- a/roles/prometheus/tasks/main.yml +++ b/roles/prometheus/tasks/main.yml @@ -50,14 +50,16 @@ line: "ARGS=\"--web.listen-address=127.0.0.1:9116\"" notify: Restart prometheus-snmp-exporter -# This file store SNMP OIDs +# These files store SNMP OIDs - name: Configure Prometheus snmp-exporter template: - src: snmp.yml.j2 - dest: /etc/prometheus/snmp.yml + src: "{{ item }}.j2" + dest: "/etc/prometheus/{{ item }}" owner: prometheus group: prometheus mode: u=r,g=r,o= + loop: + - snmp.yml notify: Restart prometheus-snmp-exporter # We don't need to restart Prometheus when updating nodes @@ -103,6 +105,13 @@ mode: 0644 when: prometheus_postgres_targets is defined +- name: Configure Prometheus apc_pdu monitoring + copy: + content: "{{ [{'targets': prometheus_pdu_snmp_targets }] | to_nice_json }}\n" + dest: /etc/prometheus/targets_apc_pdu_snmp.json + mode: 0644 + when: prometheus_pdu_snmp_targets is defined + - name: Activate prometheus service systemd: name: prometheus diff --git a/roles/prometheus/templates/prometheus.yml.j2 b/roles/prometheus/templates/prometheus.yml.j2 index bae1d2b..4400de3 100644 --- a/roles/prometheus/templates/prometheus.yml.j2 +++ b/roles/prometheus/templates/prometheus.yml.j2 @@ -123,4 +123,21 @@ scrape_configs: - source_labels: [__param_target] target_label: __address__ replacement: '$1:9187' + + - job_name: apc_pdu_snmp + file_sd_configs: + - files: + - '/etc/prometheus/targets_apc_pdu_snmp.json' + metrics_path: /snmp + params: + module: + - apc_pdu + relabel_configs: + - source_labels: [__address__] + target_label: __param_target + - source_labels: [__param_target] + target_label: instance + - target_label: __address__ + replacement: 127.0.0.1:9116 + ... diff --git a/roles/prometheus/templates/snmp.yml.j2 b/roles/prometheus/templates/snmp.yml.j2 index cd8abd0..5ed5fa1 100644 --- a/roles/prometheus/templates/snmp.yml.j2 +++ b/roles/prometheus/templates/snmp.yml.j2 @@ -416,4 +416,70 @@ ubiquiti_unifi: auth_protocol: SHA priv_protocol: AES priv_password: {{ snmp_unifi_password }} + + +apc_pdu: + walk: + - 1.3.6.1.4.1.318.1.1.26.10.2.2.1.8 + - 1.3.6.1.4.1.318.1.1.26.4.3.1.4 + - 1.3.6.1.4.1.318.1.1.26.4.3.1.5 + - 1.3.6.1.4.1.318.1.1.26.4.3.1.6 + - 1.3.6.1.4.1.318.1.1.26.6.3.1.9 + - 1.3.6.1.4.1.318.1.1.26.9.4.3.1.7 + metrics: + - name: rPDU2SensorTempHumidityStatusTempC + oid: 1.3.6.1.4.1.318.1.1.26.10.2.2.1.8 + type: gauge + help: Sensor temperature reading in tenths of degrees Celsius - 1.3.6.1.4.1.318.1.1.26.10.2.2.1.8 + indexes: + - labelname: rPDU2SensorTempHumidityStatusIndex + type: gauge + - name: rPDU2DeviceStatusLoadState + oid: 1.3.6.1.4.1.318.1.1.26.4.3.1.4 + type: gauge + help: Indicates the present load status of the Rack PDU - 1.3.6.1.4.1.318.1.1.26.4.3.1.4 + indexes: + - labelname: rPDU2DeviceStatusIndex + type: gauge + - name: rPDU2DeviceStatusPower + oid: 1.3.6.1.4.1.318.1.1.26.4.3.1.5 + type: gauge + help: The power consumption of the Rack PDU load in hundredths of kilowatts - + 1.3.6.1.4.1.318.1.1.26.4.3.1.5 + indexes: + - labelname: rPDU2DeviceStatusIndex + type: gauge + - name: rPDU2DeviceStatusPeakPower + oid: 1.3.6.1.4.1.318.1.1.26.4.3.1.6 + type: gauge + help: The peak power consumption of the Rack PDU load in hundredths of kilowatts + - 1.3.6.1.4.1.318.1.1.26.4.3.1.6 + indexes: + - labelname: rPDU2DeviceStatusIndex + type: gauge + - name: rPDU2PhaseStatusPowerFactor + oid: 1.3.6.1.4.1.318.1.1.26.6.3.1.9 + type: gauge + help: Indicates the load power factor, in hundredths, of the Rack PDU phase being + queried - 1.3.6.1.4.1.318.1.1.26.6.3.1.9 + indexes: + - labelname: rPDU2PhaseStatusIndex + type: gauge + - name: rPDU2OutletMeteredStatusPower + oid: 1.3.6.1.4.1.318.1.1.26.9.4.3.1.7 + type: gauge + help: Indicates the power draw of the load on the Rack PDU outlet being queried + - 1.3.6.1.4.1.318.1.1.26.9.4.3.1.7 + indexes: + - labelname: rPDU2OutletMeteredStatusIndex + type: gauge + version: 3 + auth: + security_level: authPriv + username: {{ snmp_pdu_user }} + password: {{ snmp_pdu_password }} + auth_protocol: SHA + priv_protocol: AES + priv_password: {{ snmp_pdu_password }} + ... diff --git a/roles/prometheus/templates/snmp_apc_pdu.yml.j2 b/roles/prometheus/templates/snmp_apc_pdu.yml.j2 new file mode 100644 index 0000000..0fe4aa3 --- /dev/null +++ b/roles/prometheus/templates/snmp_apc_pdu.yml.j2 @@ -0,0 +1,68 @@ +--- +{{ ansible_managed | comment }} + +apc_pdu: + walk: + - 1.3.6.1.4.1.318.1.1.26.10.2.2.1.8 + - 1.3.6.1.4.1.318.1.1.26.4.3.1.4 + - 1.3.6.1.4.1.318.1.1.26.4.3.1.5 + - 1.3.6.1.4.1.318.1.1.26.4.3.1.6 + - 1.3.6.1.4.1.318.1.1.26.6.3.1.9 + - 1.3.6.1.4.1.318.1.1.26.9.4.3.1.7 + metrics: + - name: rPDU2SensorTempHumidityStatusTempC + oid: 1.3.6.1.4.1.318.1.1.26.10.2.2.1.8 + type: gauge + help: Sensor temperature reading in tenths of degrees Celsius - 1.3.6.1.4.1.318.1.1.26.10.2.2.1.8 + indexes: + - labelname: rPDU2SensorTempHumidityStatusIndex + type: gauge + - name: rPDU2DeviceStatusLoadState + oid: 1.3.6.1.4.1.318.1.1.26.4.3.1.4 + type: gauge + help: Indicates the present load status of the Rack PDU - 1.3.6.1.4.1.318.1.1.26.4.3.1.4 + indexes: + - labelname: rPDU2DeviceStatusIndex + type: gauge + - name: rPDU2DeviceStatusPower + oid: 1.3.6.1.4.1.318.1.1.26.4.3.1.5 + type: gauge + help: The power consumption of the Rack PDU load in hundredths of kilowatts - + 1.3.6.1.4.1.318.1.1.26.4.3.1.5 + indexes: + - labelname: rPDU2DeviceStatusIndex + type: gauge + - name: rPDU2DeviceStatusPeakPower + oid: 1.3.6.1.4.1.318.1.1.26.4.3.1.6 + type: gauge + help: The peak power consumption of the Rack PDU load in hundredths of kilowatts + - 1.3.6.1.4.1.318.1.1.26.4.3.1.6 + indexes: + - labelname: rPDU2DeviceStatusIndex + type: gauge + - name: rPDU2PhaseStatusPowerFactor + oid: 1.3.6.1.4.1.318.1.1.26.6.3.1.9 + type: gauge + help: Indicates the load power factor, in hundredths, of the Rack PDU phase being + queried - 1.3.6.1.4.1.318.1.1.26.6.3.1.9 + indexes: + - labelname: rPDU2PhaseStatusIndex + type: gauge + - name: rPDU2OutletMeteredStatusPower + oid: 1.3.6.1.4.1.318.1.1.26.9.4.3.1.7 + type: gauge + help: Indicates the power draw of the load on the Rack PDU outlet being queried + - 1.3.6.1.4.1.318.1.1.26.9.4.3.1.7 + indexes: + - labelname: rPDU2OutletMeteredStatusIndex + type: gauge + version: 3 + auth: + security_level: authPriv + username: {{ snmp_pdu_user }} + password: {{ snmp_pdu_password }} + auth_protocol: SHA + priv_protocol: AES + priv_password: {{ snmp_pdu_password }} + +... diff --git a/roles/prometheus/templates/snmp_procurve_switcs.yml.j2 b/roles/prometheus/templates/snmp_procurve_switcs.yml.j2 new file mode 100644 index 0000000..61e2937 --- /dev/null +++ b/roles/prometheus/templates/snmp_procurve_switcs.yml.j2 @@ -0,0 +1,72 @@ +--- +{{ ansible_managed | comment }} + +procurve_switch: + walk: + - 1.3.6.1.2.1.31.1.1.1.10 + - 1.3.6.1.2.1.31.1.1.1 + - 1.3.6.1.2.1.2.2.1.2 + - 1.3.6.1.2.1.31.1.1.1.18 + get: + - 1.3.6.1.2.1.1.3.0 + - 1.3.6.1.2.1.1.5.0 + - 1.3.6.1.2.1.1.6.0 + metrics: + - name: sysUpTime + oid: 1.3.6.1.2.1.1.3 + type: gauge + help: The time (in hundredths of a second) since the network management + portion of the system was last re-initialized. - 1.3.6.1.2.1.1.3 + - name: sysName + oid: 1.3.6.1.2.1.1.5 + type: DisplayString + help: An administratively-assigned name for this managed node + - 1.3.6.1.2.1.1.5 + - name: sysLocation + oid: 1.3.6.1.2.1.1.6 + type: DisplayString + help: The physical location of this node (e.g., 'telephone closet, 3rd + floor') - 1.3.6.1.2.1.1.6 + - name: ifHCOutOctets + oid: 1.3.6.1.2.1.31.1.1.1.10 + type: counter + help: The total number of octets transmitted out of the interface, + including framing characters - 1.3.6.1.2.1.31.1.1.1.10 + indexes: + - labelname: ifIndex + type: gauge + lookups: + - labels: + - ifIndex + labelname: ifDescr + oid: 1.3.6.1.2.1.2.2.1.2 + type: DisplayString + - labels: + - ifIndex + labelname: ifName + oid: 1.3.6.1.2.1.31.1.1.1.1 + type: DisplayString + - name: ifHCInOctets + oid: 1.3.6.1.2.1.31.1.1.1.6 + type: counter + help: The total number of octets received on the interface, including + framing characters - 1.3.6.1.2.1.31.1.1.1.6 + indexes: + - labelname: ifIndex + type: gauge + lookups: + - labels: + - ifIndex + labelname: ifDescr + oid: 1.3.6.1.2.1.2.2.1.2 + type: DisplayString + - labels: + - ifIndex + labelname: ifName + oid: 1.3.6.1.2.1.31.1.1.1.1 + type: DisplayString + version: 2 + auth: + community: "{{ snmp_switch_community }}" + +... diff --git a/roles/prometheus/templates/snmp_ubiquiti_unifi.yml.j2 b/roles/prometheus/templates/snmp_ubiquiti_unifi.yml.j2 new file mode 100644 index 0000000..f6793eb --- /dev/null +++ b/roles/prometheus/templates/snmp_ubiquiti_unifi.yml.j2 @@ -0,0 +1,268 @@ +--- +{{ ansible_managed | comment }} + +ubiquiti_unifi: + walk: + - 1.3.6.1.4.1.41112.1.6 + get: + - 1.3.6.1.2.1.1.5.0 + - 1.3.6.1.2.1.1.6.0 + metrics: +# Pour faire une WifiMap un jour, on peut entrer la location dans la conf des bornes +# - name: sysLocation +# oid: 1.3.6.1.2.1.1.6 +# type: DisplayString +# help: The physical location of this node (e.g., 'telephone closet, 3rd floor') +# - 1.3.6.1.2.1.1.6 + - name: unifiVapIndex + oid: 1.3.6.1.4.1.41112.1.6.1.2.1.1 + type: gauge + help: ' - 1.3.6.1.4.1.41112.1.6.1.2.1.1' + indexes: + - labelname: unifiVapIndex + type: gauge + - name: unifiVapChannel + oid: 1.3.6.1.4.1.41112.1.6.1.2.1.4 + type: gauge + help: ' - 1.3.6.1.4.1.41112.1.6.1.2.1.4' + indexes: + - labelname: unifiVapIndex + type: gauge + - name: unifiVapEssId + oid: 1.3.6.1.4.1.41112.1.6.1.2.1.6 + type: DisplayString + help: ' - 1.3.6.1.4.1.41112.1.6.1.2.1.6' + indexes: + - labelname: unifiVapIndex + type: gauge + - name: unifiVapName + oid: 1.3.6.1.4.1.41112.1.6.1.2.1.7 + type: DisplayString + help: ' - 1.3.6.1.4.1.41112.1.6.1.2.1.7' + indexes: + - labelname: unifiVapIndex + type: gauge + - name: unifi_vap_num_stations + oid: 1.3.6.1.4.1.41112.1.6.1.2.1.8 + type: gauge + help: ' - 1.3.6.1.4.1.41112.1.6.1.2.1.8' + indexes: + - labelname: unifi_vap_index + type: gauge + lookups: + - labels: [unifi_vap_index] + labelname: unifi_vap_essid + oid: 1.3.6.1.4.1.41112.1.6.1.2.1.6 + type: DisplayString + - labels: [unifi_vap_index] + labelname: unifi_vap_radio + oid: 1.3.6.1.4.1.41112.1.6.1.2.1.9 + type: DisplayString + - labels: [] + labelname: unifi_vap_index +# - name: unifiVapNumStations +# oid: 1.3.6.1.4.1.41112.1.6.1.2.1.8 +# type: gauge +# help: ' - 1.3.6.1.4.1.41112.1.6.1.2.1.8' +# indexes: +# - labelname: unifiVapIndex +# type: gauge + - name: unifiVapRadio + oid: 1.3.6.1.4.1.41112.1.6.1.2.1.9 + type: DisplayString + help: ' - 1.3.6.1.4.1.41112.1.6.1.2.1.9' + indexes: + - labelname: unifiVapIndex + type: gauge + - name: unifiVapRxBytes + oid: 1.3.6.1.4.1.41112.1.6.1.2.1.10 + type: counter + help: ' - 1.3.6.1.4.1.41112.1.6.1.2.1.10' + indexes: + - labelname: unifiVapIndex + type: gauge + - name: unifiVapRxCrypts + oid: 1.3.6.1.4.1.41112.1.6.1.2.1.11 + type: counter + help: ' - 1.3.6.1.4.1.41112.1.6.1.2.1.11' + indexes: + - labelname: unifiVapIndex + type: gauge + - name: unifiVapRxDropped + oid: 1.3.6.1.4.1.41112.1.6.1.2.1.12 + type: counter + help: ' - 1.3.6.1.4.1.41112.1.6.1.2.1.12' + indexes: + - labelname: unifiVapIndex + type: gauge + - name: unifiVapRxErrors + oid: 1.3.6.1.4.1.41112.1.6.1.2.1.13 + type: counter + help: ' - 1.3.6.1.4.1.41112.1.6.1.2.1.13' + indexes: + - labelname: unifiVapIndex + type: gauge + - name: unifiVapRxFrags + oid: 1.3.6.1.4.1.41112.1.6.1.2.1.14 + type: counter + help: ' - 1.3.6.1.4.1.41112.1.6.1.2.1.14' + indexes: + - labelname: unifiVapIndex + type: gauge + - name: unifiVapRxPackets + oid: 1.3.6.1.4.1.41112.1.6.1.2.1.15 + type: counter + help: ' - 1.3.6.1.4.1.41112.1.6.1.2.1.15' + indexes: + - labelname: unifiVapIndex + type: gauge + - name: unifiVapTxBytes + oid: 1.3.6.1.4.1.41112.1.6.1.2.1.16 + type: counter + help: ' - 1.3.6.1.4.1.41112.1.6.1.2.1.16' + indexes: + - labelname: unifiVapIndex + type: gauge + - name: unifiVapTxDropped + oid: 1.3.6.1.4.1.41112.1.6.1.2.1.17 + type: counter + help: ' - 1.3.6.1.4.1.41112.1.6.1.2.1.17' + indexes: + - labelname: unifiVapIndex + type: gauge + - name: unifiVapTxErrors + oid: 1.3.6.1.4.1.41112.1.6.1.2.1.18 + type: counter + help: ' - 1.3.6.1.4.1.41112.1.6.1.2.1.18' + indexes: + - labelname: unifiVapIndex + type: gauge + - name: unifiVapTxPackets + oid: 1.3.6.1.4.1.41112.1.6.1.2.1.19 + type: counter + help: ' - 1.3.6.1.4.1.41112.1.6.1.2.1.19' + indexes: + - labelname: unifiVapIndex + type: gauge + - name: unifiVapTxRetries + oid: 1.3.6.1.4.1.41112.1.6.1.2.1.20 + type: counter + help: ' - 1.3.6.1.4.1.41112.1.6.1.2.1.20' + indexes: + - labelname: unifiVapIndex + type: gauge + - name: unifiVapTxPower + oid: 1.3.6.1.4.1.41112.1.6.1.2.1.21 + type: gauge + help: ' - 1.3.6.1.4.1.41112.1.6.1.2.1.21' + indexes: + - labelname: unifiVapIndex + type: gauge + - name: unifiVapUp + oid: 1.3.6.1.4.1.41112.1.6.1.2.1.22 + type: gauge + help: ' - 1.3.6.1.4.1.41112.1.6.1.2.1.22' + indexes: + - labelname: unifiVapIndex + type: gauge + - name: unifiVapUsage + oid: 1.3.6.1.4.1.41112.1.6.1.2.1.23 + type: DisplayString + help: guest or regular user - 1.3.6.1.4.1.41112.1.6.1.2.1.23 + indexes: + - labelname: unifiVapIndex + type: gauge + - name: unifiIfIndex + oid: 1.3.6.1.4.1.41112.1.6.2.1.1.1 + type: gauge + help: ' - 1.3.6.1.4.1.41112.1.6.2.1.1.1' + indexes: + - labelname: unifiIfIndex + type: gauge + - name: unifiIfName + oid: 1.3.6.1.4.1.41112.1.6.2.1.1.5 + type: DisplayString + help: ' - 1.3.6.1.4.1.41112.1.6.2.1.1.5' + indexes: + - labelname: unifiIfIndex + type: gauge + - name: unifiIfRxBytes + oid: 1.3.6.1.4.1.41112.1.6.2.1.1.6 + type: counter + help: ' - 1.3.6.1.4.1.41112.1.6.2.1.1.6' + indexes: + - labelname: unifiIfIndex + type: gauge + - name: unifiIfRxDropped + oid: 1.3.6.1.4.1.41112.1.6.2.1.1.7 + type: counter + help: ' - 1.3.6.1.4.1.41112.1.6.2.1.1.7' + indexes: + - labelname: unifiIfIndex + type: gauge + - name: unifiIfRxError + oid: 1.3.6.1.4.1.41112.1.6.2.1.1.8 + type: counter + help: ' - 1.3.6.1.4.1.41112.1.6.2.1.1.8' + indexes: + - labelname: unifiIfIndex + type: gauge + - name: unifiIfRxMulticast + oid: 1.3.6.1.4.1.41112.1.6.2.1.1.9 + type: counter + help: ' - 1.3.6.1.4.1.41112.1.6.2.1.1.9' + indexes: + - labelname: unifiIfIndex + type: gauge + - name: unifiIfRxPackets + oid: 1.3.6.1.4.1.41112.1.6.2.1.1.10 + type: counter + help: ' - 1.3.6.1.4.1.41112.1.6.2.1.1.10' + indexes: + - labelname: unifiIfIndex + type: gauge + - name: unifiIfTxBytes + oid: 1.3.6.1.4.1.41112.1.6.2.1.1.12 + type: counter + help: ' - 1.3.6.1.4.1.41112.1.6.2.1.1.12' + indexes: + - labelname: unifiIfIndex + type: gauge + - name: unifiIfTxDropped + oid: 1.3.6.1.4.1.41112.1.6.2.1.1.13 + type: counter + help: ' - 1.3.6.1.4.1.41112.1.6.2.1.1.13' + indexes: + - labelname: unifiIfIndex + type: gauge + - name: unifiIfTxError + oid: 1.3.6.1.4.1.41112.1.6.2.1.1.14 + type: counter + help: ' - 1.3.6.1.4.1.41112.1.6.2.1.1.14' + indexes: + - labelname: unifiIfIndex + type: gauge + - name: unifiIfTxPackets + oid: 1.3.6.1.4.1.41112.1.6.2.1.1.15 + type: counter + help: ' - 1.3.6.1.4.1.41112.1.6.2.1.1.15' + indexes: + - labelname: unifiIfIndex + type: gauge + - name: unifiApSystemModel + oid: 1.3.6.1.4.1.41112.1.6.3.3 + type: DisplayString + help: ' - 1.3.6.1.4.1.41112.1.6.3.3' + - name: unifiApSystemUptime + oid: 1.3.6.1.4.1.41112.1.6.3.5 + type: counter + help: ' - 1.3.6.1.4.1.41112.1.6.3.5' + version: 3 + auth: + security_level: authPriv + username: snmp_prometheus + password: {{ snmp_unifi_password }} + auth_protocol: SHA + priv_protocol: AES + priv_password: {{ snmp_unifi_password }} +...