2017-02-01 1 views
0

프로세스 (PID)별로 AIX 6.1 서버에서 실시간 CPU %로드를 모니터링하고 IBM 설명서에서이 두 가지를 모두 검색하는 스크립트를 작성하려고합니다. 그리고 온통 stackoverflow.AIX 6.1의 프로세스 모니터링 스크립트 별 실시간 CPU %

난 단지 예를 들어, 사용하는 사람의 예를 찾아

ps aux 

, 그것은 단지 모니터링하기 때문에 프로세스가 세션 시간이 지남에 사용하고 얼마나 많은 CPU % 내가 필요하지 이잖아 말할 필요도없이있는 내 경우에는 꽤 길다. 필자가 필요로하는 정보는 topas와 nmon에 포함되어 있지만 각 개별 순간에이 정보의 스냅 샷을 잡는 방법을 알지 못합니다.

top 

AIX 시스템에는 존재하지 않습니다.

답변

0

30 번째 두 번째 tprof 로그를 생성하고 PID를 기준으로 프로세스 스레드를 더하고 실시간 CPU로드 % 프로세스 목록과 같은 합계에 도달하는 것을 반복하는 스크립트를 작성하여이를 해결했습니다.

0
Here is a function I use to search and grab CPU load from nmon data log 

function fetch_UARG_process_by_pid() 
{ 

#Check_Argument $1 $2 

#parameter initialization 
filesource=$1 
cpuvalue=$2 
readarray -t X <<< "$(grep TOP $filesource)" 
length=${#X[@]} 

#echo " this is the length of my array : $length" 
#you have to start from 2 to avoid the first lines that describe the content of the file 
#TOP,%CPU Utilisation 
#TOP,+PID,Time,%CPU,%Usr, Sys,Size,ResSet,ResText,ResData,ShdLib,MinorFault,MajorFault,Command 

    for ((i = 2; i != length; i++)); do 
    echo ${X[i]} | awk -F "," '{print $2 , $4}' | while read processid n 
     do 
        if (($(echo "$n > $cpuvalue " |bc -l))); 
        then 
      echo "the value of CPU usage is: $n" 
      echo "the Linux PID is : $processid " 
      echo "And the short desciption of the process:" 
      echo ${X[i]} | awk -F "," '{print $14}' 
      echo -e "And the long desciption of the process:" 
         grep UARG $1 | grep $processid | awk -F "," '{print $5}' 
      echo -e "\n" 
      fi 
     done 
    done 

}