Ejemplo n.º 1
0
        private static JToken GetOneAlert(ISwisClient swisClient)
        {
            const string query = @"SELECT TOP 1 AlertDefID, ActiveObject, ObjectType 
FROM Orion.AlertStatus
WHERE Acknowledged=0
ORDER BY TriggerTimeStamp DESC";

            JToken queryResult = swisClient.QueryAsync(query).Result;

            Console.WriteLine(queryResult);

            var alert = queryResult["results"][0];

            return(alert);
        }
Ejemplo n.º 2
0
        private static int GetOneAlert(ISwisClient swisClient)
        {
            const string query = @"SELECT TOP 1 AlertObjectID
FROM Orion.AlertActive
WHERE ISNULL(Acknowledged,0)!=1
ORDER BY TriggeredDateTime DESC";

            JToken queryResult = swisClient.QueryAsync(query).Result;

            Console.WriteLine(queryResult);

            var alertObjectId = (int)queryResult["results"][0]["AlertObjectID"];

            return(alertObjectId);
        }
Ejemplo n.º 3
0
        private static async Task <string> AddNode(ISwisClient swisClient)
        {
            string nodeUri = await swisClient.CreateAsync("Orion.Nodes",
                                                          new
            {
                IPAddress     = "10.199.4.3",
                EngineID      = 1,
                ObjectSubType = "SNMP",
                SNMPVersion   = 2,
                Community     = "public"
            });

            JObject node = await swisClient.ReadAsync(nodeUri);

            int nodeId = (int)node["NodeID"];

            string[] pollerTypes =
            {
                "N.Status.ICMP.Native",
                "N.ResponseTime.ICMP.Native",
                "N.Details.SNMP.Generic",
                "N.Uptime.SNMP.Generic",
                "N.Cpu.SNMP.CiscoGen3",
                "N.Memory.SNMP.CiscoGen3",
                "N.HardwareHealthMonitoring.SNMP.NPM.Cisco"
            };

            foreach (string pollerType in pollerTypes)
            {
                await swisClient.CreateAsync("Orion.Pollers", new
                {
                    NetObject     = "N:" + nodeId,
                    NetObjectType = "N",
                    NetObjectID   = nodeId,
                    PollerType    = pollerType
                });
            }

            await swisClient.CreateAsync("Orion.NodeSettings", new
            {
                NodeID       = nodeId,
                SettingName  = "NeedsInventory",
                SettingValue = "HWH"
            });

            return(nodeUri);
        }
Ejemplo n.º 4
0
        private static JToken AcknowledgeAlert(ISwisClient swisClient, JToken alert)
        {
            JToken invokeResult = swisClient.InvokeAsync("Orion.AlertStatus", "Acknowledge", new object[]
            {
                new[]
                {
                    new
                    {
                        DefinitionId = alert["AlertDefID"],
                        ObjectType   = alert["ObjectType"],
                        ObjectId     = alert["ActiveObject"]
                    }
                }
            }).Result;

            return(invokeResult);
        }
Ejemplo n.º 5
0
        private static JToken AcknowledgeAlert(ISwisClient swisClient, int alertObjectId, string note)
        {
            JToken invokeResult = swisClient.InvokeAsync("Orion.AlertActive", "Acknowledge", new[] { alertObjectId }, note).Result;

            return(invokeResult);
        }