0

I'm wanting to graph the memory of certain processes in windows using rrdtool which I can then show in a simple webpage.

So I got this far. Not quite sure I understand how it works after following some tutorials I get blank output.

rrdtool create psrvr-mem.rrd --start 1023654125 --step 300 DS:mem:GAUGE:600:0:U RRA:AVERAGE:0.5:12:24 RRA:AVERAGE:0.5:288:31

Update script.

@ECHO OFF

:LOOP
FOR /F "tokens=*" %%g IN ('powershell "get-process psrvr | select -ExpandProperty PrivateMemorySize"') do (SET mem_usage=%%g)

rrdtool update psrvr-mem.rrd N:%mem_usage%
TIMEOUT /t 300
GOTO LOOP

And finally the graph

rrdtool graph memory.png --start -1800 -a PNG -t "Memory" --vertical-label "" -w 1260 -h 400 -r DEF:mem=psrvr-mem.rrd:mem:AVERAGE  AREA:mem#FF0000

Unfortunately, the result is an empty graph. Not sure why. And not quite understanding if the start time is particularly critical or not.

-- edit -- Still not creating lines on the graph. However, well I found one problem is there were no labels on any axis. Because the font file was missing. Turns out the pre-compiled binaries downloaded from rrdtool website are 15 years out of date for windows. I found a newer binary but if I get this going then I'll probably try and compile it with the latest revision. For now, I'll settle with something that seems to be working better from 2013.

After more messing about this is my attempt at creating a 5 minute average. rrdtool create psrvr-mem.rrd --start 1592774026 --step 60 DS:mem:GAUGE:120:0:U RRA:AVERAGE:0.5:1:5

Then fill with some values using the update script above.

And then try to graph it again. rrdtool graph memory.png --start=now-300 -a PNG -t "Memory" --vertical-label "Bytes" -w 800 -h 300 -r DEF:mem=psrvr.rrd:mem:AVERAGE LINE:mem#FF0000

The output is a graph where the line isn't moving. It might be zero all the way.

enter image description here

hookenz
  • 36,432
  • 45
  • 177
  • 286
  • Did you get any error messages from the `rrdtool graph` command? What do you mean by 'empty graph' -- a blank image, a graph frame with no line, etc? Also , the start time is important else rrdtool doesnt know what time point to make the graph start (the end defaults to 'now'). Finally, if you get a graph with no line, are you sure that the RRA actually has any data for that time window? – Steve Shipway Jun 21 '20 at 03:57
  • @SteveShipway - updated – hookenz Jun 21 '20 at 21:44
  • @SteveShipway - By blank I meant that it didn't seem to graph anything. It might have graphed something but the line as all zero right across. Despite moving data? maybe... not sure. – hookenz Jun 21 '20 at 21:50
  • I got a little closer. I made it work with a step of 1 and called update every second and inserted a random number then regenerated the graph with start = now-60. It produced something more meaningful. Is it perhaps that the memory usage is not changing so it is down around the zero mark? All I'm wanting to start with is a 5 minute average memory for a process. It should show the output in megabytes. – hookenz Jun 21 '20 at 21:59
  • The script is updating values every 300s, but your second create specifies a 60s interval, and the graph is only 300s wide? Dont forget you need to have at least 3 sequential samples in order to start getting a line on your graph due to the way normalisation and rates work in RRDTool – Steve Shipway Jun 23 '20 at 00:56

0 Answers0