示例#1
0
 def fpath_activities(self, fpath, time_slot=None, user=None, cmd=None):
     logs = pick(self.logs, [
         cond.in_timeslot('time', time_slot),
         cond.in_list('user', user),
         cond.in_list('cmd', cmd),
         cond.in_list('fpath', fpath),
     ])
     r = []
     for log in logs:
         x = log.copy()
         x.pop('fpath')
         r.append(x)
     return sorted(r, key=lambda l: l['time'])
示例#2
0
    def stat_users(self, time_slot, cmd=None, fpath=None):
        """ Count freq of users opening files

        Args:
            time_slot (tuple(datetime)): a tuple of two
                specifying the start and end time as datetime

            cmd (optional[list[str]]): a list of cmds within which
                to be filtered. Could also be a single str.

            fpath (optional[list[str]]): a list of files within which
                to be filtered. Could also be a single str.
        Returns:
            dict{str->int}: dict of users and counts
        """
        return stat(self.logs, 'user', [
            cond.in_timeslot('time', time_slot),
            cond.in_list('cmd', cmd),
            cond.in_list('fpath', fpath),
        ])