#NEWLINE# def collector( hostname , cmd , result ) : #NEWLINE# #INDENT# '\n    Collect data in a mongo database.\n    ' #NEWLINE# conn = pymongo . Connection ( __opts__ [ 'mongo.host' ] , __opts__ [ 'mongo.port' ] ) #NEWLINE# db = conn [ __opts__ [ 'mongo.db' ] ] #NEWLINE# user = __opts__ . get ( 'mongo.user' ) #NEWLINE# password = __opts__ . get ( 'mongo.password' ) #NEWLINE# if ( user and password ) : #NEWLINE# #INDENT# db . authenticate ( user , password ) #NEWLINE# #UNINDENT# collection = db [ hostname ] #NEWLINE# back = _escape_dot ( result ) #NEWLINE# log . debug ( back ) #NEWLINE# collection . insert ( { #NEWLINE# #INDENT# 'utctime' : datetime . datetime . utcnow ( ) , #NEWLINE# 'cmd' : cmd , #NEWLINE# 'result' : back , #NEWLINE# #UNINDENT# } )