'Update the processes stats.'

def update(self):

    self.processlist = []
    self.reset_processcount()
    if self.disable_tag:
        return
    time_since_update = getTimeSinceLastUpdate('process_disk')
    self.reset_max_values()
    self.processcount['pid_max'] = self.pid_max
    processdict = {}
    excluded_processes = set()
    for proc in psutil.process_iter():
        if (self.no_kernel_threads and (not WINDOWS) and is_kernel_thread(proc)):
            continue
        s = self.__get_process_stats(proc, mandatory_stats=True, standard_stats=(self.max_processes is None))
        if ((s is None) or (BSD and (s['name'] == 'idle')) or (WINDOWS and (s['name'] == 'System    Idle    Process')) or (MACOS and (s['name'] == 'kernel_task'))):
            continue
        if self._filter.is_filtered(s):
            excluded_processes.add(proc)
            continue
        processdict[proc] = s
        try:
            self.processcount[str(proc.status())] += 1
        except KeyError:
            try:
                self.processcount[str(proc.status())] = 1
            except psutil.NoSuchProcess:
                pass
        except psutil.NoSuchProcess:
            pass
        else:
            self.processcount['total'] += 1
        try:
            self.processcount['thread'] += proc.num_threads()
        except Exception:
            pass
    if self._enable_tree:
        self.process_tree = ProcessTreeNode.build_tree(processdict, self.sort_key, self.sort_reverse, self.no_kernel_threads, excluded_processes)
        for (i, node) in enumerate(self.process_tree):
            if ((self.max_processes is not None) and (i >= self.max_processes)):
                break
            new_stats = self.__get_process_stats(node.process, mandatory_stats=False, standard_stats=True, extended_stats=False)
            if (new_stats is not None):
                node.stats.update(new_stats)
            node.stats['time_since_update'] = time_since_update
    else:
        if (self.max_processes is not None):
            try:
                processiter = sorted(iteritems(processdict), key=(lambda x: x[1][self.sort_key]), reverse=self.sort_reverse)
            except (KeyError, TypeError) as e:
                logger.error('Cannot    sort    process    list    by    {}:    {}'.format(self.sort_key, e))
                logger.error('{}'.format(listitems(processdict)[0]))
                processloop = iteritems(processdict)
                first = False
            else:
                processloop = processiter[0:self.max_processes]
                first = True
        else:
            processloop = iteritems(processdict)
            first = False
        for i in processloop:
            procstat = i[1]
            if (self.max_processes is not None):
                s = self.__get_process_stats(i[0], mandatory_stats=False, standard_stats=True, extended_stats=first)
                if (s is None):
                    continue
                procstat.update(s)
            procstat['time_since_update'] = time_since_update
            self.processlist.append(procstat)
            first = False
    self.allprocesslist = [p for p in itervalues(processdict)]
    if self.cache_timer.finished():
        self.username_cache = {}
        self.cmdline_cache = {}
        self.cache_timer.reset()
