From 677993a8c08d77eb8d07ffb55abb8e1cb001afd4 Mon Sep 17 00:00:00 2001 From: koichirok Date: Fri, 29 Jul 2011 09:15:37 +0000 Subject: [PATCH] 2011-07-29 Koichiro Kikuchi * unix/pandora_agent: Don't remove 1st line of the result of the PROC_CMDS, 1st line isn't a header. Also fixed and simplified some commands. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4649 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_agents/ChangeLog | 5 +++++ pandora_agents/unix/pandora_agent | 11 ++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pandora_agents/ChangeLog b/pandora_agents/ChangeLog index ffdf9a95dc..ecaa56bf4f 100644 --- a/pandora_agents/ChangeLog +++ b/pandora_agents/ChangeLog @@ -1,3 +1,8 @@ +2011-07-29 Koichiro Kikuchi + + * unix/pandora_agent: Don't remove 1st line of the result of the PROC_CMDS, + 1st line isn't a header. Also fixed and simplified some commands. + 2011-07-18 Sergio Martin * unix/Linux/pandora_agent.conf: Change default memory modules to get it with free command diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index df605acf98..76fbf31c34 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -58,9 +58,9 @@ use constant AGENT_BUILD => '110629'; # Commands to retrieve total memory information in kB use constant TOTALMEMORY_CMDS => { linux => 'cat /proc/meminfo | grep MemTotal: | awk \'{ print $2 }\'', - solaris => 'MEM=`prtconf | grep Memory | awk \'{print $3}\'` bash -c \'echo $(( 1024 * $MEM ))\'', + solaris => '/usr/sbin/prtconf | awk \'/Memory/ { print $3 * 1024 }\'', hpux => 'swapinfo -t | grep memory | awk \'{print $2}\'', - freebsd => 'sysctl hw.physmem | awk \'{print $2 / 1024}\'' + freebsd => '/sbin/sysctl hw.physmem | awk \'{print $2 / 1024}\'', }; # Commands to retrieve free memory information in kB @@ -68,7 +68,7 @@ use constant FREEMEMORY_CMDS => { linux => 'cat /proc/meminfo | grep MemFree: | awk \'{ print $2 }\'', solaris => 'vmstat 1 2 | tail -1 | awk \'{ print $5 }\'', hpux => 'swapinfo -t | grep memory | awk \'{print $4}\'', - freebsd => 'vmstat -H 1 2 | tail -1 | awk \'{ print $5 }\'' + freebsd => '/sbin/sysctl -n vm.stats.vm.v_page_size vm.stats.vm.v_free_count | tr "\n" " " | awk \'{ print $1 * $2 / 1024 }\'', }; # Commands to retrieve cpu information @@ -86,7 +86,7 @@ use constant PROC_CMDS => { solaris => 'prstat 1 1 | awk \'NR > 1 {split ($10, ps, "/"); cpu = substr ($9, 1, length ($9) - 1); mem = substr ($3, 1, length ($3) - 1); print cpu, mem, ps[1]}\'', hpux => 'ps -elf | awk \'NR > 1 {ps = ""; for (i = 15; i <= NF; ++i) {ps = (ps " " $i) }; print 0, $10, ps}\'', aix => 'ps aux | awk \'NR > 1 {print $3, $6, $11}\'', - freebsd => 'ps -axw -o %cpu,%mem,command | awk \'NR > 1 {ps = ""; for (i = 3; i <= NF; ++i) {ps = (ps " " $i) }; print $1, $2, ps}\'' + freebsd => 'ps axww -o %cpu= -o %mem= -o command= | sed -e "s/^ *//"', }; # Commands to retrieve partition information in kB @@ -1011,9 +1011,6 @@ sub load_procs () { my @procs = `$cmd`; return undef unless ($? eq 0); - # Discard the header - shift (@procs); - # Parse process information foreach my $proc (@procs) {