Exemplo n.º 1
0
引数8:ログファイル

"""

DEFAULT_SUBJECT = "[Karesansui notification] '%{watch_name}' threshold exceeded"
DEFAULT_SENDER  = "root@localhost"

import os, sys, re

from karesansui.lib.collectd.utils import append_line
from karesansui.lib.net.mail       import MAIL_LIB, MAIL_LIB_Exception
from karesansui.lib.utils          import preprint_r, ucfirst
from karesansui.lib.parser.eml     import emlParser

from karesansui import __version__, __release__, __app__
AppName = "%s %s" % (ucfirst(__app__),__version__,)

def send_mail(recipient=None, sender=None, server="localhost", port=25, message="", extra_message="", watch_name="", logfile="/dev/null"):
    retval = False

    func_name = sys._getframe(0).f_code.co_name
    append_line(logfile,"[%s] Entering function '%s'." % (func_name,func_name,))

    smtp_server = server.split(":")[0]
    try:
        smtp_port = int(port)
    except:
        smtp_port = 25

    try:
        socket_timeout
Exemplo n.º 2
0
NOTIF_FAILURE = 1<<0
NOTIF_WARNING = 1<<1
NOTIF_OKAY    = 1<<2

CHECK_CONTINUATION = 1<<0
CHECK_HITCOUNT     = 1<<1
CHECK_SPAN         = 1<<2
CHECK_ALL          = CHECK_CONTINUATION | CHECK_HITCOUNT | CHECK_SPAN

ACTION_LOG    = 1<<0
ACTION_MAIL   = 1<<1
ACTION_SCRIPT = 1<<2
ACTION_ALL    = ACTION_LOG | ACTION_MAIL | ACTION_SCRIPT

AppName = "%s %s-%s" % (ucfirst(__app__),__version__,__release__,)
optional_data = {
                'AppName' : AppName,
                }

"""
notifyオブジェクト(printの結果)
インスタンス名はプラグインによっては無い場合がある

type=%s
type_instance=%s
plugin=%s
plugin_instance=%s
host=%s
message=%s
severity=%i
Exemplo n.º 3
0
NOTIF_FAILURE = 1 << 0
NOTIF_WARNING = 1 << 1
NOTIF_OKAY = 1 << 2

CHECK_CONTINUATION = 1 << 0
CHECK_HITCOUNT = 1 << 1
CHECK_SPAN = 1 << 2
CHECK_ALL = CHECK_CONTINUATION | CHECK_HITCOUNT | CHECK_SPAN

ACTION_LOG = 1 << 0
ACTION_MAIL = 1 << 1
ACTION_SCRIPT = 1 << 2
ACTION_ALL = ACTION_LOG | ACTION_MAIL | ACTION_SCRIPT

AppName = "%s %s-%s" % (
    ucfirst(__app__),
    __version__,
    __release__,
)
optional_data = {
    'AppName': AppName,
}
"""
notifyオブジェクト(printの結果)
インスタンス名はプラグインによっては無い場合がある

type=%s
type_instance=%s
plugin=%s
plugin_instance=%s
host=%s