Quantcast
Channel: THWACK: All Content - Orion SDK
Viewing all articles
Browse latest Browse all 2677

Powershell scripts to add a Node

$
0
0

I am using the following scripts but not successful to add a single Node. I am pretty much sure, i am doing something wrong.

 

# This sample script demonstrates how to add a new node using CRUD operations.

#

# Please update the hostname and credential setup to match your configuration, and

# information about the node you would like to add for monitoring.

 

# Connect to SWIS

$hostname = "localhost"

$username = "admin"

$password = New-Object System.Security.SecureString

$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $password

$swis = Connect-Swis -host $hostname -cred $cred

 

$ip = "10.0.0.1"

 

# add a node

$newNodeProps = @{

    IPAddress = $ip;

    EngineID = 1;

 

    # SNMP v2 specific

    ObjectSubType = "SNMP";

 

    SNMPVersion = 2;

 

    DNS = "";

    SysName = "";

   

    # === default values ===

 

    # EntityType = 'Orion.Nodes'

    # Caption = ''

    # DynamicIP = false

    # PollInterval = 120

    # RediscoveryInterval = 30

    # StatCollection = 10 

}

 

$newNodeUri = New-SwisObject $swis -EntityType "Orion.Nodes" -Properties $newNodeProps

$nodeProps = Get-SwisObject $swis -Uri $newNodeUri

 

# register specific pollers for the node

$poller = @{

    NetObject="N:"+$nodeProps["NodeID"];

    NetObjectType="N";

    NetObjectID=$nodeProps["NodeID"];

}

 

# Status

$poller["PollerType"]="N.Status.ICMP.Native";

$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

 

# Response time

$poller["PollerType"]="N.ResponseTime.ICMP.Native";

$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

 

# Details

$poller["PollerType"]="N.Details.SNMP.Generic";

$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

 

# Uptime

$poller["PollerType"]="N.Uptime.SNMP.Generic";

$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

 

# CPU

$poller["PollerType"]="N.Cpu.SNMP.CiscoGen3";

$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

 

# Memory

$poller["PollerType"]="N.Memory.SNMP.CiscoGen3";

$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller

 

I am getting the following error:

 

PS C:\Users\>

Connect-Swis : The term 'Connect-Swis' is not recognized as the name of a cmdlet, function, script file, or operable

program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

At line:1 char:9

+ $swis = Connect-Swis -host $hostname -cred $cred

+         ~~~~~~~~~~~~

    + CategoryInfo          : ObjectNotFound: (Connect-Swis:String) [], CommandNotFoundException

    + FullyQualifiedErrorId : CommandNotFoundException

 

It looks like i was not able to connect to SWIS. Could anyone please explain what i am doing wrong. Do i need to run first "Add-PSSnapin SwisSnapin"?

 

/MSarkar


Viewing all articles
Browse latest Browse all 2677

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>