@@ -0,0 +1,1351 @@
+# coding=utf-8%0D%0A%0D%0Afrom task import task%0D%0Afrom task import task_container%0D%0A%0D%0Afrom task.job import job%0D%0Afrom task.trigger import simple_trigger%0D%0A%0D%0Afrom py_sys.info import linux%0D%0Afrom py_sys import execute%0D%0A%0D%0Aclass WatchDog():%0D%0A    %0D%0A    def __init__(self):%0D%0A        self.watch_c = task_container.TaskContainer()%0D%0A    %0D%0A    def watch(self, processes):%0D%0A        if processes == None or not isinstance(processes, dict):%0D%0A            raise IOError('Watch processes is NULL or not dict')%0D%0A        %0D%0A        for pid in processes:%0D%0A            action = processes.get(pid)%0D%0A            if action is not None:%0D%0A                watch_task = task.Task('%25s WatchDog' %25 pid, WatchJob(pid, action), simple_trigger.SimpleTrigger(0, 1))%0D%0A                self.watch_c.add_task(watch_task)%0D%0A            %0D%0A    def start(self):%0D%0A        self.watch_c.start_all(True)%0D%0A        %0D%0Aclass WatchJob(job.Job):%0D%0A    %0D%0A    def __init__(self, pid, action):%0D%0A        self.pid = pid%0D%0A        self.action = action%0D%0A        %0D%0A    def execute(self):%0D%0A        linux_info = linux.LinuxInfo()%0D%0A        ps_info = linux_info.ps(True)%0D%0A        if ps_info is not None:%0D%0A            for ps_item in ps_info:%0D%0A                _pid = ps_item.get('pid')%0D%0A                if self.pid == _pid:%0D%0A                    return%0D%0A        %0D%0A        execute.run(self.action)%0D%0A                %0D%0A        %0D%0A        

Add watchdog for monitor system processor