Compare commits

..

No commits in common. "54219928e4bb173966587ca8b5ec314aab0ea531" and "22d5ba12ee7798b7e3c8104d8792cc09c80ab447" have entirely different histories.

4 changed files with 11 additions and 40 deletions

View file

@ -10,7 +10,7 @@ object User "${username}" {
states = [ OK, Warning, Critical, Up, Down ]
types = [ Problem, Recovery ]
% if config['is_admin'] and (config['email'] or config['phone']):
% if config['is_admin']:
groups = [ "on-call_sms" ]
% endif

View file

@ -3,14 +3,10 @@
import email.mime.text
import smtplib
from argparse import ArgumentParser
from json import dumps
from requests import post
from requests import get
from subprocess import run
from sys import argv
SIPGATE_USER='${node.metadata['icinga2']['sipgate_user']}'
SIPGATE_PASS='${node.metadata['icinga2']['sipgate_pass']}'
parser = ArgumentParser(
prog='icinga_notification_wrapper',
description='Icinga2 Notification Wrapper',
@ -59,34 +55,14 @@ def log_to_syslog(message):
def notify_per_sms():
message = {
'message': 'ICINGA: {host}/{service} is {state}: {output}'.format(
host=args.host_name,
service=args.service_name,
state=args.state.upper(),
output=args.output
),
'smsId': 's0', # XXX what does this mean? Documentation is unclear
'recipient': args.sms
}
headers = {
'Content-type': 'application/json',
'Accept': 'application/json'
}
try:
r = post(
'https://api.sipgate.com/v2/sessions/sms',
json=message,
headers=headers,
auth=(SIPGATE_USER, SIPGATE_PASS),
)
if r.status_code == 204:
log_to_syslog('Sent a SMS to "{}"'.format(args.sms))
else:
r.raise_for_status()
except Exception as e:
log_to_syslog('Sending a SMS to "{}" failed: {}'.format(args.sms, repr(e)))
log_to_syslog('SMS requested, but not implemented yet!') # FIXME TODO
return
msg = 'ICINGA: {host}/{service} is {state}: {output}'.format(
host=args.host_name,
service=args.service_name,
state=args.state,
output=args.output
)
def notify_per_mail():
@ -112,7 +88,7 @@ State: {state}
mail = email.mime.text.MIMEText(text.format(
host=args.host_name,
service=args.service_name,
state=args.state.upper(),
state=args.state,
output=args.output
),
'plain',

View file

@ -93,7 +93,6 @@ files = {
},
'/etc/icinga2/scripts/icinga_notification_wrapper': {
'source': 'scripts/icinga_notification_wrapper',
'content_type': 'mako',
'mode': '0755',
},
'/etc/icinga2/features-available/ido-pgsql.conf': {

View file

@ -26,10 +26,6 @@ nodes['ovh.icinga2'] = {
'php-imagick': {},
},
},
'icinga2': {
'sipgate_user': vault.decrypt('encrypt$gAAAAABfujAmCUnicSAllq8MskXnPodKp3cGcfA6Abvef-rAYwB2CtCwt9oBRVKFskJPVArDaF1wfjNTfLwgX3gTP7xFutJ1HA=='),
'sipgate_pass': vault.decrypt('encrypt$gAAAAABfui_4B7UmOosI_gsQ-xvmd3X_BUDSl-G2KF_Tg8O6RpUvk0gHexOKsrTb6se1ipXsh7RC9pbZCKMtesW0C6j24LHXDKCOjkqI77oO0ZjnG6SUwfcJqg61biNiRlXy8z-9LCGA'),
},
'nginx': {
'vhosts': {
'icingaweb': {