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.

Autodeploy LAN, add to NPM and NCM, and collect backup etc

Hi all

I´m trying to get a feel for the SDK, which has been on my to-do list for quite some time now, however my lack of sripting knowledge may prevent my success...

What i´m trying to achieve, is that based on a syslog event, where my switch has connected to our tftp store, and collected a given configiuration, i want to trigger a "add to solarwinds NPM and thus also NCM" event, modifying a few custom properties etc.

I started to play arround with the script yesterday, and at this point i have a script which (triggered maually) can add the switch to NPM, and set the custom properties i want.

(btw, im on NPM 10.3.1, and NCM 7.1)

What i can´t do is..:

  • Get my head arround the password (credentials) part of the script. It constantly prompts me to enter my credentials, which in the automated version won´t really be... automated
  • Parse the ip address from the syslog into the script, and use for IPAdderss="$IP" variable
  • Add to ncm as part of the add script (or add to ncm at all.. )
  • Figure out if i need to do anything with the "IPAddressGUID="0100000a-0000-0000-0000-000000000000"; statement ? (have no clue what this is....)

Nice to haves ( emoticons_happy.png ) whould be a way to also prevent duplicate nodes.. but for testing it´s acctually quite nice

I also would like to add interfaces IF some criterias are met, like must be Gig and / or Vlan interfaces, must be up etc

Trigger NCM inventory and "standarlization scripts" afterwards would be add-ons

I´m attaching the script as is - Hoping that someone will give me some guidance

AddNode.PS1

  • Got a bit further - My script now works - .... When execuded manually from the desktop.

    However, when i create a syslog alert action, and execute an external program:

    "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe D:\SWIS\AddNode.PS1 -IP ${IP}  it does not work.

    Even when executing the script from within same directory as powershell, or in the C: root directory - No joy.

    In the syslog service log, i see that the application can´t find the application / file:

    C:\ProgramData\Solarwinds\Logs\Orion\SyslogService.log

    2012-11-26 16:11:53,373 [11] WARN  All - On alert action Execute program : "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe D:\SWIS\AddNode.PS1 -IP" ${IP} the Alerting Engine service was unable to run the program "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe D:\SWIS\AddNode.PS1 -IP" ${IP}

    Error Detail - File not found.

    I know that the string is valid, as when i run it from a prompt it execute correctly, however i suspect that the problem may be related to either the parsing of the IP, parsing of the script file, or parsing of the PS parameter -IP

    It could also be a permissions issue, where the syslog application will not be permitted to execute the script at all.

    I tried to run the syslog service with my ad creds (admin, and admin also on the solarwinds installation - still no joy

    Does anyone have success with executing a PS script based on a syslog event - and if so : how ?

    Solarwinds in reading (hopefully) can you elaborate on the parameters needed in the syslog alert action to be able to run a script ?

    Attaching an updated version of the script

    Edit: Adding the script Message was edited by: Jesper Vestergaard

    AddNode.PS1

  • And now working as intended emoticons_happy.png

    The execute string in syslog event should be: "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" D:\SWIS\AddNode.PS1 -IP ${IP}

    The remaining issue is now how to add to NCM automatically.... Any ideas ?

    AddNode.PS1
  • Starting with NCM 7.0.2 you can add nodes to NCM programmatically using the Cirrus.Nodes.AddNodeToNCM verb. From PowerShell, it looks like this:

    Invoke-SwisVerb $swis Cirrus.Nodes AddNodeToNCM $nodeId

  • Hi Tim

    Could you elaborate on this ?

    I´m running NCM 7.1 and NPM 10.3.1 - But still get the error:

    PS D:\swis> .\AddNode.ps1 -ip 1.1.1.1

    Invoke-SwisVerb : Verb Cirrus.Nodes.AddNodeToNCM: Not found

    At D:\swis\AddNode.ps1:105 char:16

    + Invoke-SwisVerb <<<<  $swis Cirrus.Nodes AddNodeToNCM $nodeId

        + CategoryInfo          : InvalidOperation: (:) [Invoke-SwisVerb], FaultException`1

        + FullyQualifiedErrorId : SwisError,SwisPowerShell.InvokeSwisVerb

    PS D:\swis>

    after adding your suggested line in the bottom of my script. (After the Custom props update line)

    Do i need "more connection settings" or similar, to the NCM database ?

    / Jesper

  • I forgot: NCM still only supports SWISv2. Try this:

    $swisv2 = Connect-Swis -Credential $credentials -v2

    Invoke-SwisVerb $swisv2 Cirrus.Nodes AddNodeToNCM $nodeId

  • Hi

    I´m still getting the same error:

    PS D:\swis> .\AddNode.ps1 -IP 1.1.1.1

    Invoke-SwisVerb : Verb Cirrus.Nodes.AddNodeToNCM: Not found

    At D:\swis\AddNode.ps1:110 char:16

    + Invoke-SwisVerb <<<<  $swisv2 Cirrus.Nodes AddNodeToNCM $nodeId

        + CategoryInfo          : InvalidOperation: (:) [Invoke-SwisVerb], FaultException`1

        + FullyQualifiedErrorId : SwisError,SwisPowerShell.InvokeSwisVerb

    PS D:\swis>

    And the end of my script now shows:

    #### ADD NODE TO NCM ###

    # Initialize SWIS connection version 2 with  previous configured credentials
    $swisv2 = Connect-Swis -Credential $credentials -v2

    # Add to NCM for Configuration Management
    Invoke-SwisVerb $swisv2 Cirrus.Nodes AddNodeToNCM $nodeId

  • NPM and NCM are integrated, right? If you run SWQL Studio and connect to your server, do you see the Cirrus.* entries in the tree on the right?

  • Hi

    It is intergrated, but i don´t see any cirrus.* resources in SWQL studio ?!

  • I'm not sure what's going on here. By "integrated", you mean that you have the "CONFIGS" tab in the website, right? You can do the usual NCM operations from the same website where you can look at NPM data?

  • Yes, The config tab is in my normal website, and i believe that during install, i was prompted for standalone or intergrated mode. (selected intergrated)

    The NCM is on a seperate server,  in a seperate DB, however using the same db server as NPM

    I can also perform NCM operations from my normal NPM website.