Solarwinds - Unmanage

Octopus.Script exported 2014-05-16 by bobjwalker belongs to ‘SolarWinds’ category.

Stop monitoring for a Solarwinds node, application or both

Parameters

When steps based on the template are included in a project’s deployment process, the parameters below can be set.

Host

Host

IP or DNS of the Solarwinds monitoring server

Node ID

NodeId

Solarwinds ID of machine to be unmonitored. Starts with ‘N:’.

Application ID

ApplicationId

Solarwinds ID of application to be unmonitored. Starts with ‘AA:’.

Re-manage after (minutes)

RemanageMinutes

Automatically begins monitoring of a node after given minutes.

Username

Username

Username for the Solarwinds console user.

Password

Password

Password for the Solarwinds console user

Script body

Steps based on this template will execute the following PowerShell script.

[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}

$solarwindsHost =  $OctopusParameters['Host']
$node =  $OctopusParameters['NodeId']
$application =  $OctopusParameters['ApplicationId']
$timeout = [int] $OctopusParameters['RemanageMinutes']
$username =  $OctopusParameters['Username']
$password =  $OctopusParameters['Password']

if ($node -ne "")
{
    Write-Host "Stopping Solarwinds monitoring for node $node"

    $success = $false
    try
    {
        $now = (Get-Date).ToUniversalTime().AddSeconds(5);
        $remanage = $now.AddMinutes($timeout);
        $nowString = $now.ToString("yyyy-MM-ddTHH:mm:ssZ")
        $remanageString = $remanage.ToString("yyyy-MM-ddTHH:mm:ssZ")
        $body = "[""$node"", ""$nowString"", ""$remanageString"", ""false""]"
        $header = @{}
        $header.Add("Authorization", "Basic "+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($username+":"+$password)))
        $uri = "https://" + $solarwindsHost + ":17778/SolarWinds/InformationService/v3/Json/Invoke/Orion.Nodes/Unmanage"

        Write-Host "Sending request $body to $uri"

        $response = Invoke-WebRequest -Uri $uri -Method Post -Body $body -Headers $header -ContentType "application/json" -UseBasicParsing

        if ($response.StatusCode -eq 200)
        {
            $success = $true
        }
    }
    catch
    {
        Write-Host "Something went wrong:"
        Write-Host $_.Exception
    }

    if (!$success)
    {
        throw "Unmanaging node failed."
    }

    Write-Host "Unmanaged node $node. Will automatically remanage at $remanage.ToString()"
}

if ($application -ne "")
{
    Write-Host "Stopping Solarwinds monitoring for application $application"

    $success = $false
    try
    {
        $now = (Get-Date).ToUniversalTime().AddSeconds(5);
        $remanage = $now.AddMinutes($timeout);
        $nowString = $now.ToString("yyyy-MM-ddTHH:mm:ssZ")
        $remanageString = $remanage.ToString("yyyy-MM-ddTHH:mm:ssZ")
        $body = "[""$application"", ""$nowString"", ""$remanageString"", ""false""]"
        $header = @{}
        $header.Add("Authorization", "Basic "+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($username+":"+$password)))
        $uri = "https://" + $solarwindsHost + ":17778/SolarWinds/InformationService/v3/Json/Invoke/Orion.APM.Application/Unmanage"

        Write-Host "Sending request $body to $uri"

        $response = Invoke-WebRequest -Uri $uri -Method Post -Body $body -Headers $header -ContentType "application/json" -UseBasicParsing

        if ($response.StatusCode -eq 200)
        {
            $success = $true
        }
    }
    catch
    {
        Write-Host "Something went wrong:"
        Write-Host $_.Exception
    }

    if (!$success)
    {
        throw "Unmanaging application failed."
    }

    Write-Host "Unmanaged application $application. Will automatically remanage at $remanage.ToString()"
}

Provided under the Apache License version 2.0.

Report an issue

To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.

{
  "Id": "8da75dc4-f430-4c52-ac50-b37629445ff5",
  "Name": "Solarwinds - Unmanage",
  "Description": "Stop monitoring for a Solarwinds node, application or both",
  "Version": 3,
  "ExportedAt": "2014-05-16T10:24:13.698+00:00",
  "ActionType": "Octopus.Script",
  "Author": "bobjwalker",
  "Parameters": [
    {
      "Name": "Host",
      "Label": "Host",
      "HelpText": "IP or DNS of the Solarwinds monitoring server",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "NodeId",
      "Label": "Node ID",
      "HelpText": "Solarwinds ID of machine to be unmonitored. Starts with 'N:'.",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "ApplicationId",
      "Label": "Application ID",
      "HelpText": "Solarwinds ID of application to be unmonitored. Starts with 'AA:'.",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "RemanageMinutes",
      "Label": "Re-manage after (minutes)",
      "HelpText": "Automatically begins monitoring of a node after given minutes.",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "Username",
      "Label": "Username",
      "HelpText": "Username for the Solarwinds console user.",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "Password",
      "Label": "Password",
      "HelpText": "Password for the Solarwinds console user",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    }
  ],
  "Properties": {
    "Octopus.Action.Script.ScriptBody": "[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}\n\n$solarwindsHost =  $OctopusParameters['Host']\n$node =  $OctopusParameters['NodeId']\n$application =  $OctopusParameters['ApplicationId']\n$timeout = [int] $OctopusParameters['RemanageMinutes']\n$username =  $OctopusParameters['Username']\n$password =  $OctopusParameters['Password']\n\nif ($node -ne \"\")\n{\n    Write-Host \"Stopping Solarwinds monitoring for node $node\"\n\n    $success = $false\n    try\n    {\n        $now = (Get-Date).ToUniversalTime().AddSeconds(5);\n        $remanage = $now.AddMinutes($timeout);\n        $nowString = $now.ToString(\"yyyy-MM-ddTHH:mm:ssZ\")\n        $remanageString = $remanage.ToString(\"yyyy-MM-ddTHH:mm:ssZ\")\n        $body = \"[\"\"$node\"\", \"\"$nowString\"\", \"\"$remanageString\"\", \"\"false\"\"]\"\n        $header = @{}\n        $header.Add(\"Authorization\", \"Basic \"+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($username+\":\"+$password)))\n        $uri = \"https://\" + $solarwindsHost + \":17778/SolarWinds/InformationService/v3/Json/Invoke/Orion.Nodes/Unmanage\"\n\n        Write-Host \"Sending request $body to $uri\"\n\n        $response = Invoke-WebRequest -Uri $uri -Method Post -Body $body -Headers $header -ContentType \"application/json\" -UseBasicParsing\n\n        if ($response.StatusCode -eq 200)\n        {\n            $success = $true\n        }\n    }\n    catch\n    {\n        Write-Host \"Something went wrong:\"\n        Write-Host $_.Exception\n    }\n\n    if (!$success)\n    {\n        throw \"Unmanaging node failed.\"\n    }\n\n    Write-Host \"Unmanaged node $node. Will automatically remanage at $remanage.ToString()\"\n}\n\nif ($application -ne \"\")\n{\n    Write-Host \"Stopping Solarwinds monitoring for application $application\"\n\n    $success = $false\n    try\n    {\n        $now = (Get-Date).ToUniversalTime().AddSeconds(5);\n        $remanage = $now.AddMinutes($timeout);\n        $nowString = $now.ToString(\"yyyy-MM-ddTHH:mm:ssZ\")\n        $remanageString = $remanage.ToString(\"yyyy-MM-ddTHH:mm:ssZ\")\n        $body = \"[\"\"$application\"\", \"\"$nowString\"\", \"\"$remanageString\"\", \"\"false\"\"]\"\n        $header = @{}\n        $header.Add(\"Authorization\", \"Basic \"+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($username+\":\"+$password)))\n        $uri = \"https://\" + $solarwindsHost + \":17778/SolarWinds/InformationService/v3/Json/Invoke/Orion.APM.Application/Unmanage\"\n\n        Write-Host \"Sending request $body to $uri\"\n\n        $response = Invoke-WebRequest -Uri $uri -Method Post -Body $body -Headers $header -ContentType \"application/json\" -UseBasicParsing\n\n        if ($response.StatusCode -eq 200)\n        {\n            $success = $true\n        }\n    }\n    catch\n    {\n        Write-Host \"Something went wrong:\"\n        Write-Host $_.Exception\n    }\n\n    if (!$success)\n    {\n        throw \"Unmanaging application failed.\"\n    }\n\n    Write-Host \"Unmanaged application $application. Will automatically remanage at $remanage.ToString()\"\n}",
    "Octopus.Action.Script.Syntax": "PowerShell"
  },
  "Category": "SolarWinds",
  "HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/solarwinds-unmanage.json",
  "Website": "/step-templates/8da75dc4-f430-4c52-ac50-b37629445ff5",
  "Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADNQTFRF////+Z00//ny+aNB+8KA/ebM/vPm+7Zn/dqz/M6Z+q9a+qlN/u3Z+7x0/MiN/NSm/eC/hW0iIgAAA/tJREFUeNrsnOliqyAQRtkRcHv/p6017W0WFzQBB+53/tt6AgPMADIGAAAAAAAAAAAAAAAAAAAAAAAAgDtEU4mH15V4yEo8uKrBo/Wc19CzBsl5KF/DWD7hio8Ox2cMpZfSE6ObEbEa8uZhCfykWjvXWc/viZvczK9G7AOpxppxEuALyKjX0urvictCXQ/K8zVkG9MY4f6R4YpBptlwiPNoh6e/IEVuiaGTfAe/4zH24eWZrGOvaFTg+/itH1e7xZgKOZvC8ihWPdqmX+2RuYastg88EiWWxueh3/wZLDUL/ryCbbXr7W5Q5ZjUzeA5P+wxT+82wiBXpI8dP0SwE/woPnVjuMBzINN2LN3xTIxJZ4yQS4P3KRMEmU0j4chrVEaN7WXAexo8J0FUoRG13D8TG5k1EnlkDfFbv0riMeTWSBPnOuTW4DaBh7HZNVIUen8LZFlpquhVKcJcdBc0hxIVjFXT7DFWEeS8q6M5wlhHdLjPN4e+oDlskqTW6MHZnEOvTbpHKLTrstiEHMVE03SyAo0T9cSj69zMu1GJXOwV++ftxysP6qrN2o+WtMIg2IXoD61cupFdTft+GUL2NA4AvFkYsoTOkJ3vYFQa483csaN4oO9wqSsMhpHkUOoV+pbRZYxsFKlGRpuYBCz0cRZGfx8kck7ZmfCy/5i2TXdSYu/anUxBz6++07RBDcl7ZuvX/3sj1gWa6f3jRr4u0yCxuOEgu7WfcPUY10p0NRlXZEOchJkUPO0F2V2xYlnCNM7KwxnXBavjW6D4Xi8m/vZ4HhOuWskI2zVmoS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