Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"So why don't you make like a tree, and get outta here." -- Biff in "Back to the Future"


devel / comp.unix.shell / tracing the Proportional Set Size (PSS) of a process

SubjectAuthor
o tracing the Proportional Set Size (PSS) of a processCelalD

1
tracing the Proportional Set Size (PSS) of a process

<e15243b5-9a3c-46d4-bf61-ab7c912db817n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=3721&group=comp.unix.shell#3721

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:ae9:c014:: with SMTP id u20mr21545836qkk.387.1620065820456;
Mon, 03 May 2021 11:17:00 -0700 (PDT)
X-Received: by 2002:a37:7906:: with SMTP id u6mr14496757qkc.225.1620065820155;
Mon, 03 May 2021 11:17:00 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Mon, 3 May 2021 11:16:59 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=160.83.30.185; posting-account=bO5cCQoAAADl1pF-8W0XKpSxQis5ejlR
NNTP-Posting-Host: 160.83.30.185
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e15243b5-9a3c-46d4-bf61-ab7c912db817n@googlegroups.com>
Subject: tracing the Proportional Set Size (PSS) of a process
From: cdik...@gmail.com (CelalD)
Injection-Date: Mon, 03 May 2021 18:17:00 +0000
Content-Type: text/plain; charset="UTF-8"
 by: CelalD - Mon, 3 May 2021 18:16 UTC

Hi Group,

I've here (Red Hat EL 7.9) the issue to calculate the real memory usage of a process - actual and trace
Background: some Nagios-like monitoring tool reports "memory full" although there is still memory free, which triggers false positives.

During my research, I found that the common ps command estimates the memory size not right:

"Resident Set Size (RSS) : The standard measure of physical memory (it typically shared among multiple applications) usage known as resident set size (RSS) will significantly overestimate memory usage."
(https://www.2daygeek.com/smem-linux-memory-usage-statistics-reporting-tool/)

As an alternative, the above site suggest to use smem instead. Unfortunately, smem is not included in the standard RHEL repository.
In EPEL smem is available but unfortunately not allowed to use due restrictions set by company.

Thus, I'm looking for alternatives how to measure the PSS value of a process; the best would be using shells own capabilities or Perl (v5.16.3 is installed) or Python (v2.7).

==> has someone an idea or already programmed such a solution?

For the sake of completeness, below I have put the tries (which have nothing with PSS) of my ancestor to solve the problem; just if you have comments on them.

Thanks,
Celal

memchecker.sh
#!/bin/bash

echo -e "USER Memory(%) Process TOTALUSEDMEMORY(MB) TOTALFREEMEMORY(MB) TOTALMEMORY(MB)" |sed 's/ /\| /g'
for i in {1..50};do
echo `ps aux|egrep 'app1adm|app2adm'|sort -rnk 4 |head -$i|tail -1|awk '{print $1,$4,$11}'` `free -m |grep ^M|awk '{print $3,$4,$2}'` |sed 's/ /\| /g'
done

---

memtest.sh
#!/bin/bash
function report_utilisation {
echo
echo Memory eaters :

cat /tmp/mem_usage.$$ |
awk '
{ process[$1]+=$2; }
END{
for(i in process)
{
printf("%-20s %sn",i, process[i]) ;
}

}' | sort -nrk 2 | head

rm /tmp/mem_usage.$$
exit 0
}

trap 'report_utilisation' INT

SECS=900
UNIT_TIME=10

STEPS=$(( $SECS / $UNIT_TIME ))

echo Watching Memory usage... ;

# Collect data in temp file
for((i=0;i<$STEPS;i++)); do
ps -eocomm,pmem | egrep -v '(0.0)|(%MEM)' >> /tmp/mem_usage.$$
sleep $UNIT_TIME
done

report_utilisation

----

memmap.sh
!/bin/bash

printf "%-10s%-15s%-15s%s\n" "PID" "OWNER" "MEMORY" "COMMAND"

function sys_main {
RAWIN=$(ps -o pid,user,%mem,command ax | grep -v PID |grep -v root| sort -bnr -k3 |
awk '/[0-9]*/{print $1 ":" $2 ":" $4}')

for i in $RAWIN
do
PID=$(echo $i | cut -d: -f1)
OWNER=$(echo $i | cut -d: -f2)
COMMAND=$(echo $i |cut -d: -f3)
MEMORY=$(pmap $PID |tail -n 1 |awk '/[0-9]K/{print $2}')

printf "%-10s%-15s%-15s%s\n" "$PID" "$OWNER" "$MEMORY" "$COMMAND"
done
} sys_main | sort -bnr -k3 |head -n 50

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor