Skip to content

Instantly share code, notes, and snippets.

@yordanoweb
Last active January 13, 2025 19:51
Show Gist options
  • Save yordanoweb/88940086380d6790a36504351dca6017 to your computer and use it in GitHub Desktop.
Save yordanoweb/88940086380d6790a36504351dca6017 to your computer and use it in GitHub Desktop.

Create RRD with custom options

#!/bin/sh

###################################################
# Create the graph first
###################################################
#
# rrdcreate wlan-traffic.rrd --start now-2h --step 60 DS:in:COUNTER:120:U:2000000 DS:out:COUNTER:120:U:2000000 RRA:AVERAGE:0.5:1:525600 RRA:AVERAGE:0.5:60:8760
#
# rrdtool create disk-32gb-temperature.rrd --start now --step 60 DS:temperature:GAUGE:120:U:U RRA:AVERAGE:0.5:1:1440
#
###################################################

/usr/bin/rrdtool update cpu-temperature.rrd N:$($HOME/etc/cpu_temp | head -n 1)

/usr/bin/rrdtool update disk-32gb-temperature.rrd N:$(sudo smartctl --all /dev/nvme1 | grep --color=never -E "^Temperature" | awk '{print $2}')

/usr/bin/rrdtool update disk-512gb-temperature.rrd N:$(sudo smartctl --all /dev/nvme0 | grep --color=never -E "^Temperature" | awk '{print $2}')

/usr/bin/rrdtool update wlan-traffic.rrd N:$($HOME/etc/wlan_traffic | head -n 1):$($HOME/etc/wlan_traffic | head -n 2 | tail -n 1)

/usr/bin/rrdtool update system-memory.rrd N:$(expr `free | grep --color=never "Mem:" | awk '{print $3}'` \* 1024)

/usr/bin/rrdtool graph cpu-temperature.png --start end-8h --end now --vertical-label="degrees" DEF:temp=$HOME/cpu-temperature.rrd:temperature:AVERAGE AREA:temp#FF0000:"Temp" GPRINT:temp:LAST:" Current\:%8.2lf %s" GPRINT:temp:AVERAGE:"Average\:%8.2lf %s" GPRINT:temp:MAX:"Maximum\:%8.2lf %s\n" HRULE:60#0000FF:""

/usr/bin/rrdtool graph disk-32gb-temperature.png --start end-8h --end now --vertical-label="degrees" DEF:temp=$HOME/disk-32gb-temperature.rrd:temperature:AVERAGE AREA:temp#FF0000:"Temp" GPRINT:temp:LAST:" Current\:%8.2lf %s" GPRINT:temp:AVERAGE:"Average\:%8.2lf %s" GPRINT:temp:MAX:"Maximum\:%8.2lf %s\n" HRULE:40#0000FF:""

/usr/bin/rrdtool graph disk-512gb-temperature.png --start end-8h --end now --vertical-label="degrees" DEF:temp=$HOME/disk-512gb-temperature.rrd:temperature:AVERAGE AREA:temp#FF0000:"Temp" GPRINT:temp:LAST:" Current\:%8.2lf %s" GPRINT:temp:AVERAGE:"Average\:%8.2lf %s" GPRINT:temp:MAX:"Maximum\:%8.2lf %s\n" HRULE:40#0000FF:""

/usr/bin/rrdtool graph wlan-traffic.png --start end-8h --end now --vertical-label="bytes" DEF:in=$HOME/wlan-traffic.rrd:in:AVERAGE DEF:out=$HOME/wlan-traffic.rrd:out:AVERAGE AREA:in#00CF00:"Rx" GPRINT:in:LAST:" Current\:%8.2lf %s" GPRINT:in:AVERAGE:"Average\:%8.2lf %s" GPRINT:in:MAX:"Maximum\:%8.2lf %s\n" LINE1:out#002A97:"Tx" GPRINT:out:LAST:"Current\:%8.2lf %s" GPRINT:out:AVERAGE:"Average\:%8.2lf %s" GPRINT:out:MAX:"Maximum\:%8.2lf %s" HRULE:500000#0000FF:""

/usr/bin/rrdtool graph system-memory.png --start end-8h --end now --vertical-label="GBytes" DEF:mem=$HOME/system-memory.rrd:mem:AVERAGE DEF:out=$HOME/system-memory.rrd:mem:AVERAGE AREA:mem#00CF00:"Mem" GPRINT:mem:LAST:" Current\:%8.2lf %s" GPRINT:mem:AVERAGE:"Average\:%8.2lf %s" GPRINT:mem:MAX:"Maximum\:%8.2lf %s\n" HRULE:5000000000#0000FF:""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment