The backup server sleeps most of the time, so the check was UNKNOWN. check_by_sshmon now runs an optional wake command first; the freshness check uses the wol-sleeper wake command, runs every 24h and retries after 6h so a failure does not wake the server every 30s. nagios on the icinga node may run the waker command as wol. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RywMtsL8qXG7GDY3MHq9Uh
46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
defaults = {
|
|
'apt': {
|
|
'packages': {
|
|
'wakeonlan': {},
|
|
},
|
|
},
|
|
}
|
|
|
|
|
|
@metadata_reactor.provides(
|
|
'users/wol/authorized_users',
|
|
)
|
|
def user(metadata):
|
|
sleepers = [
|
|
sleeper
|
|
for sleeper in repo.nodes
|
|
if sleeper.has_bundle('wol-sleeper')
|
|
and sleeper.metadata.get('wol-sleeper/waker') == node.name
|
|
]
|
|
commands = {
|
|
sleeper.metadata.get('wol-sleeper/waker_command')
|
|
for sleeper in sleepers
|
|
}
|
|
# icinga wakes sleepers before checks that need them awake
|
|
clients = {
|
|
f'root@{ssh_client.name}'
|
|
for ssh_client in repo.nodes
|
|
if ssh_client.dummy == False and ssh_client.has_bundle('ssh')
|
|
} | {
|
|
f"nagios@{sleeper.metadata.get('monitoring/icinga2_node')}"
|
|
for sleeper in sleepers
|
|
if sleeper.has_bundle('monitored')
|
|
}
|
|
|
|
return {
|
|
'users': {
|
|
'wol': {
|
|
'authorized_users': {
|
|
client: {
|
|
'commands': commands,
|
|
}
|
|
for client in clients
|
|
},
|
|
},
|
|
},
|
|
}
|