AdminTurnedDevOps / opsview-add-host

Add Windows server host via PowerShell and Linux via Python/Bash using Opsview REST-API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

opsview-add-host

Add Windows server host via PowerShell and Linux via Python/Bash using Opsview REST-API.

PowerShell:

The PowerShell script is based on the resources from http://damirkasper.blogspot.de/2011/04/opsview-and-adding-hosts-through-rest.html. The issue with the script provided there was that the .NET client/PowerShell set the expect header and only send the request headers before a POST of data. This allows the server to respond with errors/redirects/security violations prior to the client sending the request body. The client does not wait until it gets a response and just pushes out the body of the request, which results in a 417 expectation error on my apache 2.2 and requesting the auth token failed. I resolved by disabling the expect header via "ServicePoint.Expect100Continue" property.

Python:

Based on https://github.com/AAbouZaid/add-host-to-opsview

Bash:

Based on https://github.com/guerremdq/opsview-addhost-script

Requirements

You need a Host Group and a user/role with enough rights on this Host Group to add hosts to it. For determining the JSON-configuration-data-string I used the opsview_rest command on the opsview master.

Miscellaneous

  • Bypass Powershell Execution Policy and execute script like - powershell.exe -noprofile -executionpolicy bypass -file C:\Temp\opsview-add-host.ps1
  • All scripts try to autodetect hostname and IP for new Opsview host object

About

Add Windows server host via PowerShell and Linux via Python/Bash using Opsview REST-API.

License:GNU General Public License v3.0


Languages

Language:PowerShell 52.9%Language:Python 36.9%Language:Shell 10.2%