cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post

Standardisation of Variables Across All Products

Standardisation of Variables Across All Products

Hello,

This is something that has caught me out quite a few times.  For example sometimes NodeName will be ${NodeName} then othertimes it will be ${Node.NodeName} etc.  It would be nice to have these standardised across all products and also available for use in scripts and other templates (eg Powershell only supports ${IP} and ${CREDENTIAL})

I was wanting to pass ${Community} ${AgentPort} among others for creating a Powershell OID monitor to translate textual values to numerical so that Warning/Critical alerts can be setup based on numerical value.

Thanks,

Peter

16 Comments
Level 9

Indeed, having more macro acessible from argument woule be nice:

${ApplicationID}

${ComponentID}

${ApplicationTemplateID}

All script : Perl, vbscript or powershell...

Product Manager
Product Manager

The following additional macros are now available in the SAM 6.0 RC (available now)

  • ${USER}
  • ${PASSWORD}
  • ${PORT}
  • ${Node.SysName}
  • ${Node.Caption}
  • ${Node.DNS}
  • ${Node.ID}
  • ${Component.ID}
  • ${Component.Name}
  • ${Application.Id}
  • ${Application.Name}
  • ${Application.TemplateId
  • ${Threshold.Warning}
  • ${Threshold.Critical}
  • Node Custom Property Macros ${Node.CustomPropertyName}
  • Application Custom Property Macros ${Application.CustomPropertyName}

Hi Alterego

Display Component (StatisticData) Value on NetWorkAtlas would be great,if this feature is released  can be compared with CA Nimbus.

Product Manager
Product Manager

Allowing for additional SAM specific macros to be used in Network Atlas mouse hover tool tips is a feature request I'm tracking internally under FB255197.

That´s great...

Level 8

Complaint of the day: cannot use file age monitor on folder named 2014_04, because next month that will not be valid. Duh.

So \\${IP}\share\${Year}_${MM} should work for \\10.0.0.1\share\2014_04

I had this problem many times when trying to replicate resource filters between NPM and EOC views. As the variable names are different (and don't get me started about the lack of 'remember expanded state' options on key resources in EOC!) it meant that every change took twice as long to research and implement. +1 vote for this

Level 9

FWIW .. I just tested these macros .. ${USER} works and ${IP} always worked .. however ${PASSWORD} clearly does NOT work at

I can code other ways around this not working .. however I think the documentation should be fixed to reflect this .. BTW I tested on SAM 6.22

Level 9

To further build on this ... the original request/post was to get the community string for a device .. and that's exactly what I needed also.

Using the ${Node.ID} .. and the Orion Powershell SDK.. you can get the community string .. here's the code for my SAM Powershell template .. (BTW I put username/pass in CSV file)

Add-PSSnapin SwisSnapin

$credFile = Import-Csv "SwisAPI.csv"

$swis = Connect-Swis -host usatl-s-solwdb1 -UserName $credFile.Username -Password $credFile.Password

$curNode = Get-SwisObject $swis -Uri "swis://localhost/Orion/Orion.Nodes/NodeID=${Node.ID}"

$perlCommand = "/bin/perl netapp-scripts/checkNetAppFiler.pl " + $curNode.Community + " ${IP}"

c:\cygwin64\bin\bash.exe -lc "$perlCommand"

The

$curNode.Community

is the Community string configured for the device.

Level 10

gtalton,

I ran into this issue just recently and I needed to pass creds to Powershell in order to interact with our own product's API. Then I finally found that the PowerShell Monitor only really provides the ${CREDENTIAL} object to be used with the PowerShell "Get-Credential" cmdlet. If your use-case will allow you to pass the -credential, then you can simply enter the command like this: -credential ${CREDENTIAL}   If you do this, whatever credential you selected for the component, will get passed through.

However, in my case, our API would only allow user, domain & password to be passed in individual variables within the API call.  So, after a little digging on thwack, I found this function that engineering provided that allowed me to get the secure password out of the credential object.  This is an example of the code I used to extract the user, domain & password.  It also contains the parsing to separate the domain from the username if they exist in the credential:

---------------------------------------------------------

#Solarwinds Function to Get-Credential from Powershell and extract the password securely.

Function SecureStringToString($value)

{

    [System.IntPtr] $bstr = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($value);

    try

    {

        [System.Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr);

    }

    finally

    {

        [System.Runtime.InteropServices.Marshal]::FreeBSTR($bstr);

    }

};

#Username and Password Extraction

$c = Get-Credential -credential ${CREDENTIAL};  #The ${CREDENTIAL} object is credentials passed from Solarwinds in the form of a PowerShell Get-Credential Object.

[string] $username = $c.Username;

[string] $password = SecureStringToString $c.Password; #Leverages the Solarwinds provided function "SecureStringToString" to parse our the password from the Get-Credential Object.

#Extract Username and Domain from combined windows credential.

if ($username -like "*\*") { # This if statement checks the $username variable for a backslash, if it exists parses the domain from the username into two separate variables.

$domain = $username -replace "\\.*","";

$user = $username -replace ".*\\","";

}

elseif ($username -like "*@*") { # This if statement checks the $username variable for an @ symbol, if it exists parses the domain from the username into two separate variables.

$domain = $username -replace ".*@","";

$user = $username -replace "@.*","";

}

else

{ # If neither of the two above are true, domain is set to null and $user is assigned $username.

$domain = "";

$user = $username;

}

# Set Connection Credentials

$vltConn.userName = $user;

$vltConn.Domain = $domain;

$vltConn.Password = $password;

----------------------------------------------------------

Hope this helps!