diff --git a/forensics/mxvmem b/forensics/mxvmem index 528873f..27e2143 100755 --- a/forensics/mxvmem +++ b/forensics/mxvmem @@ -3,12 +3,12 @@ ''' show memory consumption per user - The script reads conserved or live information from the /proc - directory and shows memory consumption per user. + The script analyses actual or recorded memory usage on the + host where it is run. - The default is to read the most recent forensics dump found in - /var/log. When called with the '-p' option, data is collected - from /proc. + The default is to read the information live from the /proc + directory. When called with the '-c' option, /var/log is + searched for the most recent forensics dump. Setting the FORENSICS_STORE environment variable overrides the default directory where the forensics logs are searched. @@ -26,6 +26,7 @@ History: 13.10.2022, created, Kreitler + 08.05.2024, default to reading the state 'live' ''' @@ -415,14 +416,14 @@ def handle_args(): help="show documentation", action='store_true') ap.add_argument("-a", dest='allentries', help='print all entries, makes you scroll, helps when piping', action='store_true') + ap.add_argument('-c', dest='readconserved', + help='read data from a conserved forensics dump', action='store_true') ap.add_argument("-d", dest='logdir', metavar='dir', default=None, help='location of forensics logs (/var/log)') ap.add_argument('-m', dest='memthresh', metavar='percent' , help='threshold for memory usage report (10%%)', default=10.0, type=float) ap.add_argument('-q', dest='query', metavar='query' , help='report memory usage for given categories (eg. \'SD\')', default='') - ap.add_argument('-p', dest='readproc', - help='read current data from proc', action='store_true') ap.add_argument('-s', dest='summary', help='print short summary', action='store_true') ap.add_argument('-t', dest='durationthresh', metavar='days' , @@ -454,9 +455,7 @@ if __name__ == '__main__': else: print('# Error: can not read', args.forensicsfile, file=sys.stderr) quit() - elif args.readproc: - proc = ProcInfo() - else: + elif args.readconserved: default_logdir = '/var/log' logdir = None if 'FORENSICS_STORE' in os.environ: @@ -473,6 +472,8 @@ if __name__ == '__main__': print('# Fatal: no logs found in', logdir, file=sys.stderr) quit() proc = ProcInfoSaved(logs[0][0]) + else: + proc = ProcInfo() if args.verbose: print(' Reading:', "'%s'" % proc.source, '...')