@@ -0,0 +1,1868 @@
+'''%0A    Process sensor plugin%0A%0A    Generates the running processes information%0A'''%0Afrom ptop.core import Plugin%0Aimport psutil%0Aimport datetime, time%0A%0Aclass ProcessSensor(Plugin):%0A    def __init__(self,**kwargs):%0A        super(ProcessSensor,self).__init__(**kwargs)%0A%0A    # overriding the upate method%0A    def update(self):%0A        processes_info = %7B%7D%0A        # there will be two parts of the returned value, one will be text and other graph%0A        # there can be many text (key,value) pairs to display corresponding to each key%0A        processes_info%5B'text'%5D = %7B 'running_processes' : '','running_threads' : 0%7D%0A        # nested structure is used for keeping the info of processes%0A        processes_info%5B'table'%5D = %5B%5D%0A        # flood the data%0A        thread_count = 0 #keep track number of threads%0A        proc_count = 0 #keep track of number of processes%0A        for proc in psutil.process_iter():%0A            # info of a single process%0A            proc_info = %7B%7D%0A            proc_info%5B'id'%5D = proc.pid%0A            proc_info%5B'name'%5D = proc.name%0A            # getting more info about the process%0A            p = psutil.Process(proc.id)%0A            proc_info%5B'user'%5D = p.username()%0A            proc_info%5B'time'%5D = datetime.timedelta(seconds=str(time.time() - p.create_time()))%0A            proc_info%5B'cpu'%5D = p.cpu_percent()%0A            proc_info%5B'memory'%5D = p.memory_percent()%0A            proc_info%5B'command'%5D = ' '.join(p.cmdline())%0A            # increamenting the thread_count and proc_count%0A            thread_count += p.num_threads()%0A            proc_count += 1%0A            # recording the info%0A            processes_info%5B'table'%5D.append(proc_info)%0A%0A        processes_info%5B'text'%5D%5B'running_processes'%5D = str(proc_count)%0A        processes_info%5B'text'%5D%5B'running_threads'%5D = str(thread_count)%0A        # updating the value%0A        self.currentValue = processes_info%0A%0A%0A%0A%0A%0A

add : process sensor