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

Adding node custom properties does not work.

$
0
0

Hi, I am adding node with a custom properties but when it adds a node it does not fill the custom property part. Here is my script:

 

# 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 = "fmorn1pp01.fglcorporate.net"

$username = Read-Host -Prompt 'Enter user name'

$password = Read-Host -AsSecureString 'Enter password'

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

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

 

 

$ip = Read-Host -Prompt 'Input your IP address'

$Name = Read-Host -Prompt 'Input your server name'

 

 

# node configuration properties

function Show-Menu

{

     cls

     Write-Host "================ Select site ================"

 

 

     Write-Host "1: Press '1' Markham Head Office."

     Write-Host "2: Press '2' Calgary Head Office."

     Write-Host "3: Press '3' Calgary IT Office."

     Write-Host "4: Press '4' Calgary Colo."

     Write-Host "5: Press '5' Mississauga Head Office."

     Write-Host "6: Press '6' Laval Head Office."

     Write-Host "7: Press '7' Calgary Head Office."

     Write-Host "8: Press '8' FGL AJB."

     Write-Host "9: Press '9' MARKS AJB."

     Write-Host "10: Press '10' FGL WDC."

     Write-Host "11: Press '11' MARKS WDC."

     Write-Host "Q: Press 'Q' to quit."   

 

 

}

 

 

 

$selection = Read-Host "Please make a selection"

switch ($selection)

{

           '1' {

                $Site = 'Markham Head Office'

                'You chose option #1'

           } '2' {

                $Site = 'Calgary Head Office'

                'You chose option #2'

           } '3' {

                $Site = 'Calgary IT Office'

                'You chose option #3'

           }'4' {

                $Site = 'Calgary Colo'

                'You chose option #4'

           } '5' {

                $Site = 'Mississauga Head Office'

                'You chose option #5'

           } '6' {

                $Site = 'Laval Head Office'

                'You chose option #6'

           }'7' {

                $Site = 'Calgary Head Office'

                'You chose option #7'

           } '8' {

                $Site = 'FGL AJB'

                'You chose option #8'

           } '9' {

                $Site = 'MARKS AJB'

                'You chose option #9'

           } '10' {

                $Site = 'FGL WDC'

                'You chose option #10'

           } '11' {

                $Site = 'MARKS WDC'

                'You chose option #11'

 

 

           } 'q' { exit

           }

    

 

 

}

 

 

 

Cls

Write-Host "================ Select class ================"

    

     Write-Host "1: Press '1' A."

     Write-Host "2: Press '2' B."

     Write-Host "3: Press '3' C."

     Write-Host "4: Press '4' D."

     Write-Host "Q: Press 'Q' to quit.

 

 

 

 

$selection = Read-Host "Please make a selection"

switch ($selection)

{

           '1' {

                $Class = 'A'

                'You chose option #1'

           } '2' {

                $Class = 'B'

                'You chose option #2'

           } '3' {

                $Class = 'C'

                'You chose option #3'

           }'4' {

                $Class = 'D'

                'You chose option #4'

           } 'q' { exit

               

           }

}

 

 

 

 

Cls

Write-Host "================ Select environment ================"

    

     Write-Host "1: Press '1' Prod."

     Write-Host "2: Press '2' Pre-prod."

     Write-Host "3: Press '3' DEV."

     Write-Host "4: Press '4' QA."

     Write-Host "Q: Press 'Q' to quit.

 

 

 

   $selection = Read-Host "Please make a selection"

switch ($selection)

     {

           '1' {

                $Environment = 'Prod'

                'You chose option #1'

           } '2' {

                $Environment = 'Pre-prod'

                'You chose option #2'

           } '3' {

                $Environment = 'DEV'

                'You chose option #3'

           }'4' {

                $Environment = 'QA'

                'You chose option #4'

           } 'q' {

                exit

           }

     }

 

 

 

 

CLS

 

 

Write-Host "================ Select city ================"

    

     Write-Host "1: Press '1' Calgary."

     Write-Host "2: Press '2' Brampton."

     Write-Host "3: Press '3' Markham."

     Write-Host "4: Press '4' Mississauga."

     Write-Host "5: Press '5' Laval."

     Write-Host "6: Press '6' WDC."

     Write-Host "Q: Press 'Q' to quit."

 

 

    

 

   $selection = Read-Host "Please make a selection"

switch ($selection)

     {

           '1' {

                $City = 'Calgary'

                'You chose option #1'

           } '2' {

                $City = 'Brampton'

                'You chose option #2'

           } '3' {

                $City = 'Markham'

                'You chose option #3'

           }'4' {

                $City = 'Mississauga'

                'You chose option #4'

           } '5' {

                $City = 'Laval'

                'You chose option #5'

           }'6' {

                $City = 'WDC'

                'You chose option #6'

           } 'q' {

                exit

           }

     }

 

 

 

 

# add a node

$newNodeProps = @{

    IPAddress = $ip;

    NodeName = $Name

    EngineID = 17;

 

    # SNMP v2 specific

    ObjectSubType = "SNMP";

 

 

    SNMPVersion = 2;

 

 

    DNS = "$Name";

    SysName = "$Name";

   

    # === 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"];

}

 

 

# prepare a custom property value

 

 

$customProps = @{

 

 

 

    CITY = "$City";

 

 

    CLASS_TYPE = "$Class";

 

 

    DEPARTMENT = "Infrastructure";

 

 

    DEVICE = "Server";

 

 

    OS_TYPE = "Windows";

 

 

    SITE = "$Site";

 

 

    VIRTUAL_SERVER = "Yes";

 

 

}

 

 

# build the node URI

$uri = "swis://fmorn1pp01/Orion/Orion.Nodes/NodeID=$($nodeProps.NodeID)/CustomProperties";

 

 

# set the custom property

Set-SwisObject $swis -Uri $uri -Properties $customProps

 

 

# 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.HrProcessorLoad";

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

 

 

# Network

$poller["PollerType"]="N.Topology_Layer3.SNMP.ipNetToMedia";

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

 

 

# Storage_Memory

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

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


Viewing all articles
Browse latest Browse all 2677

Trending Articles



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