add bundle:check-mail-received
All checks were successful
bundlewrap/pipeline/head This commit looks good
All checks were successful
bundlewrap/pipeline/head This commit looks good
This commit is contained in:
parent
76b859c629
commit
3351767d56
6 changed files with 137 additions and 6 deletions
41
bundles/check-mail-received/metadata.py
Normal file
41
bundles/check-mail-received/metadata.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
@metadata_reactor.provides(
|
||||
'cron/check-mail-received',
|
||||
'icinga2_api/check-mail-received/services',
|
||||
)
|
||||
def process_metadata(metadata):
|
||||
cron = set()
|
||||
services = {}
|
||||
|
||||
my_mail_address = 'root@{}'.format(metadata.get('hostname'))
|
||||
|
||||
for name, config in metadata.get('check-mail-received', {}).items():
|
||||
cron.add('{minute} {hour} * * * root date | mail -s "daily test mail from {node}" -r {source} {target}'.format(
|
||||
minute=node.magic_number%60,
|
||||
hour=node.magic_number%24,
|
||||
node=node.name,
|
||||
source=my_mail_address,
|
||||
target=config['email'],
|
||||
))
|
||||
|
||||
services[f'MAIL RECEIVED ON {name}'] = {
|
||||
'command_on_monitored_host': repo.libs.faults.join_faults([
|
||||
'/usr/local/share/icinga/plugins/check_imap_for_mail_from',
|
||||
config['imap_host'],
|
||||
config.get('imap_user', config['email']),
|
||||
config['imap_pass'],
|
||||
my_mail_address,
|
||||
]),
|
||||
'check_interval': '15m',
|
||||
'retry_interval': '5m',
|
||||
}
|
||||
|
||||
return {
|
||||
'cron': {
|
||||
'check-mail-received': '\n'.join(sorted(cron)),
|
||||
},
|
||||
'icinga2_api': {
|
||||
'check-mail-received': {
|
||||
'services': services,
|
||||
},
|
||||
},
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue