Merge pull request #5232 from rgeissert/processes-output-truncation-issue

Run ps with an ulimited width on linux
This commit is contained in:
Nick Schwaderer 2020-09-02 15:57:42 +01:00 committed by GitHub
commit 508861b80f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View file

@ -138,7 +138,7 @@ module Inspec::Resources
command: 8,
}
else
command = "ps axo label,pid,pcpu,pmem,vsz,rss,tty,stat,start,time,user:32,command"
command = "ps wwaxo label,pid,pcpu,pmem,vsz,rss,tty,stat,start,time,user:32,command"
regex = /^(.+?)\s+(\d+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+(\w{3} \d{2}|\d{2}:\d{2}:\d{2})\s+([^ ]+)\s+([^ ]+)\s+(.*)$/
field_map = {
label: 1,

View file

@ -210,7 +210,7 @@ class MockLoader
'find /sys/class/net/eth1/ -maxdepth 1 -type f -exec sh -c \'echo "[$(basename {})]"; cat {} || echo -n\' \;' => empty.call,
"Get-Package -Name 'Not available' | ConvertTo-Json" => empty.call,
"ps axo pid,pcpu,pmem,vsz,rss,tty,stat,start,time,user,command" => cmd.call("ps-axo"),
"ps axo label,pid,pcpu,pmem,vsz,rss,tty,stat,start,time,user:32,command" => cmd.call("ps-axoZ"),
"ps wwaxo label,pid,pcpu,pmem,vsz,rss,tty,stat,start,time,user:32,command" => cmd.call("ps-axoZ"),
"ps -o pid,vsz,rss,tty,stat,time,ruser,args" => cmd.call("ps-busybox"),
"env" => cmd.call("env"),
"${Env:PATH}" => cmd.call("$env-PATH"),

View file

@ -228,6 +228,6 @@ describe "Inspec::Resources::Processes" do
it "returns the correct command for non-busybox linux" do
resource = MockLoader.new(:centos7).load_resource("processes")
resource.expects(:busybox_ps?).returns(false)
_(resource.send(:ps_configuration_for_linux)[0]).must_equal "ps axo label,pid,pcpu,pmem,vsz,rss,tty,stat,start,time,user:32,command"
_(resource.send(:ps_configuration_for_linux)[0]).must_equal "ps wwaxo label,pid,pcpu,pmem,vsz,rss,tty,stat,start,time,user:32,command"
end
end