3

I am using my Raspberry Pi with OpenMediaVault, a variant of Debian/Raspian intended for running a NAS server. The web interface for the operating system features a user interface that allows for hardware usage to be tracked using graphs generated by RRDTool that look like this:

RRDTool Graphs in OpenMediaVault

Obviously, the graphs are based on system time. I've noticed that this causes some problems when the Pi is rebooted or booted from a powered off state. When I first check the graphs after a reboot or fresh start, the graphs list a "Last Updated" date of December 2015, and when I force a refresh of the data, the graphs all end up looking like this:

RRDTool Graph Gone Wrong

I understand that this is happening because of the lack of an RTC on the Raspberry Pi, and although one could be acquired, I would like to work around doing so.

To do this, I would like to configure my Pi to sync both its date and time to an NTP server before RRDTool services kick in. Is it possible to achieve something like this?

2 Answers2

2

You could use the command ntpdate pool.ntp.org once the network is up (in a script in /etc/network/ip-up.d) and then once a day in root's crontab. If the time difference is too big after 24 hours, you can run it more frequently, like every 6 hours.

ott--
  • 189
  • 1
  • 1
  • 6
  • 1
    Thank you, but how could I stop RRDTool from starting before the sync has completed? – DaveTheMinion Jun 29 '16 at 21:27
  • How is that tool started? Is there a script in /etc/init.d? – ott-- Jun 29 '16 at 21:57
  • There are two services that I am looking to delay, and I see scripts with matching names for both of them in /etc/init.d. – DaveTheMinion Jun 29 '16 at 22:06
  • The scripts have symlinks to other directories like /etc/rc2.d and /etc/rc3.d, with names starting with Snn where nn ranges from 00 to 99 and S00_xxx is executed first, S99_xxx last. So create a script in /etc/init.d and link it to other directories so your script is executed before the RRDTools.. – ott-- Jun 29 '16 at 22:19
  • You may need to be a bit cautious in trying to reorganise the order in which things are stared up with the __S##__tart and __K##__ill scripts in the /etc/rc#.d - in that since Debian 8 ("Jessie") from which Raspbian is derived the default init sustem is systemd NOT sysV init and, unless you are a curmudgeonly stick-in-the-mud (like myself) you will find yourself using systemd which is a whole different ball-game (or so I understand) about ordering of and interdependence of "sub-systems" and "services" and I wouldn't want to swear that renumbering those scripts is going to work...! 8-) – SlySven Jul 02 '16 at 01:11
  • Oh, just checked and they are still using "Debian Linux (Wheezy) OS" currently a.k.a. as Debian "oldStable" or 7 (i.e. the version before the tentacled hydra that is systemd got set loose inside {it is present in the Wheezy distribution but hadn't got hold of the switch to set the default to it yet!}) - I just wonder for how much longer THAT distribution will be on Wheezy. – SlySven Jul 02 '16 at 01:18
  • @SlySven The last three comments that have been written have totally lost me. I can tell you that those in charge of distribution of OpenMediaVault are currently finalizing OpenMediaVault 3, which moves the disto over to Debian 8. – DaveTheMinion Jul 02 '16 at 02:45
  • tl;dr; ==> learn how to configure systemd to have a clock-setting service e.g. ntpdate or nptd up and running BEFORE RRDTool starts monitoring the data used to produce it's reports! – SlySven Jul 02 '16 at 12:22
  • Not being familiar with RRDTool (other than seeing it on my IPv6 tunnel broker's site for their on-line stats reporting) I do not know whether it looks at other programs log-files and uses "everything" it sees or whether it can be configured only to consider data from what is a "recent" time - i.e. to ignore "ancient" readings that arise from times before the system clock was corrected from the Midnight 1 Jan 1970 or whatever the RPi uses when it is booted up. – SlySven Jul 02 '16 at 12:24
1

There is only one way to reach the Stratum-1 servers, and that is to use time.nist.gov which is a pool address all by itself.

It will reach the quickest and most accurate time available on the web.

It will run automatically.

Here is a Q&A on this Stack Exchange that explains how to do it:

How do I set Raspbian to use the primary time server time.nist.gov?

SDsolar
  • 2,348
  • 8
  • 25
  • 43