Issue with email format

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
stecino
Posts: 248
Joined: Thu Mar 14, 2013 4:42 pm

Re: Issue with email format

Post by stecino »

tgriep wrote:Do you have any other multi-line plugins running and are they working?
Can you run your check from a shell on your server and post the output here?
Can you upload your script so we can review it?
No I don't have any multi-line plugins. I will use postfix to send out a multiline message

Here is the python code, it's essentially connects to replica set, runs a query. Takes json like output, converts to true json format, and then parses out the result field of output
query_result looks something like this

query_result={"ok": 1.0, "result": [{"total": 3, "_id": "serverX"},{"total": 2, "_id": "serverY"}]}
=====

#!/usr/bin/python

from pymongo import Connection
import datetime
from bson.son import SON
import json
import sys





db = Connection(["server01.test.com:28001","server02.test.com:28001","server03.test.com:28001"]).ssp0
db.authenticate("xxxx","xxxx")


start = datetime.datetime.now() - datetime.timedelta(minutes=5)

pipeline = [
{ "$match": {"popDate":{ "$lt":start}}},
{ "$group": {"_id":"$lockHost","total":{"$sum":1}}}
]

query_result=db.batchPushMessageTask.aggregate(pipeline)


#convert into valid json format
query_result=json.dumps(query_result)

#load the json
json_string=json.loads(query_result)

array_length=len(json_string['result'])
#print array_length

if array_length == 0:

print ('No Errors')
sys.exit(0)

else:
for i in xrange(len(json_string['result'])):
print ("\rServer %s has %s batch push messages that are older than 5 minutes " % (json_string['result']['_id'],json_string['result']['total']))

sys.exit(2)
stecino
Posts: 248
Joined: Thu Mar 14, 2013 4:42 pm

Re: Issue with email format

Post by stecino »

Looks like it may be a in issue with Postfix.

I have generated an email using a test file with multiline in it. It's treating it as single line. Will be investigation little more. let you know what happens
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Issue with email format

Post by tmcdonald »

Keep us posted!
Former Nagios employee
Locked