Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix processes resource user and command truncation #1225

Merged
merged 2 commits into from
Oct 18, 2016
Merged

Fix processes resource user and command truncation #1225

merged 2 commits into from
Oct 18, 2016

Conversation

alexpop
Copy link
Contributor

@alexpop alexpop commented Oct 17, 2016

Fixes #995

Uses code submitted by @Anirudh-Gupta here: #1173

Linux:

inspec> processes('/opt/chef-compliance/embedded/service/core/bin/core run').list
=> [#<struct Inspec::Resources::Processes::Process
  label="system_u:system_r:init_t:s0",
  pid=801,
  cpu="0.0",
  mem="3.7",
  vsz=481740,
  rss=57368,
  tty="?",
  stat="Ssl",
  start="12:43:15",
  time="00:00:02",
  user="chef-compliance",
  command=
   "/opt/chef-compliance/embedded/service/core/bin/core run --mode=setup --oidc --oidc-issuer-url https://ap-cc6.opschef.tv --oidc-client-id JZik-QcuP1LK2lOmL8l1qQwyazeI6XoUhvYnOb7oFz0=@ap-cc6.opschef.tv --oidc-redirect-url https://ap-cc6.opschef.tv/api/callback">]

OSX:

inspec> processes('Support/mdworker -s mdworker').list
=> [#<struct Inspec::Resources::Processes::Process
  label=nil,
  pid=92252,
  cpu="0.0",
  mem="0.1",
  vsz=2519384,
  rss=12628,
  tty="??",
  stat="S",
  start="3:03PM",
  time="0:00.03",
  user="_spotlight",
  command=
   "/System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Versions/A/Support/mdworker -s mdworker -c MDSImporterWorker -m com.apple.mdworker.shared">]

@alexpop alexpop added the Type: Bug Feature not working as expected label Oct 17, 2016
@alexpop alexpop self-assigned this Oct 17, 2016
os = inspec.os

if os.linux?
command = 'ps auxZ'
command = 'ps axo label,pid,pcpu,pmem,vsz,rss,tty,stat,start,time,user:32,command'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to add to it - Limiting the user field here since Usernames may only be upto 32 chars long. (Taken from man page - https://linux.die.net/man/8/useradd)
Can also use args instead of command. Both can be used interchangeably.

@alexpop alexpop changed the title Fir processes resource user and command truncation Fix processes resource user and command truncation Oct 18, 2016
@alexpop alexpop merged commit 41d3116 into inspec:master Oct 18, 2016
@alexpop alexpop deleted the ag-ap/processes-user-comm branch October 18, 2016 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Feature not working as expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants