Occasionally change values in rrd4-persistance-DB

Hi there,

is there a SIMPLE-Noob-way of changing some values in the rrd4-database??
I have occasionally the issue, that exactly at 00:00, when I do a lot of rules (daily calculations and resets a.s.o.) I hav a wrong value anywhere, because sometime a rule is not exacltly fired and or some reconditions are not done. This results sometimes in wrong values for the day.
The same sometimes happens when playing around and doing a mistake somewhere

Not really dramatic, but annoying.

So it would be cool, to have the possibility to manually change the values to a (more) correct value, to have this spikes away in history.

Any hint is appreciated, but keep in mind, I´m not a programmer :wink:

You obviously didn’t you the sesrch function for “Change rrd values”.
You would have found a rather old thread which shows how to do it. You would have to use the actually used rrd4j version, otherwise your rrd won’t be opened.

Note that you would have to change the effected entries in EACH archive!

I have used this once before:

Here is a script I did ages ago.

echo Run this on a computer with a display. Cant run it headless
#There are some post in this forum about the usage of the inspector, but they are incomplete. So go to this site: https://repo1.maven.org/maven2/org/rrd4j/rrd4j/3.3.1/ 133 and download these TWO files:
#    rrd4j-3.3.1-inspector.jar AND
#    rrd4j-3.3.1.jar
#Put both files into the same directory. Use a CLI and change into this directory. Start the inspector with
#java -cp rrd4j-3.3.1-inspector.jar org.rrd4j.inspector.RrdInspector
#Select a rrd4j file for inspection. If you get an error like Exception in thread “main” java.lang.NoClassDefFoundError: org/rrd4j/core/RrdDb, then you are missing the 2nd .jar-file from above!
mkdir rrd4jFix
cd rrd4jFix

wget -c -N https://repo1.maven.org/maven2/org/rrd4j/rrd4j/3.3.1/rrd4j-3.3.1-inspector.jar
wget -c -N https://repo1.maven.org/maven2/org/rrd4j/rrd4j/3.3.1/rrd4j-3.3.1.jar
java -cp rrd4j-3.3.1-inspector.jar org.rrd4j.inspector.RrdInspector

Thanks guys.
I´m still not a developer :wink:
Anyhow, in fact I FOUND that threat and was not sure, whether it still is valid as it was from 2018, I should have said that in the initial post. It would not be the first time that I broke my system with (too) old tipps from anywhere on the internet…

Are you sure it is still working with a OH4 including new java-version?

Yes, used it yesterday for my openHAB 4 installation.

1 Like

Greg, you are saying, it is NOT working on a headless system? I run OH on a headless Raspi4

You copy your rrd files to a computer with a screen and run the program. Hack the file and put it back. Make a backup as well.
Obviously stop OH first.
I am running headless as well.
PS I am NOT a developer either.


LOL, trying to do my best.

THANKS to all

I would suggest that you should also spend some time to prevent this from happening in the first place. Without details I can only offer generic ideas:

  • put all the calculation in a single rule
  • use Group aggregation functions
  • stagger the runtime of the rules so there is plenty of time between them that they run in the required order
  • calculate the value on events as the day progresses but only persist the value at the given time
  • use the new persistence filters to prevent obviously out of range values from being saved (maybe no value is better than a really wrong one)

I TOTALLY agree with your way. Avoid errors is always better than correcting them.
The “new day”-rule´s have already been reworked and reordered, and I use the min and max from the MQTT-things to filter valid values.

Unfortunately this helps only for the part the system writing wrong values and did not prevent ME from doing wrong calculations, which probably happens more often at all :wink: