2

I need to make both the day name and the date appear in the X-axis. So far, rrdtool seems to decide whether to put the date (only the day of the month though, eg: 17, 18 etc) or the day name depending on the size of the rendered image. As seen in the below images.

How do I make rrdtool do something like this:

First line:  Tuesday
Second line: 14/07/2015

Or even:

First line:  Tuesday  
Second line: 14th July 2015

For each day within the week?

enter image description here

enter image description here

user9993
  • 5,833
  • 11
  • 56
  • 117

1 Answers1

2

You can specify the format of the x-axis labels using the --x-grid option.

The parameters specify all the properties of the x-grid including the labels and their positioning. You can not have a multi-line label, but you can use full strftime formatting to specify a label of your choice.

Normally rrdtool will pick something 'sensible' automatically but you can specify your own rule if you want:

[-x|--x-grid GTM:GST:MTM:MST:LTM:LST:LPR:LFM]

The grid is defined by specifying a certain amount of time in the ?TM positions. You can choose from SECOND, MINUTE, HOUR, DAY, WEEK, MONTH or YEAR. Then you define how many of these should pass between each line or label. This pair (?TM:?ST) needs to be specified for the base grid (G??), the major grid (M??) and the labels (L??). For the labels you also must define a precision in LPR and a strftime format string in LFM. LPR defines where each label will be placed. If it is zero, the label will be placed right under the corresponding line (useful for hours, dates etcetera). If you specify a number of seconds here the label is centered on this interval (useful for Monday, January etcetera).

--x-grid MINUTE:10:HOUR:1:HOUR:4:0:%X

This places grid lines every 10 minutes, major grid lines every hour, and labels every 4 hours. The labels are placed under the major grid lines as they specify exactly that time.

--x-grid HOUR:8:DAY:1:DAY:1:86400:%A

This places grid lines every 8 hours, major grid lines and labels each day. The labels are placed exactly between two major grid lines as they specify the complete day and not just midnight.

A strftime format to show weekday and date would be %a %D

Also note that with rrdtool 1.5.x the automatic labeling code has been re-done ... and produces more sensible results.

Tobi Oetiker
  • 5,167
  • 2
  • 17
  • 23
  • What Tobi said, in addition to that the `LFM` uses the same formate as the `date` command in linux. Run `man date` to get a list of options – Jim Oct 14 '19 at 00:09
  • @Nakilon, nope, I meant `man date`, but strftime works too – Jim Sep 25 '21 at 01:32
  • ok, maybe man was different on linux and macos when I tried before leaving the comment – Nakilon Sep 25 '21 at 21:10