X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=monitor%2Fpolicy.py;h=4574de7e4046eda5608ea33fe7b7328e0de6808f;hb=3f4df5945bbfb4592a164d929cf22c31d5fba50e;hp=cc61fee35a3297f09d905a0c5e4a5063b34a2a2a;hpb=da913fbd1629fc4669b186915df8ff3a340482d3;p=monitor.git diff --git a/monitor/policy.py b/monitor/policy.py index cc61fee..4574de7 100644 --- a/monitor/policy.py +++ b/monitor/policy.py @@ -1,15 +1,15 @@ import config import database import time -import mailer import sys -import emailTxt import string +from monitor.wrapper import mailer +from monitor.wrapper import emailTxt from monitor.wrapper import plccache from datetime import datetime -from rt import is_host_in_rt_tickets -import plc +from monitor.wrapper.rt import is_host_in_rt_tickets +from monitor.wrapper import plc # Time to enforce policy POLSLEEP = 7200 @@ -171,10 +171,11 @@ class MonitorMergeDiagnoseSendEscellate: #### APPLY PENALTY if ( record.data['take_action'] and diag['Squeeze'] ): - print "action: taking action" + print "action: taking squeeze action" record.takeAction(record.data['penalty_level']) del diag['Squeeze'] if diag.getFlag('BackOff'): + print "action: taking backoff action" record.takeAction(0) del diag['BackOff'] @@ -258,7 +259,7 @@ class MonitorMergeDiagnoseSendEscellate: return rec def checkStageAndTime(self, record): - """ + """ The core variables are: send_email_to : defines who to send messages to at this time @@ -268,15 +269,15 @@ class MonitorMergeDiagnoseSendEscellate: save_act_all : whether or not to save the action record in the db. action/stage : stage tracks which state we're in. - """ - stages = { - "initial" : [ { action='noop', next="weekone"}], - "weekone" : [ { action='noop', index=0, save=True, email=TECH, length=7*SPERDAY, next="weektwo" }, ], - "weektwo" : [ { action='nocreate', index=1, save=True, email=TECH|PI, length=7*SPERDAY, next="waitforever" }, ], - "waitforever" : [ { action='suspendslices',index=2, save=True, email=TECH|PI|USER, length=7*SPERDAY, next="waitforever" }, ], - "paused" : [ { action='noop', save=True length=30*SPERDAY, next="weekone" }, ] - "improvement" : [ { action='close_rt', index=0, save=True, email=TECH, next="monitor-end-record" }, ], - } + """ + #stages = { + # "initial" : [ { action='noop', next="weekone"}], + # "weekone" : [ { action='noop', index=0, save=True, email=TECH, length=7*SPERDAY, next="weektwo" }, ], + # "weektwo" : [ { action='nocreate', index=1, save=True, email=TECH|PI, length=7*SPERDAY, next="waitforever" }, ], + # "waitforever" : [ { action='suspendslices',index=2, save=True, email=TECH|PI|USER, length=7*SPERDAY, next="waitforever" }, ], + # "paused" : [ { action='noop', save=True length=30*SPERDAY, next="weekone" }, ] + # "improvement" : [ { action='close_rt', index=0, save=True, email=TECH, next="monitor-end-record" }, ], + #} # TODO: make this time relative to the PREVIOUS action taken. current_time = time.time() current_stage = record.getMostRecentStage()