Skip to content

Commit

Permalink
switch from hddtemp to smartmontools
Browse files Browse the repository at this point in the history
hddtemp is used to monitor the hard disks temperature. This package is dormant and is not available on debian12.
It is recommended to use smartmontools instead.
This commit creates the snmp endpoint to retrieve the hard drive temperatures using Smartmontools, and remove the hddtemp deployment code from the playbooks.

Signed-off-by: Florent CARLI <florent.carli@rte-france.com>
  • Loading branch information
insatomcat committed Aug 17, 2023
1 parent e8e7bf2 commit 270b1b3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 27 deletions.
27 changes: 0 additions & 27 deletions roles/debian/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -410,33 +410,6 @@
line: "{{ logstash_server_ip }} logstash-seapath"
state: present

- name: lineinfile in /etc/default/hddtemp file for DISKS
lineinfile:
dest: /etc/default/hddtemp
regexp: '^DISKS='
line: "DISKS=\"{{ main_disk }} {{ ceph_osd_disk if ceph_osd_disk is defined else none }}\""
state: present
register: updatehddtemp1
- name: lineinfile in /etc/default/hddtemp file for RUN_DAEMON
lineinfile:
dest: /etc/default/hddtemp
regexp: '^RUN_DAEMON='
line: "RUN_DAEMON=\"true\""
state: present
register: updatehddtemp2
- name: lineinfile in /etc/default/hddtemp file for INTERFACE
lineinfile:
dest: /etc/default/hddtemp
regexp: '^INTERFACE='
line: "INTERFACE=\"{{ ansible_host }}\""
state: present
register: updatehddtemp3
- name: Restart hddtemp
ansible.builtin.systemd:
state: restarted
name: hddtemp
when: updatehddtemp1.changed or updatehddtemp2.changed or updatehddtemp3.changed

- block:
- name: Remove all file in /etc/apt/sources.list.d
file:
Expand Down
9 changes: 9 additions & 0 deletions src/debian/snmp_tempdisk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

/usr/sbin/smartctl --scan | awk '{ print $1 }' | while read i; do
temp=$(/usr/sbin/smartctl -a $i | grep Temperature_Celsius | awk '{ print $10 }')
if [ ! -z "$temp" ]
then
echo "$i;$temp"
fi
done
1 change: 1 addition & 0 deletions src/debian/snmpd.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ extend virshlist /usr/bin/timeout 2s /usr/bin/sudo -u libvirt /usr/local/bin/snm
extend cephstatus /usr/bin/timeout 2s /usr/bin/sudo -u ceph /usr/local/bin/snmp_cephstatus.sh
extend cephusage /usr/bin/timeout 2s /usr/bin/sudo -u ceph /usr/local/bin/snmp_cephusage.sh
extend diskusage /usr/bin/timeout 40s /usr/bin/sudo /usr/local/bin/snmp_diskusage.sh
extend tempdisk /usr/bin/timeout 2s /usr/bin/sudo /usr/local/bin/snmp_tempdisk.sh
agentAddress udp:{{ admin_ip_addr }}:161
1 change: 1 addition & 0 deletions src/debian/sudoers/Debian-snmp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Defaults:Debian-snmp !requiretty
Debian-snmp ALL = NOPASSWD:EXEC: /usr/local/bin/snmp_diskusage.sh ""
Debian-snmp ALL = NOPASSWD:EXEC: /usr/local/bin/snmp_tempdisk.sh ""
Debian-snmp ALL = (hacluster) NOPASSWD:EXEC: /usr/local/bin/snmp_crmstatus.sh ""
Debian-snmp ALL = (libvirt) NOPASSWD:EXEC: /usr/local/bin/snmp_virshlist.sh ""
Debian-snmp ALL = (libvirt) NOPASSWD:EXEC: /usr/local/bin/snmp_domstats.sh ""
Expand Down

0 comments on commit 270b1b3

Please sign in to comment.