Compare commits
No commits in common. "21b530cd8d680f0ab033ed58bbed3a16e60aed4b" and "1f0e660a4dd86e01d6266928304f7109b79b2a15" have entirely different histories.
21b530cd8d
...
1f0e660a4d
10 changed files with 32 additions and 116 deletions
18
bundles/hdparm/items.py
Normal file
18
bundles/hdparm/items.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
previous_action = []
|
||||||
|
|
||||||
|
for device, options in node.metadata.get('hdparm').items():
|
||||||
|
for option, value in options.items():
|
||||||
|
if option == 'power_management':
|
||||||
|
name = f'hdparm_{option}_{device}'
|
||||||
|
actions[name] = {
|
||||||
|
'command': f'hdparm -B {value} "{device}"',
|
||||||
|
'unless': f'hdparm -B "{device}" | grep APM_level | cut -d= -f2 | xargs | grep -q "^{value}$"',
|
||||||
|
'needs': [
|
||||||
|
'pkg_apt:hdparm',
|
||||||
|
*previous_action,
|
||||||
|
],
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
raise ValueError(f'unsupported hdparm option: {option}')
|
||||||
|
|
||||||
|
previous_action = [f'action:{name}']
|
8
bundles/hdparm/metadata.py
Normal file
8
bundles/hdparm/metadata.py
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
defaults = {
|
||||||
|
'apt': {
|
||||||
|
'packages': {
|
||||||
|
'hdparm': {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'hdparm': {},
|
||||||
|
}
|
|
@ -1,15 +0,0 @@
|
||||||
# state
|
|
||||||
smartctl -n idle /dev/sda
|
|
||||||
|
|
||||||
# temp
|
|
||||||
smartctl -n idle -A /dev/sdb --json=c | jq .temperature.current
|
|
||||||
|
|
||||||
# apm
|
|
||||||
smartctl --get apm /dev/sdb --json=c | jq .ata_apm.level
|
|
||||||
smartctl --set apm,20 /dev/sdb --json=c
|
|
||||||
|
|
||||||
# power state
|
|
||||||
smartctl -n idle /dev/sdb
|
|
||||||
|
|
||||||
# devices
|
|
||||||
smartctl --scan | cut -d' ' -f1
|
|
|
@ -1,18 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
for device in $(smartctl --scan | cut -d' ' -f1)
|
|
||||||
do
|
|
||||||
temp=$(smartctl -n idle -A --json=c $device | jq .temperature.current)
|
|
||||||
|
|
||||||
if [[ $temp == ?(-)+([0-9]) ]]
|
|
||||||
then
|
|
||||||
echo "smartctl,host=${node.name},device=$device temperature=$temp $(date --utc +%s%N)"
|
|
||||||
elif [[ $temp == null ]]
|
|
||||||
then
|
|
||||||
# hdd might be sleeping
|
|
||||||
continue
|
|
||||||
else
|
|
||||||
# hdd might be unsupported
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
done
|
|
|
@ -1,25 +0,0 @@
|
||||||
files = {
|
|
||||||
'/usr/local/share/icinga/plugins/hdd_temp': {
|
|
||||||
'content_type': 'mako',
|
|
||||||
'mode': '0755',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
previous_action = []
|
|
||||||
|
|
||||||
for device, conf in node.metadata.get('smartctl').items():
|
|
||||||
for option, value in conf.items():
|
|
||||||
if option == 'apm':
|
|
||||||
action_name = f'smartctl_apm_{device}'
|
|
||||||
actions[action_name] = {
|
|
||||||
'command': f'smartctl --set apm,{value} "{device}"',
|
|
||||||
'unless': f'smartctl --get apm "{device}" --json=c | jq .ata_apm.level | grep -q "^{value}$"',
|
|
||||||
'needs': [
|
|
||||||
'pkg_apt:smartmontools',
|
|
||||||
*previous_action,
|
|
||||||
],
|
|
||||||
}
|
|
||||||
else:
|
|
||||||
raise ValueError(f'{node.name}: unkown smartctl option: {option}')
|
|
||||||
|
|
||||||
previous_action = [f'action:{action_name}']
|
|
|
@ -1,27 +0,0 @@
|
||||||
defaults = {
|
|
||||||
'apt': {
|
|
||||||
'packages': {
|
|
||||||
'smartmontools': {},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
'grafana_rows': {
|
|
||||||
'smartctl',
|
|
||||||
},
|
|
||||||
'smartctl': {},
|
|
||||||
'telegraf': {
|
|
||||||
'config': {
|
|
||||||
'inputs': {
|
|
||||||
'exec': [{
|
|
||||||
'commands': [
|
|
||||||
f'sudo /usr/local/share/icinga/plugins/hdd_temp',
|
|
||||||
],
|
|
||||||
'data_format': 'influx',
|
|
||||||
'interval': '60s',
|
|
||||||
}],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
'sudoers': {
|
|
||||||
'telegraf': ['/usr/local/share/icinga/plugins/hdd_temp'],
|
|
||||||
},
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
{
|
|
||||||
'temperature': {
|
|
||||||
'queries': {
|
|
||||||
'usage': {
|
|
||||||
'filters': {
|
|
||||||
'_measurement': 'smartctl',
|
|
||||||
'_field': [
|
|
||||||
'temperature',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
'function': 'mean',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
'display_name': '__field.labels.device',
|
|
||||||
'min': 0,
|
|
||||||
'unit': 'degrees',
|
|
||||||
},
|
|
||||||
}
|
|
|
@ -6,9 +6,9 @@
|
||||||
'monitored',
|
'monitored',
|
||||||
],
|
],
|
||||||
'bundles': [
|
'bundles': [
|
||||||
'smartctl',
|
|
||||||
'zfs',
|
'zfs',
|
||||||
'zfs-mirror',
|
'zfs-mirror',
|
||||||
|
'hdparm',
|
||||||
],
|
],
|
||||||
'metadata': {
|
'metadata': {
|
||||||
'id': '9cf52515-63a1-4659-a8ec-6c3c881727e5',
|
'id': '9cf52515-63a1-4659-a8ec-6c3c881727e5',
|
||||||
|
@ -22,15 +22,15 @@
|
||||||
'backup-server': {
|
'backup-server': {
|
||||||
'hostname': 'backups.sublimity.de',
|
'hostname': 'backups.sublimity.de',
|
||||||
},
|
},
|
||||||
'smartctl': {
|
'hdparm': {
|
||||||
'/dev/disk/by-id/ata-HGST_HDN726040ALE614_K3GV6TPL': {
|
'/dev/disk/by-id/ata-HGST_HDN726040ALE614_K3GV6TPL': {
|
||||||
'apm': 32,
|
'power_management': 1,
|
||||||
},
|
},
|
||||||
'/dev/disk/by-id/ata-HGST_HDN726040ALE614_K4KAJXEB': {
|
'/dev/disk/by-id/ata-HGST_HDN726040ALE614_K4KAJXEB': {
|
||||||
'apm': 32,
|
'power_management': 1,
|
||||||
},
|
},
|
||||||
'/dev/disk/by-id/ata-TOSHIBA_HDWQ140_19VZK0EMFAYG': {
|
'/dev/disk/by-id/ata-TOSHIBA_HDWQ140_19VZK0EMFAYG': {
|
||||||
'apm': 32,
|
'power_management': 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'zfs-mirror': {
|
'zfs-mirror': {
|
||||||
|
|
|
@ -9,15 +9,14 @@
|
||||||
],
|
],
|
||||||
'bundles': [
|
'bundles': [
|
||||||
'gitea',
|
'gitea',
|
||||||
'gollum',
|
|
||||||
'grafana',
|
'grafana',
|
||||||
'influxdb2',
|
'influxdb2',
|
||||||
'mirror',
|
'mirror',
|
||||||
'postgresql',
|
'postgresql',
|
||||||
'redis',
|
'redis',
|
||||||
'smartctl',
|
|
||||||
'wireguard',
|
'wireguard',
|
||||||
'zfs',
|
'zfs',
|
||||||
|
'gollum',
|
||||||
],
|
],
|
||||||
'metadata': {
|
'metadata': {
|
||||||
'id': 'af96709e-b13f-4965-a588-ef2cd476437a',
|
'id': 'af96709e-b13f-4965-a588-ef2cd476437a',
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
],
|
],
|
||||||
'bundles': [
|
'bundles': [
|
||||||
'dm-crypt',
|
'dm-crypt',
|
||||||
'smartctl',
|
|
||||||
'wireguard',
|
'wireguard',
|
||||||
'zfs',
|
'zfs',
|
||||||
],
|
],
|
||||||
|
@ -54,11 +53,6 @@
|
||||||
'device': '/dev/disk/by-id/ata-TOSHIBA_MG06ACA10TE_61C0A1B1FKQE',
|
'device': '/dev/disk/by-id/ata-TOSHIBA_MG06ACA10TE_61C0A1B1FKQE',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'smartctl': {
|
|
||||||
'/dev/disk/by-id/ata-TOSHIBA_MG06ACA10TE_61C0A1B1FKQE': {
|
|
||||||
'apm': 32,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
'zfs': {
|
'zfs': {
|
||||||
'pools': {
|
'pools': {
|
||||||
'tank': {
|
'tank': {
|
||||||
|
|
Loading…
Reference in a new issue