Does anyone have an example already on how to create a custom node with Custom Properties and Pollers using C#? The example in SDK only shows query
Any help would be appreciated
All of the higher-level tasks in the API are just different inputs to the same basic operations (query, invoke, create, update, delete). I recommend you look at the PowerShell examples and then make equivalent calls to those basic operations from C#.
Also quick addition, we have a custom Poller for Cisco ASR's how do I add that to the router type? The poller is is just called "Cisco ASR Devices"
# CPU
$poller["PollerType"]="N.Cpu.SNMP.CiscoGen3";
$pollerUri = New-SwisObject $swis -EntityType "Orion.Pollers" -Properties $poller
# Memory
$poller["PollerType"]="N.Memory.SNMP.CiscoGen3";
So in reading through the example I see you have an Invoke for Alert but how do I know what the invoke is for example Adding a Node
JToken invokeResult = Invoke("Orion.Nodes", "CCCCC", new object[]
{
new[]
new
IPAddress = "4.4.4.8",
EngineID = 12,
ObjectSubType = "SNMP",
SNMPVersion = 2,
EntityType = "Orion.Nodes",
NodeName = "test.mycompany.com"
}
}).Result;
Console.WriteLine(invokeResult);
Those kinds of custom pollers are handled separately from these built-in pollers. See https://github.com/solarwinds/OrionSDK/wiki/NPM-Universal-Device-Pollers for how to assign those programmatically.
Adding a node is done using a "create" operation, not "invoke". The C# sample does not have a wrapper method for create, but it should be straightforward to make one given the request format, which is shown here: https://github.com/solarwinds/OrionSDK/wiki/REST#create-request.
I tried
JToken CreateResult = Create("Orion.Nodes", new object[]
NodeName = "test.mycompany.com",
Community = "public",
RwCommunity = "public",
DynamicIP = "false",
PollInterval = "120",
RediscoveryInterval = "30",
StatCollection = "30"
Console.WriteLine(CreateResult);
private static Task<JToken> Create(string entity, params object[] args)
return SwisCallAsync(client =>
var request = JToken.FromObject(args);
HttpContent content = new StringContent(request.ToString(), Encoding.UTF8, "application/json");
foreach (JObject item in args)
return client.PostAsync(string.Format("Create/", entity), content);
return null;
});
But get the following error
System.AggregateException: One or more errors occurred. ---> System.InvalidCastException: Unable to cast object of type '<>f__AnonymousType0`12[System.String,System.Int32,System.String,System.Int32,System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String][]' to type 'Newtonsoft.Json.Linq.JObject'.
at CSRestClient.Program.<>c__DisplayClass6_0.<Create>b__0(HttpClient client) in C:\Users\romartin\Downloads\OrionSDK-master\OrionSDK-master\Samples\CSharp\Program.cs:line 114
at CSRestClient.Program.<SwisCallAsync>d__7.MoveNext() in C:\Users\romartin\Downloads\OrionSDK-master\OrionSDK-master\Samples\CSharp\Program.cs:line 134
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at System.Threading.Tasks.Task`1.get_Result()
at CSRestClient.Program.Main(String[] args) in C:\Users\romartin\Downloads\OrionSDK-master\OrionSDK-master\Samples\CSharp\Program.cs:line 48
---> (Inner Exception #0) System.InvalidCastException: Unable to cast object of type '<>f__AnonymousType0`12[System.String,System.Int32,System.String,System.Int32,System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String][]' to type 'Newtonsoft.Json.Linq.JObject'.
at CSRestClient.Program.<SwisCallAsync>d__7.MoveNext() in C:\Users\romartin\Downloads\OrionSDK-master\OrionSDK-master\Samples\CSharp\Program.cs:line 134<---
I know you don't support custom code but any help would be gratefully appreciated