Page 1 of 1

Decommissioning Automation

Posted: Fri Sep 24, 2021 4:59 am
by danniiffxi
Hi Guys,

I was just wondering if anyone has had any experience with using PowerShell on CentOS7 for removal of Nagios entries? We are currently in the early stages of automating our decommissioning process, part of which is removing the server in question from Nagios XI.

I already use a series of custom PowerShell scripts to create the Nagios cfg files when adding new servers & services from a .csv on a Windows machine, I then SCP the files to appropriate folders on the nagios server are run /usr/local/nagiosxi/scripts/reconfigure_nagios.sh, so I can add hundreds of servers to Nagios in a matter of mins.

But now I want to be able to remove entries using purely PowerShell which is slightly more challenging as it will require the script to SSH to the Nagios server, remove entries from the 'hostgroup.cfg' where when adding it imply appends the exiting file, unless I stick with removing hostgroups manually and just go for removal of 'servername'.cfg and then run /usr/local/nagiosxi/scripts/reconfigure_nagios.sh.

Any suggestions?

Re: Decommissioning Automation

Posted: Fri Sep 24, 2021 4:30 pm
by benjaminsmith
Hi,

Full disclosure, you are much better at Powershell than I am :) . However, we have team members who are pretty good with it and I can consult them.

That said, I would recommend using the REST API as you can communicate over HTTP, and it won't being necessary to login with SSH and move files around.

Log into Nagios XI and go to Help > API Docs and review the commands in Config Reference, that's the best way to add/remove hosts or services programmatically.

Are you currently updating the cfg files directly in the static directory?

--Benjamin