Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
XMPP
XMPPNotify
Commits
7beaadea
Commit
7beaadea
authored
Sep 30, 2021
by
Bernhard Geier
Browse files
add -B for shorter alert messages
parent
2d807736
Changes
2
Hide whitespace changes
Inline
Side-by-side
commands-xmppnotify.conf
View file @
7beaadea
...
...
@@ -26,6 +26,9 @@ template NotificationCommand "xmpp-notification-base" {
required
=
true
value
=
"$notification_type$"
}
"-B"
= {
set_if
=
"$notification_brief$"
}
}
vars
+= {
...
...
xmppnotify.py
View file @
7beaadea
...
...
@@ -56,42 +56,39 @@ def build_message(args):
if
args
.
servicename
:
# service
message
=
"""[{notificationtype}] {servicedisplayname} on {hostdisplayname} is {servicestate}!
{output}
When: {longdatetime}
Ref: {hostname}!{servicename}
Monitoring host: {monitoringhostname}
\
"""
.
format
(
message
=
"""[{notificationtype}] {servicedisplayname} on {hostdisplayname} is {servicestate}!
\n
{output}"""
.
format
(
notificationtype
=
args
.
notificationtype
,
monitoringhostname
=
gethostname
(),
servicedisplayname
=
args
.
servicedisplayname
,
hostdisplayname
=
args
.
hostdisplayname
,
servicestate
=
args
.
state
,
output
=
output
,
longdatetime
=
args
.
longdatetime
,
servicename
=
args
.
servicename
,
hostname
=
args
.
hostname
output
=
output
)
if
not
args
.
brief
:
message
+=
"""
\n
When: {longdatetime}
\n
Ref: {hostname}!{servicename}
\n
Monitoring host: {monitoringhostname}"""
.
format
(
longdatetime
=
args
.
longdatetime
,
hostname
=
args
.
hostname
,
servicename
=
args
.
servicename
,
monitoringhostname
=
gethostname
()
)
else
:
message
=
"""[{notificationtype}] {hostdisplayname} is {hoststate}!
{output}
When: {longdatetime}
Ref: {hostname}
Monitoring host: {monitoringhostname}
\
"""
.
format
(
message
=
"""[{notificationtype}] {hostdisplayname} is {hoststate}!
\n
{output}"""
.
format
(
notificationtype
=
args
.
notificationtype
,
monitoringhostname
=
gethostname
(),
hostdisplayname
=
args
.
hostdisplayname
,
hoststate
=
args
.
state
,
output
=
output
,
output
=
output
)
if
not
args
.
brief
:
message
+=
"""
\n
When: {longdatetime}
\n
Ref: {hostname}
\n
Monitoring host: {monitoringhostname}"""
.
format
(
longdatetime
=
args
.
longdatetime
,
hostname
=
args
.
hostname
hostname
=
args
.
hostname
,
monitoringhostname
=
gethostname
()
)
if
args
.
hostaddress
:
if
not
args
.
brief
and
args
.
hostaddress
:
message
+=
"
\n
IPv4: {}"
.
format
(
args
.
hostaddress
)
if
args
.
hostaddress6
:
if
not
args
.
brief
and
args
.
hostaddress6
:
message
+=
"
\n
IPv6: {}"
.
format
(
args
.
hostaddress6
)
if
args
.
notificationcomment
:
...
...
@@ -142,6 +139,7 @@ def build_argparser():
parser
.
add_argument
(
'-b'
,
'--notificationauthorname'
)
parser
.
add_argument
(
'-c'
,
'--notificationcomment'
)
parser
.
add_argument
(
'-i'
,
'--icingaweb2url'
)
parser
.
add_argument
(
'-B'
,
'--brief'
,
default
=
False
,
action
=
'store_true'
)
return
parser
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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