#!/usr/bin/env python

import os
from optparse import OptionParser

def highlight(status, watch):
    if watch:
	return status.upper()
    elif status == 'running':
	return '\x1b[32mRUNNING\x1b[0m'
    elif status == 'start':
        return '\x1b[36mSTART\x1b[0m'
    else:
        return '\x1b[31m%s\x1b[0m'%(status.upper())

def main(watch):
    status  = os.popen('systemctl status spoofer | grep Active').readlines()[0].strip().split('(')[1].split(')')[0]
    print 'Spoofer------: {}'.format(highlight(status, watch))

    status  = os.popen('systemctl status flipevil | grep Active').readlines()[0].strip().split('(')[1].split(')')[0]
    print 'Flip Evil----: {}'.format(highlight(status, watch))


    status  = os.popen('systemctl status snortd | grep Active').readlines()[0].strip().split('(')[1].split(')')[0]
    print 'Snort--------: {}'.format(highlight(status, watch))


    status  = os.popen('systemctl status syslog-ng | grep Active').readlines()[0].strip().split('(')[1].split(')')[0]
    print 'Syslog-ng----: {}'.format(highlight(status, watch))

    status  = os.popen('systemctl status chksnort | grep Active').readlines()[0].strip().split('(')[1].split(')')[0]
    print 'Snort checker: {}'.format(highlight(status, watch)) 
    
if __name__ == '__main__':
    parser = OptionParser()    
    parser.add_option('-w', '--watch', dest = 'watch', help = 'use to run with no colors', default = False, action = 'store_true')
    (options, args) = parser.parse_args()
    main(options.watch)

