Test Server Clear all Host and Services
Test Server Clear all Host and Services
I have a test server that over time has accumulated items that are no longer present. What is the best method to wipe everything out so I can start new without completely re-installing Nagios XI?
Re: Test Server Clear all Host and Services
This should do the trick -
I believe this was fixed in recent versions, so depending what version the test server is on you may need to upgrade. (or pull the script from the latest)
Code: Select all
cd /usr/local/nagiosxi/scripts/
./restore_defaults.sh
Former Nagios Employee
-
SteveBeauchemin
- Posts: 524
- Joined: Mon Oct 14, 2013 7:19 pm
Re: Test Server Clear all Host and Services
Just read this post and read the shell file contents.
I immediately changed some system settings.
Do not even accidentally run this
I also edited the file and put the 2nd line to be the single word "exit"
You folks are a little too trusting for me.
Steve B
I immediately changed some system settings.
Do not even accidentally run this
Code: Select all
chmod 640 /usr/local/nagiosxi/scripts/restore_defaults.shCode: Select all
vi restore_defaults.sh
#!/bin/bash
exit
# to use this script, uncomment the exit above - this is DANGEROUS
Steve B
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
-
dwhitfield
- Former Nagios Staff
- Posts: 4583
- Joined: Wed Sep 21, 2016 10:29 am
- Location: NoLo, Minneapolis, MN
- Contact:
Re: Test Server Clear all Host and Services
@jkinning, I assume danger is averted due to this being a test box. Are we ready to lock this up?
@SteveBeauchemin, I definitely see your point, though I don't think we want to make it hard for people. I can put in a feature request if you like.
@SteveBeauchemin, I definitely see your point, though I don't think we want to make it hard for people. I can put in a feature request if you like.
-
SteveBeauchemin
- Posts: 524
- Joined: Mon Oct 14, 2013 7:19 pm
Re: Test Server Clear all Host and Services
No need to change anything. What I typically do for shell scripts to make then just a little harder to 'accidentally' run, it to change the permissions to 640. then, you can still run it if you want by putting sh in front of it.
This will run if I type
but will not run as
Safe enough for me. I'm just hoping no one else learns the hard way.
Thanks
Steve B
Code: Select all
-rw-r----- 1 nagios nagios 841 Feb 15 15:20 restore_defaults.shCode: Select all
sh restore_defaults.shCode: Select all
/usr/local/nagiosxi/scripts/restore_defaults.sh
or
./restore_defaults.shThanks
Steve B
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
-
dwhitfield
- Former Nagios Staff
- Posts: 4583
- Joined: Wed Sep 21, 2016 10:29 am
- Location: NoLo, Minneapolis, MN
- Contact:
Re: Test Server Clear all Host and Services
Fair enough. We'll wait on the OP to lock.
Re: Test Server Clear all Host and Services
Fair point. Some scripts have sanity checking built in to confirm they meant to run them. I've added a BR for this, to have simple logic added to 'confirm' -SteveBeauchemin wrote:No need to change anything. What I typically do for shell scripts to make then just a little harder to 'accidentally' run, it to change the permissions to 640. then, you can still run it if you want by putting sh in front of it.
This will run if I typeCode: Select all
-rw-r----- 1 nagios nagios 841 Feb 15 15:20 restore_defaults.shbut will not run asCode: Select all
sh restore_defaults.shSafe enough for me. I'm just hoping no one else learns the hard way.Code: Select all
/usr/local/nagiosxi/scripts/restore_defaults.sh or ./restore_defaults.sh
Thanks
Steve B
Code: Select all
NEW TASK ID 11065 created - Nagios XI Bug Report: Add sanity checking to restore_defaults.sh
Former Nagios Employee
Re: Test Server Clear all Host and Services
Yes, you can lock this one up.
Thanks!
Thanks!