From 4e6a8674f3fb69ca3a0ea6916612f71fc9c1a3fb Mon Sep 17 00:00:00 2001 From: mattf Date: Tue, 26 Sep 2006 20:06:38 +0000 Subject: [PATCH] change AST_update.pl to check for bin util locations for performance stat gathering git-svn-id: svn://192.168.202.10@299 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/bin/AST_update.pl | 44 +++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/agc_2-X/trunk/bin/AST_update.pl b/agc_2-X/trunk/bin/AST_update.pl index bd343fef..6ca408cb 100644 --- a/agc_2-X/trunk/bin/AST_update.pl +++ b/agc_2-X/trunk/bin/AST_update.pl @@ -52,9 +52,10 @@ # 60808-1005 - changed to use /etc/astguiclient.conf for configs # 60808-1500 - Fixed another bug in that caused crash with ** in extension # 60814-1523 - SYSLOG and SYSPERF looked up from database, dynamic settings +# 60926-1601 - validate proper binutil locations for performance gathering # -$build = '60814-1523'; +$build = '60926-1601'; # constants $SYSPERF=0; # system performance logging to MySQL server_performance table every 5 seconds @@ -69,6 +70,39 @@ $cpuUSERprev=0; $cpuSYSTprev=0; $cpuIDLEprev=0; +# find proper locations of bin utils + +# cat +$bincat = "/usr/bin/cat"; +if (-e "/usr/local/bin/cat") + {$bincat = "/usr/local/bin/cat";} +else + { + if (-e "/bin/cat") + {$bincat = "/bin/cat";} + } + +# free +$binfree = "/usr/bin/free"; +if (-e "/usr/local/bin/free") + {$binfree = "/usr/local/bin/free";} +else + { + if (-e "/bin/free") + {$binfree = "/bin/free";} + } + +# ps +$binps = "/bin/ps"; +if (-e "/usr/local/bin/ps") + {$binps = "/usr/local/bin/ps";} +else + { + if (-e "/usr/bin/ps") + {$binps = "/usr/bin/ps";} + } + + # DB table variables for testing $parked_channels = 'parked_channels'; $live_channels = 'live_channels'; @@ -502,7 +536,7 @@ if (!$telnet_port) {$telnet_port = '5038';} $cpuUSERcent=0; $cpuSYSTcent=0; $cpuIDLEcent=0; ### get processor usage seconds ### # cpu 924841 211725 270473 6961811 - @cpuUSE = `/usr/bin/cat /proc/stat`; + @cpuUSE = `$bincat /proc/stat`; if ($cpuUSE[0] =~ /cpu\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/) { $cpuUSER = ($1 + $2); @@ -524,19 +558,19 @@ if (!$telnet_port) {$telnet_port = '5038';} } ### get system load ### - $serverLOAD = `/usr/bin/cat /proc/loadavg`; + $serverLOAD = `$bincat /proc/loadavg`; $serverLOAD =~ s/ .*//gi; $serverLOAD =~ s/\D//gi; ### get memory usage ### - @GRABserverMEMORY = `/usr/bin/free -m -t`; + @GRABserverMEMORY = `$binfree -m -t`; if ($GRABserverMEMORY[1] =~ /Mem:\s+(\d+)\s+(\d+)\s+(\d+)\s+/) { $MEMused = $2; $MEMfree = $3; } ### get number of system processes ### - @GRABserverPROCESSES = `/bin/ps -A --no-heading`; + @GRABserverPROCESSES = `$binps -A --no-heading`; $serverPROCESSES = $#GRABserverPROCESSES; if ($SYSPERF_rec) {$recording_count = ($test_local_count / 2)}