/usr/share/doc/check-mk-doc/treasures/notifications/opcmsg is in check-mk-doc 1.2.8p16-1ubuntu0.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #!/usr/bin/python
# Create message for HPOpenView
# This notification plugin forwards the notification to the
# local HPOpenView instance
#
# Note: Some paths are still hardcoded here.
import os, sys, re
def substitute_context(template, context):
# First replace all known variables
for varname, value in context.items():
template = template.replace('$'+varname+'$', value)
# Remove the rest of the variables and make them empty
template = re.sub("\$[A-Z]+\$", "", template)
return template
def main():
try:
opcmsg_bin = "/opt/OV/bin/opcmsg"
# gather all options from env
context = dict([
(var[7:], value.decode("utf-8"))
for (var, value)
in os.environ.items()
if var.startswith("NOTIFY_")])
# Severity and message text
if context["WHAT"] == "HOST":
msg_t = context["HOSTOUTPUT"]
severity = context["HOSTSTATEID"] == "0" and "ok" or "critical"
else:
msg_t = context["SERVICEOUTPUT"]
state_map = { "0": "normal", "1": "warning", "2": "critical", "3": "warning" }
try:
severity = state_map[context["SERVICESTATEID"]]
except:
severity = "normal"
# application
application = "RWWS4.0"
# object
# Wichtig: " escapen
the_object = context["HOSTNAME"]
if context["WHAT"] == "SERVICE":
the_object += ":" + context["SERVICEDESC"]
# msg_grp
msg_grp = context['CONTACTNAME']
# node
node = context['MONITORING_HOST']
# Assemble the command
command = "%s severity=%s application=%s object=\"%s\" msg_grp=\"%s\" msg_t=\"%s\" node=%s" % (
opcmsg_bin, severity, application, the_object, msg_grp, msg_t, node)
# Execute the command
print "executing command" , command
os.system(command)
except Exception, e:
sys.stdout.write("ERROR %r" % e)
sys.exit(1)
main()
|