How to remove a host ?
Hello.
It's not actually a bug, but more a question.
When I remove a host from the router.db file, it doesn't get removed from the local GIT repository.
Is there a way to completely remove a host, including its history ?
Thanks.
No, we don't delete anything from output ever. We could implement some 'delete' function to output models, which will delete all files without node.
I don't find this important, but perhaps I'm missing something.
Ok, no problem.
It's not an important issue, but I just performed some recast on our network infrastructure, and I had to remove 3 switches, and I was just curious about how can I remove a host.
There's no hurry on this feature.
I even think we can close this ticket.
Thanks.
I think we should leave it open. I'd like to hear from other people who want this, so now they'd have place to chime in.
Also I'm curious how'd they think it should be implemented.
I think it makes sense in some circumstances to delete old data from the git repository, but perhaps it is best left to the users to manually remove it from the git repo? I'm not terribly familiar with git, but it seems like it should be fairly easy to delete files.
However, I could also see value in purging anything that's not "active", as in, the files aren't tied to actively backed up devices. Maybe there could be a config option to delete files upon device deletion, or just purging non-active files on the backup interval.
I think this would be a good feature to have. I think an option in config to specify whether to delete files with no host. That would give flexibility for both use cases.
I think it would be great to also update the remote gitrepo at the same time. The feature of setting a preservation time for an old configuration would be best, ie if the device has not be contactable in 180 days, remove the configuration from the local git repo and remove it from the remote git repo. I wonder if there is any interest in removing the local repo and just having it sync with the remote repo.... seems like some duplication maybe?
I don't think we should ever remove data for boxes that we still know about, that does not make sense to me. If device is gone (router.db/sql/http) then we could delete it optionally.
However right now we don't really necessary know that node is gone, we'd only know if you do /reload, if you restart and list changed, we won't know device was removed.
Almost since the day1, I've known that the core of Oxidized isn't particularly well thought out, right now we carry the nodes and their state in memory. I've planned to change this so that state lives in sqlite table. This would fix several of our issues (memory use, statistics persistence, scalability) and it would also help addressing this. Because then we'd have persistent knowledge of what our nodes are and what are nodes reported by backend system, so even after restart, we'd know if backend disagrees with our previous view, and we could trigger 'delete' behaviour in the output systems Output#delete(node) or such.
Having said that, I'm not actively looking for opportunity to rewrite the core to keep state in disk, it would probably be like 30-50h work, not too bad.
In the interim, what you could do is
a) fetch from API list of nodes oxidized knows about
b) iterate backup directory for each file
c) if file exists in a+b, continue, if not delete from backup directory
Essentially like 5 lines script.
Hi.
Here how I do (I use the git backend) directly on the oxidized server :
- Stop Oxidized (optional, but as the operation takes few seconds...).
- Clone the repo in a temporary folder :
cd /tmp; git clone /data/oxidized/oxidized-configs.git - Suppress what you want.
- commit and push.
- Start Oxidized.
- You can remove the temporary clone if you can.
In my case, I have a hook to push to a remote repository, so on the next change, Oxidized pushes it to the remote repository.
It's a bit dirty, but it suits me for now.
As a good solution, I think it would be a big hassle to automate it completely because of the different source backend used. And it's kind of risky.
But it could be included during the reload nodes process with a flag in the config file to prevent removing if we don't want.
After receving the new node list, if a config file isn't tied to a node in the list, it should be either moved to a "garbage" folder or simply removed.
The flag/variable in the config file could looks like this :
autopurge: false|true|garbage
- False : Do not try to remove.
- True : Remove without asking.
- Garbage : Move to a garbage folder.
The only output backend I see as an issue in this case is the HTTP backend, but here, I don't have any idea :D.
Thanks.
Also would like an option to remove the files. They will remain in the git history anyways.
This is an older item - but I figure I would chime in.
We have a saying here - 'Failure at the speed of automation'.
I am personally not a fan of things being 'too smart' when it comes to deleting things.
With a source of SQL , and a basic boolean in the table for enabled , I can easily update the oxidized nodelist to stop them from polling (a /reload after the table update).
I don't mind going into the git repo via gitlab or CLI directly when I have to purge things out. I have done this when I put devices in the wrong groups for example and using repo-per-group.
If oxidized expands into this area of auto-delete - the results of bugs and defects can be much more severe ("Where did my entire repo go?"). etc. etc.
just a thought.. Keep It Simple..
There's two different things here:
- Delete the config files, so they don't appear if you were to checkout the repo
- Purge the files entirely (as if they never existed in the first place)
Doing 2 is pretty scary, this is not something that git is really meant to do. You can do it, but it's probably not something that oxidized should really be doing automatically.
With 1, you'd only see the files if you were digging through the old history. That's much safer to do as well, as you can always recover the last state of the file via git.
#1805 and #1123 seem to be related here.
I know this is closed but I have a need to do this and have opened a topic on LibreNMS for doing it manually but, just to record my opinion...
My view on deleting the configurations of removed devices is it should be OK as everything's in a git repository so, if we want to find out about something that was removed a year or so ago, we can just check out an old branch. In my case, I want to remove old files as I have a script which checks through the backups to look for things like IP addresses actively referenced in the current configuration of devices so having old configurations for defunct devices lying about means these continue to be counted as "in use".
This issue is being tracked in #1805, please comment there.