<s> """<STR_LIT>""" <EOL> import diamond . collector <EOL> from diamond . collector import str_to_bool <EOL> import subprocess <EOL> import re <EOL> class OssecCollector ( diamond . collector . Collector ) : <EOL> def get_default_config_help ( self ) : <EOL> config_help = super ( OssecCollector , self ) . get_default_config_help ( ) <EOL> config_help . update ( { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } ) <EOL> return config_help <EOL> def get_default_config ( self ) : <EOL> """<STR_LIT>""" <EOL> config = super ( OssecCollector , self ) . get_default_config ( ) <EOL> config . update ( { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> } ) <EOL> return config <EOL> def collect ( self ) : <EOL> command = [ self . config [ '<STR_LIT>' ] , '<STR_LIT>' ] <EOL> if str_to_bool ( self . config [ '<STR_LIT>' ] ) : <EOL> command . insert ( <NUM_LIT:0> , self . config [ '<STR_LIT>' ] ) <EOL> try : <EOL> p = subprocess . Popen ( command , stdout = subprocess . PIPE ) <EOL> res = p . communicate ( ) [ <NUM_LIT:0> ] <EOL> except Exception , e : <EOL> self . log . error ( '<STR_LIT>' <EOL> % ( '<STR_LIT:U+0020>' . join ( command ) , str ( e ) ) ) <EOL> return <EOL> if res == '<STR_LIT>' : <EOL> self . log . error ( '<STR_LIT>' <EOL> % ( '<STR_LIT:U+0020>' . join ( command ) ) ) <EOL> return <EOL> states = { } <EOL> for line in res . split ( "<STR_LIT:\n>" ) : <EOL> if not line . startswith ( '<STR_LIT>' ) : <EOL> continue <EOL> fragments = line . split ( '<STR_LIT:U+002C>' ) <EOL> state = fragments [ - <NUM_LIT:1> ] . lstrip ( ) <EOL> if state not in states : <EOL> states [ state ] = <NUM_LIT:1> <EOL> else : <EOL> states [ state ] += <NUM_LIT:1> <EOL> for state , count in states . items ( ) : <EOL> name = '<STR_LIT>' + re . sub ( '<STR_LIT>' , '<STR_LIT:_>' , state . lower ( ) ) <EOL> self . publish ( name , count ) </s>
