2017-02-01 2 views
0

Ich versuche, ein Skript zu schreiben, das CPU-Auslastung in Echtzeit in AIX 6.1-Server nach Prozess (PID) überwacht und in der Dokumentation von IBM nach diesem gesucht hat und ganzer Stackoverflow.Echtzeit-CPU% von Prozessüberwachungsskript in AIX 6.1

ich nur Beispiele von Menschen finden, beispielsweise

ps aux 

Unnötig zu sagen, das ist nicht das, was ich brauche, da es nur überwacht, wie viel CPU% der Prozess die Sitzungszeit mit über wurde, die in meinem Fall ist ziemlich lang. Die Informationen, die ich brauche, sind in topas und nmon enthalten, aber ich weiß nicht, wie ich einen Schnappschuss dieser Informationen für jeden einzelnen Moment erfassen kann.

top 

In AIX-Systemen nicht vorhanden.

Antwort

0

Dies wurde gelöst, indem ein Skript erstellt wurde, das 30sekunde tprof-Protokolle generiert und durchläuft, die Prozess-Threads nach PID aufaddiert und eine Summe erreicht, die mehr oder weniger einer CPU-Auslastungsprozentliste in Echtzeit entspricht.

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 

}