Skip to content

Commit

Permalink
mxvmem: default to read the memory info from /proc
Browse files Browse the repository at this point in the history
The old default behavior (reading forensics) repeatedly
caused confusion on the user side. So the less efficient
way is now the default. To get the old behavior. use '-c',
for 'conserved'.
  • Loading branch information
thomas committed May 14, 2024
1 parent 0fd7e6e commit e925874
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions forensics/mxvmem
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -26,6 +26,7 @@
History:
13.10.2022, created, Kreitler
08.05.2024, default to reading the state 'live'
'''

Expand Down Expand Up @@ -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' ,
Expand Down Expand Up @@ -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:
Expand All @@ -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, '...')
Expand Down

0 comments on commit e925874

Please sign in to comment.