Solarwinds - Manage

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

Start 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:’.

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']
$username =  $OctopusParameters['Username']
$password =  $OctopusParameters['Password']

Write-Host "Starting Solarwinds monitoring for node " + $node

if ($node -ne "")
{
    $success = $false
    try
    {
        $body = "[""$node""]"
        $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/Remanage"

        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 "Remanaging node failed."
    }

    Write-Host "Remanaged node $node."
}

if ($application -ne "")
{
    $success = $false
    try
    {
        $body = "[""$application""]"
        $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/Remanage"

        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 "Remanaging application failed."
    }

    Write-Host "Remanaged application $application."
}

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": "4e870b0d-0715-4b98-9fa3-48500f6a42e4",
  "Name": "Solarwinds - Manage",
  "Description": "Start monitoring for a Solarwinds node, application or both",
  "Version": 2,
  "ExportedAt": "2014-05-16T10:22:27.031+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": "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$username =  $OctopusParameters['Username']\n$password =  $OctopusParameters['Password']\n\nWrite-Host \"Starting Solarwinds monitoring for node \" + $node\n\nif ($node -ne \"\")\n{\n    $success = $false\n    try\n    {\n        $body = \"[\"\"$node\"\"]\"\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/Remanage\"\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 \"Remanaging node failed.\"\n    }\n\n    Write-Host \"Remanaged node $node.\"\n}\n\nif ($application -ne \"\")\n{\n    $success = $false\n    try\n    {\n        $body = \"[\"\"$application\"\"]\"\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/Remanage\"\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 \"Remanaging application failed.\"\n    }\n\n    Write-Host \"Remanaged application $application.\"\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-manage.json",
  "Website": "/step-templates/4e870b0d-0715-4b98-9fa3-48500f6a42e4",
  "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/3sj1gWa6f3jRr4u0yCxuOEgu7WfcPUY10p0NRlXZEOchJkUPO0F2V2xYlnCNM7KwxnXBavjW6D4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