Commit 356a02cf authored by Daniel Armbruster's avatar Daniel Armbruster Committed by thomas.forbriger
Browse files

nagios mode ready

This is a legacy commit from before 2015-05-18.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.

SVN Path:
SVN Revision: 4394
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 5a331840
......@@ -216,37 +216,36 @@ def main(argv=None):
logger.getLogger().debug("Finished reading logfile(s).")
if nagiosMode:
raise Usage(219, "nagios option not implemented yet.")
if len(criticalList):
sys.stdout.write("CSBACK CRITICAL")
sys.stdout.write("CSBACK CRITICAL\n")
elif len(errorList):
sys.stdout.write("CSBACK ERROR")
sys.stdout.write("CSBACK ERROR\n")
elif len(warningDeque):
sys.stdout.write("CSBACK WARNING")
sys.stdout.write("CSBACK WARNING\n")
sys.stdout.write("CSBACK OK")
sys.stdout.write("CSBACK OK\n")
logger.getLogger().debug("Checking email addresses.")
if 0 == len(sender):
raise Usage(231, "Email address of sender missing.")
raise Usage(230, "Email address of sender missing.")
if None == re.match( \
'^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$', sender):
raise Error(234, "Email address of sender not valid.")
raise Error(233, "Email address of sender not valid.")
if 0 == len(receivers):
raise Usage(236, "Email address of receiver missing.")
raise Usage(235, "Email address of receiver missing.")
for add in receivers:
if None == re.match( \
'^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$', add):
raise Error(240, "Email address of receiver not valid.")
raise Error(239, "Email address of receiver not valid.")
if 0 == len(host):
raise Usage(243, "Hostname missing.")
raise Usage(242, "Hostname missing.")
if 0 == len(username):
raise Usage(245, "Username missing.")
raise Usage(244, "Username missing.")
if 0 == len(password):
raise Usage(247, "Password missing.")
raise Usage(246, "Password missing.")
if -1 == port:
raise Usage(249, "Port missing.")
raise Usage(248, "Port missing.")
# prepare email
logger.getLogger().debug("Preparing email content ...")
msg = '============================\n'
......@@ -333,7 +332,8 @@ def main(argv=None):
return 2
logger.getLogger().info("Email sent.")
if not nagiosMode:
logger.getLogger().info("Email sent.")
return 0
# -----------------------------------------------------------------------------
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment