Page 2 of 2

Re: Issue with email format

Posted: Mon Jun 22, 2015 4:19 pm
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)

Re: Issue with email format

Posted: Mon Jun 22, 2015 4:54 pm
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

Re: Issue with email format

Posted: Tue Jun 23, 2015 11:21 am
by tmcdonald
Keep us posted!