This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

How to manage/unmanage and inspect SolarWinds nodes and vms from a linux command line

Hello there!

Our dev team has created this great tool for us to use on our Linux scripts to unmanaged and manage SolarWinds nodes on the command line.

I'm here sharing it with you guys:

Architecture

Configuration

This library/cli uses the following environment variables:

Env VariableDescription
SOLARWINDS_USERNAMEUsername of SolarWinds API user.
SOLARWINDS_PASSWORDPassword of SolarWinds API user.
SOLARWINDS_HOSTNAMEName of host where SolarWinds API is installed, e.g solarwinds.example.com
SOLARWINDS_PORTPort of SolarWinds API, default is 17778.

How to Install

$ npm install -g solarwinds

CLI Usage

  Usage: solarwinds [options] [command]     Commands:      node           Nodes monitored by SolarWinds.     vm             Virtual machines accessible by SolarWinds.     app-template   Application templates.     credential     Credentials.    Options:      -h, --help     output usage information     -V, --version  output the version number

Nodes

Nodes monitored by SolarWinds. NODE can be a node id or a hostname.

  Usage: solarwinds node [options] [command]     Commands:      list|ls                    lists all available nodes     inspect <NODE>             displays detailed information about a node     unmanage [options] <NODE>  Unmanages a node for a duration     remanage <NODE>            remanage node by id of hostname    Options:      -h, --help  output usage information

node create

  Usage: solarwinds node create [options]    Create a node    Options:      -h, --help           output usage information     --name <value>       Node name     --hostname <value>   Node host name for polling. Has to be resolvable by DNS     --community [value]  Community string (default '')     --ip <value>         IP addressnode list
  Usage: solarwinds node list|ls [options]    List all available nodes    Options:      --filter <value>  Filter output based on conditions provided     -h, --help        output usage information
Filtering

The filtering flag format is "key=value".

The currently supported filters are:

  • id
  • name
  • hostname
  • ip

node inspect

  Usage: solarwinds node inspect [options] <NODE>    Displays detailed information about a node    Options:      -h, --help  output usage information

node unmanage

  Usage: solarwinds node unmanage [options] <NODE>    Unmanage a node for a duration    Options:      -h, --help              output usage information     -d, --duration <value>  Duration, for example 15s, 30m, 3h or 1d

node remanage

  Usage: solarwinds node remanage [options] <NODE>    Remanage node by id of hostname    Options:      -h, --help  output usage information

node remove

  Usage: solarwinds node remove|rm [options] <NODE>    Remove node    Options:      -h, --help  output usage information 

Application Templates

style="margin-bottom:16px;color:rgb(36, 41, 46);font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';font-size:16px"

  • name
  • ip

vm inspect

  Usage: solarwinds vm inspect [options] <VM>    Display detailed information about a virtual machine    Options:    -h, --help  output usage information

Library Usage

This library by default uses the environment variables specified above that can be overwritten:

import SolarWinds from 'solarwinds'  const solarwinds = new SolarWinds('username', 'password', 'url') ... const nodes = await solarwinds.nodes.query()

Resources

Usage Example

The script bellow inspect the node and if the node exists then it unmanages the node

#!/bin/bash

# SolarWinds Unmanage Nodes #

#define variables

export SOLARWINDS_USERNAME="ExampleAPIUser"

export SOLARWINDS_PASSWORD="EXampleAPiUserP@ssw0rd"

export SOLARWINDS_HOSTNAME=Solarwinds.example.com

#######################

# Unmanage Node

#######################

# inspect

solarwinds node inspect `hostname` >\tmp\nodes.txt

# verify if node exist

if [ $? != 0 ]; then

   echo "Failed please verify  node" >>\tmp\nodes.txt

mail -a \tmp\nodes.txt -s "Script SolarWinds Node Unmanaged - `hostname`: failed " youremail@example.com

exit 1

fi

# unmanage node

solarwinds node unmanage --duration 1h `hostname`>>\tmp\nodes.txt

mail -a \tmp\nodes.txt -s "SolarWinds Node unmanaged- `hostname`: success" youremail@example.com </dev/null

#clean variables

unset SOLARWINDS_USERNAME

unset SOLARWINDS_PASSWORD

unset  SOLARWINDS_HOSTNAME

exit 0

The script bellow inspect the node and if the node exists then it remanages the node

#!/bin/bash

# SolarWinds remanage Nodes #

#define variables

export SOLARWINDS_USERNAME="ExampleAPIUser"

export SOLARWINDS_PASSWORD="EXampleAPiUserP@ssw0rd"

export SOLARWINDS_HOSTNAME=Solarwinds.example.com

####################################################################

# Remanage Node

####################################################################

# inspect

solarwinds node inspect `hostname` > /tmp/nodes.txt

# verify if node exist

if [ $? != 0 ]; then

   echo "Failed  Please verify node" >>/tmp/nodes.txt

mail -a /tmp/nodes.txt -s "SolarWinds Node not Remanaged- `hostname` " youremail@example.com

exit 1

fi

# Re Manage

solarwinds node remanage  `hostname` >> \tmp\nodes.txt

mail -a /tmp/nodes.txt -s "SolarWinds Node Remanaged- `hostname` failed " youremai@example.com

#clean variables

unset SOLARWINDS_USERNAME

unset SOLARWINDS_PASSWORD

unset  SOLARWINDS_HOSTNAME

exit 0

Disclaimer: