API: Restoring to Last Good Configuration Snapshot
-
MrWoodward
- Posts: 66
- Joined: Fri Jan 06, 2017 1:58 pm
API: Restoring to Last Good Configuration Snapshot
Is there a way using the Nagios XI API to restore to the "last good" configuration snapshot?
I found this page in your documentation, but didn't see any reference to the API.
https://support.nagios.com/kb/article.php?id=407
I found this page in your documentation, but didn't see any reference to the API.
https://support.nagios.com/kb/article.php?id=407
Re: API: Restoring to Last Good Configuration Snapshot
Unfortunately, it is not possible to restore to a configuration snapshot via the REST API at this time. It would be a really cool feature. I am going to file an internal feature request for adding this functionality.
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
MrWoodward
- Posts: 66
- Joined: Fri Jan 06, 2017 1:58 pm
Re: API: Restoring to Last Good Configuration Snapshot
Are there other ways to restore a configuration snapshot from the command-line of a Nagios server?
I'm attempting to create a Python script that runs on the Nagios server which (when detecting a certain state) can rollback/restore to the last good configuration snapshot.
I'm attempting to create a Python script that runs on the Nagios server which (when detecting a certain state) can rollback/restore to the last good configuration snapshot.
Re: API: Restoring to Last Good Configuration Snapshot
You could look at /usr/local/nagiosxi/scripts/nagiosql_snapshot.sh:
The error about the snapshot not being found can be ignored.
Code: Select all
[root@localhost scripts]# pwd
/usr/local/nagiosxi/scripts
[root@localhost scripts]# bash nagiosql_snapshot.sh this_one_works
taking snapshot
Backup Complete.
[root@localhost scripts]# bash nagiosql_snapshot.sh this_one_works restore
Restoring NagiosQL snapshot
Removing old files from /usr/local/nagios/etc
NOM SNAPSHOT /usr/local/nagiosxi/nom/checkpoints/nagioscore/this_one_works.tar.gz NOT FOUND!
Restoring NagiosQL databases...
Restore Complete.
Former Nagios employee
-
MrWoodward
- Posts: 66
- Joined: Fri Jan 06, 2017 1:58 pm
Re: API: Restoring to Last Good Configuration Snapshot
Thanks for the help. I'll take a look and get back to you.
Cheers.
Cheers.
Re: API: Restoring to Last Good Configuration Snapshot
Sure. Let us know if this worked for you, so that we can lock the topic, and mark it as resolved. Thank you!
Be sure to check out our Knowledgebase for helpful articles and solutions!
-
MrWoodward
- Posts: 66
- Joined: Fri Jan 06, 2017 1:58 pm
Re: API: Restoring to Last Good Configuration Snapshot
The exact command appears to be:
and the checkpoints can be found in:
Code: Select all
sudo /usr/local/nagiosxi/scripts/nagiosql_snapshot.sh <some_number_here> restoreCode: Select all
/usr/local/nagiosxi/nom/checkpoints/nagiosxi
Last edited by MrWoodward on Tue Feb 20, 2018 12:23 pm, edited 1 time in total.
Re: API: Restoring to Last Good Configuration Snapshot
You are correct. I just tested the script. It seems like that you need to use a number only (timestamp portion), for example:
instead of the full file name (timestamp + _nagiosql.sql.gz at the end).
In addition to this, in order to complete the restore, you will need to run the reconfigure.sh script:
Code: Select all
/usr/local/nagiosxi/scripts/nagiosql_snapshot.sh 1518716128 restoreIn addition to this, in order to complete the restore, you will need to run the reconfigure.sh script:
Code: Select all
/usr/local/nagiosxi/scripts/reconfigure_nagios.shBe sure to check out our Knowledgebase for helpful articles and solutions!
-
MrWoodward
- Posts: 66
- Joined: Fri Jan 06, 2017 1:58 pm
Re: API: Restoring to Last Good Configuration Snapshot
Oh, that's good to know.
I've found so far that this must be run as `root` as well. I tried running it as `nagios` user, but that error'd out on me.
I've found so far that this must be run as `root` as well. I tried running it as `nagios` user, but that error'd out on me.
Re: API: Restoring to Last Good Configuration Snapshot
The issue may be caused by wrong permissions on some of the files/directories. I can run these commands as nagios user just fine.I've found so far that this must be run as `root` as well. I tried running it as `nagios` user, but that error'd out on me.
To start troubleshooting you can run:
Code: Select all
ls -la /usr/local/nagiosxi/nom/checkpoints
ls -la /usr/local/nagiosxi/nom/checkpoints/nagiosxi
ls -la /usr/local/nagiosxi/scripts
grep nag /etc/group
grep nagios /etc/passwd
chage nagios -lBe sure to check out our Knowledgebase for helpful articles and solutions!