Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Add --show-status and extend cache to store more information about last update #457

Open
fdcastel opened this issue Sep 27, 2023 · 6 comments

Comments

@fdcastel
Copy link
Contributor

Following #455. I propose:

  1. 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.

  2. Extend the informations stored in Inadyn cache files.

    Currently the cache file stores only the last ip address updated by inadyn.

    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.

@acolomb
Copy link
Contributor

acolomb commented Sep 27, 2023

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 :-)

@troglobit
Copy link
Owner

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.

@acolomb
Copy link
Contributor

acolomb commented Sep 28, 2023

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.

@troglobit
Copy link
Owner

Agreed 👍 very true.

@fdcastel
Copy link
Contributor Author

fdcastel commented Sep 28, 2023

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:

  1. this still leaves out where we could store the last error message if one occurred in the last run; and

  2. 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

@troglobit
Copy link
Owner

That looks very nice. And possible to source from a shell script, I like it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants