Table des matières

Généralités

Tips

the top 10 CPU-consuming processes

ps aux | head -1; ps aux | sort -rn +2 | head -10

the top 10 memory-consuming processes

ps aux | head -1 ; ps aux | sort -rn +3 | head

Obtenir des infos sur un segment mémoire

On liste les segments mémoire avec la commande suivante :

root@machine:/home/root$ ipcs -mP|awk '/m/ {ligne=$0} /SID/ {print ligne" " $1}'
m   1179648 0x76003809 --rw-rw-rw-     root   system SID:0x2561
m    131073 0x76003810 --rw-rw-rw-     root   system SID:0x19007
m         2 0x0d097858 --rw-rw----     root   system SID:0x25a1
m         3 0xffffffff D-rw-------  suiveur    suivi SID:0x3865c
m    393220 0x0052e2c1 --rw-------  suiveur    suivi SID:0x2fc97
m         5 0xffffffff --rw-rw----     root   system SID:0x8c0
m   3145734 0x0000cace --rw-rw-rw-     root   system SID:0xd808
m   8126471 0xffffffff --rw-rw----     root   system SID:0x6ab

Soit la ligne suivante :

m         2 0x0d097858 --rw-rw----     root   system SID:0x25a1

On récupère le SID, ici 0x25a1, ensuite un svmon nous donnera plus d'infos :

root@machine:/home/root$ svmon -lS 0x25a1

    Vsid      Esid Type Description              PSize  Inuse   Pin Pgsp Virtual
    25a1         3 work shared memory segment        s      1     0    0     1
                   pid(s)=80434, 78606, 73892, 72518, 70314, 68498, 62240,
                   pid(s)=61728, 57886, 54110, 50450, 48752, 34464, 31384,
                   pid(s)=27290, 22746

Monitorer un process

Si vous avez besoin d'une analyse fine de la conso mémoire d'un process donné, vous pouvez utiliser le script suivant:

MonitorConsoPId.ksh

Il s'utilise ainsi:

./MonitorConsoPID.ksh <pid>

Pour couper:

./MonitorConsoPID.ksh <pid> stop

Il s'arrete aussi une fois que le PID suivi meurt.

Par défaut, on mesure toutes les 10 secondes, ça se modifie dans le script de même pour le choix de la log. (par defaut: /apps/sys/log/stats/NMON/MEMUSE_<pid>_<YYYYMMDD>.csv).

Après traitement, on peut le donner à Excel, il saura quoi en faire.

Supprimer un segment mémoire inutilisé

On liste les segments mémoire :

root@server:/home/root$ ipcs -mS|awk '/^0x/{print substr($1,3)}'|xargs -i svmon -lS {}

    Vsid      Esid Type Description              PSize  Inuse   Pin Pgsp Virtual
   3c43e         3 work shared memory segment        s      1     0    0     1
                   pid(s)=76144, 72132, 71146, 69064, 66022, 64196, 61696,
                   pid(s)=60624, 58908, 57910, 50648, 48944, 47748, 46444,
                   pid(s)=39758, 38666, 35698, 32846, 26416, 26008, 24804,
                   pid(s)=15234

    Vsid      Esid Type Description              PSize  Inuse   Pin Pgsp Virtual
   3c55e         3 work shared memory segment        s      1     0    0     1
                   pid(s)=27358

    Vsid      Esid Type Description              PSize  Inuse   Pin Pgsp Virtual
   3a59d         4 work shared memory segment        s     32     0    0    32
                   pid(s)=27358

    Vsid      Esid Type Description              PSize  Inuse   Pin Pgsp Virtual
    4722         3 work shared memory segment        s    357     0    0   357
                   pid(s)=70000, 66458, 63240, 63072, 59712, 54592, 51662,
                   pid(s)=46050, 43942, 40046, 39316, 37074, 36852, 34342,
                   pid(s)=30202, 29744, 28328

    Vsid      Esid Type Description              PSize  Inuse   Pin Pgsp Virtual
   1c8ee         4 work shared memory segment        s      1     0    0     1
                   pid(s)=34576

    Vsid     Esid Type Description              PSize  Inuse   Pin Pgsp Virtual
   20ab1         - work                              s      1     0    0     1
                   Unused segment

Ensuite on recupère l'adresse avec ipcs -mS :

m 114425863 0x0000cace --rw-rw-rw-     root   system
SID :
0x20ab1

Puis on le supprime + slibclean :

ipcrm  -M 0x0000cace
slibclean

Liens