Test server automation

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
jacek
Posts: 248
Joined: Wed Sep 09, 2015 5:49 am

Test server automation

Post by jacek »

Since our license allows to use an test server I would to run a following scenario:
  • Production server does an daily backup to its local storage
  • Backup server downloads the backups on a daily basis
  • Backup server applies the backup to itself after download
As this is an test server we would like to disable the monitoring engine and notifications before the services start (which happens automatically after the restore) so we don't get any notifications under any circumstances.
Obviously we don't want any mails from the test server as it would give a lot of false-positives in our current setup.
Also there are some settings like the IP in the web interface that require fixing after the restore (anything else?).
How can we script all the above? Most important would be to start with the engine and notifications disabling (I think at least).
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Test server automation

Post by benjaminsmith »

HI @jacek,

Glad you are setting up a test server! You should be able to script this out and you can use the Nagios External commands to disable checks or notification, they are really handy.

https://assets.nagios.com/downloads/nag ... ernalcmds/

You can also run these commands over the REST API as well. Go to Help > API Docs > System Reference > Core System for details and example commands.

Have a great weekend and let me know if you have more questions.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
jacek
Posts: 248
Joined: Wed Sep 09, 2015 5:49 am

Re: Test server automation

Post by jacek »

The question is which services/components should be disabled on a test server (licensing)?
Should I submit these commands immediately after the restore script?
Would this guarantee not getting any notifications or should I edit the recovery script and seet up the command somewhere in it?
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Test server automation

Post by ssax »

Technically after the restore you and it's up and running you can submit this to disable notifications:

https://assets.nagios.com/downloads/nag ... mmand_id=7

Or by using the API using the above core command:

Code: Select all

http://YOURXISERVER/nagiosxi/help/api-system-reference.php#system-core-command
But you could also make sure your /usr/local/nagios/var/retention.dat file has this set at the top:

program {
modified_host_attributes=0
modified_service_attributes=0
enable_notifications=0

Because when nagios starts up it reads that file (which should be restored from the other system which has it enabled).
jacek
Posts: 248
Joined: Wed Sep 09, 2015 5:49 am

Re: Test server automation

Post by jacek »

I managed to write an ugly script which:
  • blocks mails via iptables (blocking port 25)
  • runs the recovery script
  • stops nagios service, sets the enable_notifications parameter in retention.dat to 0, starts nagios service
  • sleeps 10s (time for the API/services to properly start)
  • verifies via API if the notifications are really disabled
  • runs the restore_repair script (source is CentOS 6, destination CentOS 7)
  • AGAIN - stops nagios service, sets the enable_notifications parameter in retention.dat to 0, starts nagios service
  • AGAIN - sleeps 10s (time for the API/services to properly start)
  • AGAIN - verifies via API if the notifications are really disabled
  • removes the iptables entry to unblock mails
Any questions? :lol:

How can I disable the SSH backups configured in XI via script or so? (I don't want the test server to backup itself anywhere).
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Test server automation

Post by cdienger »

If you want to disable the options under Admin > System Backups > Schedule Backups > SSH, you can run the following against the nagiosxi database:

Code: Select all

delete from xi_options where name="scheduled_ssh_backups";
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked