view load-graph @ 29:c2584db4a650

Make load recording more flexible and efficient * Works with variable number of CPUs * Use Python `enumerate()` function where possible * Use long-running NVidia function
author IBBoard <dev@ibboard.co.uk>
date Wed, 30 Dec 2020 17:22:29 +0000
parents 2576b5cfb71c
children dc0cf6bc9fbe
line wrap: on
line source

#! /bin/bash

start="-6h"
end="-0h"

if [ $# -eq 1 ]
then
	start=$1
elif [ $# -eq 2 ]
then
	start=$1
	end=$2
fi

cpu_count=$(lscpu|grep '^CPU(s)'|awk '{print $2}')

cpu_lines=()

for ((i=1; i<=cpu_count; i++)); do
	cpu_lines+=("DEF:core${i}=$HOME/.load.rrd:core${i}:AVERAGE")
	cpu_lines+=("LINE1:core${i}#99000040:\"Core-${i}\"")
done

rrdtool graph /tmp/load-percent.png -w 1280 -h 1024 -a PNG --start "$start" --end "$end" \
	--vertical-label "Usage (%)" \
	${cpu_lines[@]} \
	DEF:CPU=$HOME/.load.rrd:core_avg:AVERAGE \
	DEF:GPU=$HOME/.load.rrd:GPU:AVERAGE \
	LINE2:CPU#990000:"CPU" \
	LINE2:GPU#009900:"GPU" \
&& rrdtool graph /tmp/load-type.png -w 1280 -h 1024 -a PNG --start "$start" --end "$end" \
	--vertical-label "Usage (%)" \
	DEF:user=$HOME/.load.rrd:user:AVERAGE \
	DEF:system=$HOME/.load.rrd:system:AVERAGE \
	DEF:iowait=$HOME/.load.rrd:iowait:AVERAGE \
	AREA:iowait#888888:"I/O Wait" \
	STACK:system#6666FF:"System" \
	STACK:user#CCCC66:"User" \
&& rrdtool graph /tmp/load-memory.png -w 1280 -h 1024 -a PNG --start "$start" --end "$end" \
	--vertical-label "Usage (%)" \
	DEF:mem_used=$HOME/.load.rrd:mem_used:AVERAGE \
	DEF:mem_buffers=$HOME/.load.rrd:mem_buffers:AVERAGE \
	AREA:mem_used#888888:"Used" \
	STACK:mem_buffers#cccccc:"Buffers" \
&& eog /tmp/load-*.png
rm -f /tmp/load-*.png