4 Replies Latest reply on Feb 6, 2013 11:39 AM by Leon Adato

    modifying custom properties using swisinvoke.exe?

    RichT

      Could anyone suggest a code snippet for modifying custom properties using the command line swisinvoke.exe?

       

      I'd like to try launching this as an external program from a SNMP/Syslog Trap rule action and pass the Node ID, Custom Property Name and Custom Property Value as arguments.

       

      If this doesn't sound feasible, could anyone offer a script to do this by some other method?

       

      Thanks in advance.

        • Re: modifying custom properties using swisinvoke.exe?
          tom.rybka

          You can use a generic Update operation for changing a value of a specific node's custom property. There is a sample PowerShell script in the SDK showing its use for setting custom properties. See the most important fragment from the sample below:

           

          $hostname = "localhost"

           

          # NodeID of a node which custom properties you want to change

          $nodeId=1

           

          # prepare a custom property value

          $customProps = @{ Comments="Custom comment"; }

           

          # build the node URI

          $uri = "swis://$hostname/Orion/Orion.Nodes/NodeID=$nodeId/CustomProperties";

          # set the custom property

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

            • Re: modifying custom properties using swisinvoke.exe?
              Leon Adato

              Any thoughts on how this would be done in Perl?

                • Re: modifying custom properties using swisinvoke.exe?
                  tdanner

                  The SOAP equivalent to Set-SwisObject is Update. So the perl call would look like this:

                   

                  $swis->Update('swis://localhost/Orion/Orion.Nodes/NodeID=1/CustomProperties', {'Comments'=>'Custom comment'});

                    • Re: modifying custom properties using swisinvoke.exe?
                      Leon Adato

                      Interestingly enough, I hacked at it and got it working, but my code looks like this:

                       

                      $swis->Update('swis://TheOrionServerGoesHere/Orion/Orion.Nodes/NodeID=NodeIDGoesHere', {'MyCustomProperty'=>'NewValueGoesHere'});


                      I tried it with the addition of "/CustomProperties" and that worked also. SO:

                       

                      $swis->Update('swis://TheOrionServerGoesHere/Orion/Orion.Nodes/NodeID=NodeIDGoesHere/CustomProperties', {'MyCustomProperty'=>'NewValueGoesHere'});


                      ...and for future generations, if you are using variables you have to concatenate them thusly:


                      $orionserver = "thewatchmen";

                      $nodeid = 3;

                      $PropToChange = "ManagersDogsName";

                      $NewValue = "Fido";
                      $swis->Update('swis://'.$orionserver.'/Orion/Orion.Nodes/NodeID='.$nodeid, {$PropToChange=>$NewValue});


                      (or with the CustomProperties)

                      $swis->Update('swis://'.$orionserver.'/Orion/Orion.Nodes/NodeID='.$nodeid.'/CustomProperties/', {$PropToChange=>$NewValue});


                      But thanks a ton!

                      - Leon