Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sol1 Icinga
icinga2-enhanced-mail-notification
Commits
db3d37c3
Commit
db3d37c3
authored
Dec 13, 2018
by
Matthew Smith
Browse files
trivial
parent
e9c766d7
Changes
1
Hide whitespace changes
Inline
Side-by-side
enhanced-mail-notification.py
View file @
db3d37c3
...
...
@@ -79,7 +79,7 @@ service_output = os.getenv('SERVICEOUTPUT', '')
long_date_time
=
os
.
getenv
(
'LONGDATETIME'
,
''
)
notification_author
=
os
.
getenv
(
'NOTIFICATIONAUTHORNAME'
,
''
)
notification_comment
=
os
.
getenv
(
'NOTIFICATIONCOMMENT'
,
''
)
user_
email
=
os
.
getenv
(
'USEREMAIL'
,
''
)
email
_to
=
os
.
getenv
(
'USEREMAIL'
,
''
)
performance_data
=
os
.
getenv
(
'PERFDATA'
)
# needs to be null to avoid it
netbox_host_name
=
os
.
getenv
(
'NETBOXHOSTNAME'
,
host_alias
)
if
netbox_host_name
==
''
:
...
...
@@ -122,7 +122,7 @@ if DEBUG:
f
.
write
(
'
\n
export LONGDATETIME="{}"'
.
format
(
long_date_time
))
f
.
write
(
'
\n
export NOTIFICATIONAUTHORNAME="{}"'
.
format
(
notification_author
))
f
.
write
(
'
\n
export NOTIFICATIONCOMMENT="{}"'
.
format
(
notification_comment
))
f
.
write
(
'
\n
export USEREMAIL="{}"'
.
format
(
user_
email
))
f
.
write
(
'
\n
export USEREMAIL="{}"'
.
format
(
email
_to
))
f
.
write
(
'
\n
export PERFDATA="{}"'
.
format
(
performance_data
))
f
.
write
(
'
\n
export NETBOXHOSTNAME="{}"'
.
format
(
netbox_host_name
))
f
.
write
(
'
\n
export NETBOXPANELID="{}"'
.
format
(
grafana_host_panel_id
))
...
...
@@ -443,7 +443,7 @@ if DEBUG:
msgRoot
=
MIMEMultipart
(
'related'
)
msgRoot
[
'Subject'
]
=
email_subject
msgRoot
[
'From'
]
=
EMAILFROM
msgRoot
[
'To'
]
=
user_
email
msgRoot
[
'To'
]
=
email
_to
msgRoot
.
preamble
=
'This is a multi-part message in MIME format.'
msgAlternative
=
MIMEMultipart
(
'alternative'
)
...
...
@@ -486,7 +486,7 @@ if EMAILUSERNAME and EMAILPASSWORD:
smtp
.
login
(
EMAILUSERNAME
,
EMAILPASSWORD
)
try
:
smtp
.
sendmail
(
EMAILFROM
,
user_
email
,
msgRoot
.
as_string
())
smtp
.
sendmail
(
EMAILFROM
,
email
_to
,
msgRoot
.
as_string
())
smtp
.
quit
()
except
Exception
as
e
:
print
(
"Cannot send mail using SMTP: "
+
e
.
message
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment