#!/usr/bin/python
import sys
import os
import salt.client


def getNotification():
    notification_dict = {}
    isEndOfDictionary = False
    for line in sys.stdin:
        if not line.strip():
            isEndOfDictionary = True
            continue
        if isEndOfDictionary:
            break
        key, value = line.split(':')
        notification_dict[key] = value.lstrip()[:-1]
    return notification_dict, line


def postTheNotificationToSaltMaster():
    salt_payload = {}
    threshold_dict = {}
    caller = salt.client.Caller()
    threshold_dict['tags'], threshold_dict['message'] = getNotification()
    tag = "skyring/collectd/node/{0}/threshold/{1}/{2}".format(
        threshold_dict['tags']["Host"],
        threshold_dict['tags']["Plugin"],
        threshold_dict['tags']["Severity"])
    caller.sminion.functions['event.send'](tag, threshold_dict)


if __name__ == '__main__':
    postTheNotificationToSaltMaster()

#!/usr/bin/python
import sys
import os
import salt.client


def getNotification():
    notification_dict = {}
    isEndOfDictionary = False
    for line in sys.stdin:
        if not line.strip():
            isEndOfDictionary = True
            continue
        if isEndOfDictionary:
            break
        key, value = line.split(':')
        notification_dict[key] = value.lstrip()[:-1]
    return notification_dict, line


def postTheNotificationToSaltMaster():
    salt_payload = {}
    threshold_dict = {}
    caller = salt.client.Caller()
    threshold_dict['tags'], threshold_dict['message'] = getNotification()
    threshold_dict['severity'] = threshold_dict['tags']["Severity"]
    tag = "skyring/collectd/node/{0}/threshold/{1}/{2}".format(
        threshold_dict['tags']["Host"],
        threshold_dict['tags']["Plugin"],
        threshold_dict['tags']["Severity"])
    caller.sminion.functions['event.send'](tag, threshold_dict)


if __name__ == '__main__':
    postTheNotificationToSaltMaster()

Fix in collectd event notifier script.
Skynet: Fix in collectd event notifier script.

This patch adds a fix to collectd event notifier script,
by providing a value the "severity" field in the event
that it sends to salt-master event bus. with out that
event listener in the skyring server will fail to
process it.

Change-Id: I20b738468c8022a25024e4327434ae6dab43a123
Signed-off-by: nnDarshan <d2c6d450ab98b078f2f1942c995e6d92dd504bc8@gmail.com>
