Proposal: Add --show-status and extend cache to store more information about last update
fdcastel opened this issue · 6 comments
Following #455. I propose:
-
To add a
--status
/--show-status
parameter to Inadyn.This will do a "dry run" (run queries/collect information but don't change/update anything) and, for each configured hostname, output a result like:
hostname : MY_DOMAIN.COM update status: ok / outdated / error error message: (only when in "error" state) last run : Mon Sep 25 10:10:51 2023 current ip : XXX.XXX.215.113 last updated : Mon Sep 25 10:10:51 2023 ip source : eth0 / command / ifconfig.me actual ip : XXX.XXX.215.113l
The
-j
/--json
modifier could be used to output the above information in JSON format. -
Extend the informations stored in Inadyn
cache
files.Currently the
cache
file stores only the last ip address updated byinadyn
.Unfortunately, some other useful information are lost like:
- Timestamp of last (successful) update
- Result of last run (ok? error? which one?)
- Timestamp of last run
The cache format would need to be changed, of course. But (being a cache) this has a relatively minor impact. After a version upgrade, any attempt to read a cache file from older versions would simply be discarded (as if no cache file exists).
Opinions?
If approved, I would be glad to start working on a PR for this in the next week.
I think that would be a great addition.
Just to be pedantic, your three examples of information are actually (partly) present now, albeit not obvious.
- The last successful update should match the cache file's mtime.
- If there was an error, the cache wasn't updated, thus we know it was ok.
- If stored by the file system, the atime should tell you when the last run was. If different from the mtime, it was obviously not successful.
Not 100 % sure if that's correct, but anyway your suggestion is way more useful :-)
Looks good to me, please go ahead! :-)
@acolomb: yeah we discussed this a bit in the other issue, I mentioned mtime there, but I didn't consider atime could be used as well. That's clever.
Adding the info to the file's content is the better and more extensible idea anyway. I guess it's common on Linux distros nowadays to mount some system volumes with noatime
, so not really reliable.
Agreed 👍 very true.
Just to be pedantic, your three examples of information are actually (partly) present now, albeit not obvious.
You, sir, have eagle eyes. Nicely noted!
However, albeit clever:
-
this still leaves out where we could store the last error message if one occurred in the last run; and
-
as you already noted
Adding the info to the file's content is the better and more extensible idea anyway. I guess it's common on Linux distros nowadays to mount some system volumes with
noatime
, so not really reliable.Precisely! I have in my own home a small server with a ZFS filesystem mounted with
atime=off
(not that I'm planning to run Inaydn on it 😄).Also, Inadyn could run in so many different systems (*) that the reliance of filesystem timestamps could be a flaky solution, at best.
(*) I discovered this project when I found it running inside one of my routers.
I'm planning to attack this only in the next week so we still have time for more ideas and brainstorming.
For now, I leave you guys with a humble suggestion for the next cache file format (blatantly inspired on ddclient
format)
# inadyn 2.x.x cache file - do not modify
hostname=MY_DOMAIN.COM
ip=XXX.XXX.215.113
updatedAt=1695647451 # Mon Sep 25 10:11:56 2023
updateError= # None
lastRun=1695647451 # Mon Sep 25 10:11:56 2023
That looks very nice. And possible to source from a shell script, I like it!