Skip to content

Instantly share code, notes, and snippets.

@kapb14
Last active August 26, 2019 10:59
Show Gist options
  • Select an option

  • Save kapb14/195feb1ca3f15a20139634543093eeb1 to your computer and use it in GitHub Desktop.

Select an option

Save kapb14/195feb1ca3f15a20139634543093eeb1 to your computer and use it in GitHub Desktop.
<?php
$status = file_get_contents('/proc/' . getmypid() . '/status');
print $status . "\n";
#!/bin/bash
# https://abdussamad.com/archives/488-Memory-usage-of-a-process-under-Linux.html
# curl -Os https://gist.githubusercontent.com/kapb14/195feb1ca3f15a20139634543093eeb1/raw/817277fff1bf3c2c9e3940db2d24089167475d4c/psmem.sh && chmod +x psmem.sh && cp -v psmem.sh /sbin/psmem
# git clone https://gist.github.com/195feb1ca3f15a20139634543093eeb1.git /opt/psmem && chmod +x /opt/psmem/psmem.sh && ln -s /opt/psmem/psmem.sh /sbin/psmem
if [[ -z "$1" ]]
then
echo "Usage: $(basename $0) PROCESS_NAME"
echo "Example: $(basename $0) httpd"
exit 1
else
ps -C $1 -O rss | gawk '{ count ++; sum += $2 }; END {count --; print "Number of processes =",count; print "Memory usage per process =",sum/1024/count, "MB"; print "Total memory usage =", sum/1024, "MB" ;};'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment