Basically, I want to graph the memory usage with each username as title, as time passes by. I would set that script as a cron job, to create a graph that shows memory usage of certain usernames.
How can I graph percentage of memory consumption based on user?
Y-axis should be %MEM, X-axis should be time/date
I tried doing it with gnuplot, but failed.
The data I want to graph is:
for USER in $(ps haux | awk '{print $1}' | sort -u); do ps haux | awk -v user=$USER '$1 ~ user { sum += $4} END { print user, sum; }'; done
Example output:
102 0
avahi 0
colord 0
daemon 0
savvas 16.6
miredo 0
nobody 0
postfix 0
root 1.3
rtkit 0
syslog 0
whoopsie 0
The last gnuplot script I used:
set term png small size 800,600
set output "mem-graph.png"
set ylabel "%MEM"
set xlabel "Time"
set xtics nomirror
set ytics nomirror
set xrange [0:*]
set key autotitle columnheader
plot "mem.log" using 2 title columnhead(1) with lines
The script I use to graph:
#!/bin/bash
rm mem.log
while true
do
for USER in $(ps haux | awk '{print $1}' | sort -u); do ps haux | awk -v user=$USER '$1 ~ user { sum += $4} END { print user, sum; }'; done >> mem.log
gnuplot gnuplot.script
sleep 10
done
