def main(): logger.info('%s started' % (module)) config = confighelper.get_config() logger.info('Obtained config') logger.debug(config.__dict__) mongohelper.initialize(config) logger.info('Mongo initialized') mongohelper.seed_users(config, get_users_from_file('userlist.txt'))
def main(): logger.info('%s started' % (module)) config = confighelper.get_config() logger.info('Obtained config') logger.debug(config.__dict__) mongohelper.initialize(config) logger.info('Mongo initialized') mongohelper.upsert_schedules(config, get_schedules_from_files('groups.txt','schedules.txt'))
def main(): logger.info('%s started' % (module)) config = confighelper.get_config() logger.info('Obtained config') logger.debug(config.__dict__) mongohelper.initialize(config) logger.info('Mongo initialized') mongohelper.upsert_schedules( config, get_schedules_from_files('groups.txt', 'schedules.txt'))
def main(): logger.info('%s started' % (module)) now = datetime.datetime.now().minute logger.info('Now %d' % (now)) config = confighelper.get_config() logger.info('Obtained config') logger.debug(config.__dict__) jiramonitor.main(config) logger.info('Updated tickets') smsmonitor.main(config) logger.info('Completed SMS notifications') if now % 5 == 0: emailmonitor.main(config) logger.info('Completed email notifications')
def do(): try: logger.info('In do') config = confighelper.get_config() logger.info('Obtained config') response = ["<?xml version='1.0' encoding='utf-8' ?>\n"] r = twilio.Response() issues = mongohelper.get_issues_to_escalate(config, timedelta) if len(issues) > 0: say_msg = [ 'The following issues have been opened for at least 50 minutes' ] for issue in issues: say_msg.append(', ') say_msg.append(issue['_id']) s = twilio.Say(''.join(say_msg)) mongohelper.mark_issues_as_escalated(config, issues) else: s = twilio.Say('All escalations have been taken care of') r.append(s) response.append(r.__repr__()) return ''.join(response) except Exception, e: logger.warning(e)
def do(): try: logger.info('In do') config = confighelper.get_config() logger.info('Obtained config') response = ["<?xml version='1.0' encoding='utf-8' ?>\n"] r = twilio.Response() issues = mongohelper.get_issues_to_escalate(config, timedelta) if len(issues) > 0: say_msg = ['The following issues have been opened for at least 50 minutes'] for issue in issues: say_msg.append(', ') say_msg.append(issue['_id']) s = twilio.Say(''.join(say_msg)) mongohelper.mark_issues_as_escalated(config, issues) else: s = twilio.Say('All escalations have been taken care of') r.append(s) response.append(r.__repr__()) return ''.join(response) except Exception, e: logger.warning(e)
def do(): try: logger.info('In do') config = confighelper.get_config() logger.info('Obtained config') response = ["<?xml version='1.0' encoding='utf-8' ?>\n"] r = twilio.Response() issues = mongohelper.get_issues_to_escalate(config, timedelta) if len(issues) > 0: say_msg = [ 'The following issues have been opened for at least 50 minutes' ] for issue in issues: say_msg.append(', ') say_msg.append(issue['_id']) s = twilio.Say(''.join(say_msg)) mongohelper.mark_issues_as_escalated(config, issues) else: s = twilio.Say('All escalations have been taken care of') r.append(s) response.append(r.__repr__()) return ''.join(response) except Exception, e: logger.warning(e) if __name__ == "__main__": config = confighelper.get_config() run(host=config.webserver_host, port=config.webserver_port)
receivers = recipient_list.split(',') logger.debug(receivers) for receiver in receivers: if len(receiver.strip()) > 0: logger.info('Escalating to %s' % (receiver)) body = { 'From' : config.twilio_caller_id, 'To' : receiver, 'Url' : config.twilio_callback_url } account.request('/%s/Accounts/%s/Calls' % (API_VERSION, config.twilio_account_sid), 'POST', body) if __name__ == '__main__': logfilename = module+'.log' logging.basicConfig(filename=logfilename, level=logging.DEBUG) config = confighelper.get_config() logger.debug(config.__dict__) issue = { '_id' : 'ID1', 'priority' : 3, 'company' : '10gen.com', 'reporter' : 'sridhar', 'jiraCreationTime' : datetime.datetime.now() } try: #sms_issue(config, issue) escalate(config, '6504835343', '', 'test') except Exception, e: print e; print e.read()
import psycopg2 from confighelper import get_config config = get_config() connection_string = "dbname='" + config["postgresql"]["dbname"] + "'" connection_string += " user='******'" connection_string += " host='" + config["postgresql"]["host"] + "'" connection_string += " port=" + str(config["postgresql"]["port"]) connection_string += " password='******'" conn = psycopg2.connect(connection_string) cur = conn.cursor() def insert_env_data(deveui, voltage, temperature, humidity, moisture, timestamp): # check if humidity and temperature are 0: if (humidity == 0) and (temperature == 0): humidity = None temperature = None cur.execute( """INSERT INTO envsensordata (node_id,voltage,temperature, humidity, moisture, time) VALUES ((SELECT node_id from idmapping where deveui = %s),%s, %s, %s, %s, %s)""", (deveui, voltage, temperature, humidity, moisture, timestamp), ) conn.commit() def insert_pax_data(deveui, voltage, pax, timestamp): voltage = voltage / 1000 # mV to V