Пример #1
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        /// <param name="clusterName">Name of Hosting Cluster (KEY)</param>
        /// <param name="NodeIndex">Index of Node</param>
        /// <param name="interfaces">List of Network Interfaces</param>
        /// <param name="address">SNMP IP Address</param>
        /// <param name="community">SNMP Community</param>
        public IsilonNode(string clusterName, int NodeIndex, IsilonNetworkInterface[] interfaces, string address, string community)
        {
            string IPAddress      = "";
            string NodeName       = "Node" + NodeIndex.ToString();
            string IsilonNodeName = "";
            bool   ReadOnly       = false;
            string Type           = "";

            // Save Network Interface List (Ignore Interfaces without IP Addresses)
            for (int i = 0; i < interfaces.Length; i++)
            {
                if (interfaces[i].ip_addrs.Length != 0)
                {
                    NetworkInterfaceList.Add(interfaces[i]);
                    if (interfaces[i].status.ToLower() == "up")
                    {
                        if (!interfaces[i].name.ToLower().Contains("mgmt"))
                        {
                            IPAddress = interfaces[i].ip_addrs[0];
                        }
                    }
                }
            }

            if (IPAddress != "")
            {
                try
                {
                    // Get Node Status Info
                    List <Variable> nodeStatus = SNMP.WalkSNMP(SNMP.nodeStatus, IPAddress, 161, community);
                    if (nodeStatus.Count != 0)
                    {
                        IsilonNodeName = nodeStatus[SNMP_NODE_NAME].Data.ToString();
                        if (nodeStatus[SNMP_NODE_READONLY].Data.ToString() == "1")
                        {
                            ReadOnly = true;
                        }
                        if (nodeStatus[SNMP_NODE_TYPE].Data.ToString() == "1")
                        {
                            Type = "Accelerator";
                        }
                        else
                        {
                            Type = "Storage";
                        }
                    }
                }
                catch (Exception ex)
                {
                    Program.log.Error(ex.Message);
                }

                try
                {
                    // Get Interface Descriptions via SNMP
                    List <Variable> snmpInterfaceDescriptions = SNMP.WalkSNMP(SNMP.ifTable, IPAddress, 161, community);

                    foreach (IsilonNetworkInterface nif in NetworkInterfaceList)
                    {
                        foreach (Variable var in snmpInterfaceDescriptions)
                        {
                            // Get Description
                            string desc = var.Data.ToString().ToLower();
                            // Get OidSuffix by removing the Table OID
                            string suffix = var.Id.ToString().Replace(SNMP.ifTable.TrimStart('.') + ".", "");

                            // If name Matches then Store Suffix
                            if (nif.nic_name.ToLower() == desc)
                            {
                                nif.index = Convert.ToInt32(suffix);
                                break;
                            }
                        }
                        // Create Network Interface SCOM_Object
                        nif.CreateScomObject(clusterName, NodeName);
                    }
                }
                catch (Exception ex)
                {
                    Program.log.Error(ex.Message);
                }


                // Create Root Entity Class & Display Name Prop
                ManagementPackClass    mpc_Entity            = SCOM.GetManagementPackClass("System.Entity");
                ManagementPackProperty mpp_EntityDisplayName = mpc_Entity.PropertyCollection["DisplayName"];

                // Create Node Management Pack Class
                ManagementPackClass mpc_Node = SCOM.GetManagementPackClass("AP.Isilon.Node");
                // Create New NetworkInterface Object
                SCOM_Object = new CreatableEnterpriseManagementObject(SCOM.m_managementGroup, mpc_Node);

                // Display Name of Root Entity (KEY Property)
                SCOM_Object[mpp_EntityDisplayName].Value = NodeName;

                // Create Isilon Cluster Class & Name Prop
                ManagementPackClass    mpc_Cluster     = SCOM.GetManagementPackClass("AP.Isilon.Cluster");
                ManagementPackProperty mpp_ClusterName = mpc_Cluster.PropertyCollection["Name"];
                // Set parent Cluster Property
                SCOM_Object[mpp_ClusterName].Value = clusterName;

                // Now Create Properties for this node
                // Name Property (KEY Property)
                ManagementPackProperty mpp_NodeName = mpc_Node.PropertyCollection["Name"];
                SCOM_Object[mpp_NodeName].Value = NodeName;
                // Index
                ManagementPackProperty mpp_NodeIndex = mpc_Node.PropertyCollection["Index"];
                SCOM_Object[mpp_NodeIndex].Value = NodeIndex;
                // IP Address Property
                ManagementPackProperty mpp_NodeIPAddress = mpc_Node.PropertyCollection["IPAddress"];
                SCOM_Object[mpp_NodeIPAddress].Value = IPAddress;
                // Isilon Node Name Property
                ManagementPackProperty mpp_IsilonNodeName = mpc_Node.PropertyCollection["IsilonNodeName"];
                SCOM_Object[mpp_IsilonNodeName].Value = IsilonNodeName;
                // Type Property
                ManagementPackProperty mpp_Nodetype = mpc_Node.PropertyCollection["Type"];
                SCOM_Object[mpp_Nodetype].Value = Type;
                // ReadOnly Property
                ManagementPackProperty mpp_NodeReadOnly = mpc_Node.PropertyCollection["ReadOnly"];
                SCOM_Object[mpp_NodeReadOnly].Value = ReadOnly;
            }
        }
Пример #2
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        /// <param name="address">IP Address : From CSV File</param>
        /// <param name="community">SNMP Community  : From CSV File</param>
        /// <param name="username">SNMP UserName : From CSV File</param>
        /// <param name="password">SNMP Password : From CSV File</param>
        public IsilonCluster(string address, string community, string username, string password)
        {
            // Get Variable that are used in more than one place)
            string clusterGUID     = SNMP.GetSNMP(SNMP.clusterGUID, address, 161, community)[0].Data.ToString();
            string clusterName     = SNMP.GetSNMP(SNMP.clusterName, address, 161, community)[0].Data.ToString();
            string configuredNodes = SNMP.GetSNMP(SNMP.configuredNodes, address, 161, community)[0].Data.ToString();
            int    nodeCount       = Convert.ToInt32(SNMP.GetSNMP(SNMP.nodeCount, address, 161, community)[0].Data.ToString());

            // Get and Calculate capacity
            Double capacity = Convert.ToDouble(SNMP.GetSNMP(SNMP.ifsTotalBytes, address, 161, community)[0].Data.ToString());

            capacity = Math.Round((capacity / 1024 / 1024 / 1024 / 1024), 2);

            // Get and Calculate Used Capacity
            Double used = Convert.ToDouble(SNMP.GetSNMP(SNMP.ifsUsedBytes, address, 161, community)[0].Data.ToString());

            used = Math.Round((used / 1024 / 1024 / 1024 / 1024), 2);

            // Get and Calculate Available Capacity
            Double available = Convert.ToDouble(SNMP.GetSNMP(SNMP.ifsAvailableBytes, address, 161, community)[0].Data.ToString());

            available = Math.Round((available / 1024 / 1024 / 1024 / 1024), 2);

            // Calculate Percentage Used
            Double percentageUsed = Math.Round(((used / capacity) * 100), 2);

            // Create Root Entity Class & Display Name Prop
            ManagementPackClass    mpc_Entity            = SCOM.GetManagementPackClass("System.Entity");
            ManagementPackProperty mpp_EntityDisplayName = mpc_Entity.PropertyCollection["DisplayName"];

            // Create Cluster Management Pack Class
            ManagementPackClass mpc_Cluster = SCOM.GetManagementPackClass("AP.Isilon.Cluster");

            // Create New Cluster Object
            SCOM_Object = new CreatableEnterpriseManagementObject(SCOM.m_managementGroup, mpc_Cluster);

            // Display Name of Root Entity (KEY Property)
            SCOM_Object[mpp_EntityDisplayName].Value = clusterName;

            // Set Properties of Cluster
            //Starting with name (Key Property of Cluster)
            ManagementPackProperty mpp_ClusterName = mpc_Cluster.PropertyCollection["Name"];

            SCOM_Object[mpp_ClusterName].Value = clusterName;
            // GUID Property
            ManagementPackProperty mpp_ClusterGUID = mpc_Cluster.PropertyCollection["GUID"];

            SCOM_Object[mpp_ClusterGUID].Value = clusterGUID;
            // IPAddress
            ManagementPackProperty mpp_ClusterIP = mpc_Cluster.PropertyCollection["IPAddress"];

            SCOM_Object[mpp_ClusterIP].Value = address;
            // SNMP Community String
            ManagementPackProperty mpp_ClusterCommunity = mpc_Cluster.PropertyCollection["Community"];

            SCOM_Object[mpp_ClusterCommunity].Value = community;
            // NodeCount
            ManagementPackProperty mpp_ClusterNodeCount = mpc_Cluster.PropertyCollection["NodeCount"];

            SCOM_Object[mpp_ClusterNodeCount].Value = nodeCount;
            // Configured Nodes
            ManagementPackProperty mpp_ClusterConfiguredNodes = mpc_Cluster.PropertyCollection["ConfiguredNodes"];

            SCOM_Object[mpp_ClusterConfiguredNodes].Value = configuredNodes;
            // Online Nodes
            ManagementPackProperty mpp_ClusterOnlineNodes = mpc_Cluster.PropertyCollection["OnlineNodes"];

            SCOM_Object[mpp_ClusterOnlineNodes].Value = SNMP.GetSNMP(SNMP.onlineNodes, address, 161, community)[0].Data.ToString();
            // Offline Nodes
            ManagementPackProperty mpp_ClusterOfflineNodes = mpc_Cluster.PropertyCollection["OfflineNodes"];

            SCOM_Object[mpp_ClusterOfflineNodes].Value = SNMP.GetSNMP(SNMP.offlineNodes, address, 161, community)[0].Data.ToString();
            // Location
            ManagementPackProperty mpp_ClusterLocation = mpc_Cluster.PropertyCollection["Location"];

            SCOM_Object[mpp_ClusterLocation].Value = SNMP.GetSNMP(SNMP.sysLocation, address, 161, community)[0].Data.ToString();
            // Contact
            ManagementPackProperty mpp_ClusterContact = mpc_Cluster.PropertyCollection["Contact"];

            SCOM_Object[mpp_ClusterContact].Value = SNMP.GetSNMP(SNMP.sysContact, address, 161, community)[0].Data.ToString();
            // Capacity
            ManagementPackProperty mpp_ClusterCapacity = mpc_Cluster.PropertyCollection["Capacity"];

            SCOM_Object[mpp_ClusterCapacity].Value = capacity;
            // Used Capacity
            ManagementPackProperty mpp_ClusterUsedCapacity = mpc_Cluster.PropertyCollection["Used"];

            SCOM_Object[mpp_ClusterUsedCapacity].Value = used;
            // Available Capacity
            ManagementPackProperty mpp_ClusterAvailableCapacity = mpc_Cluster.PropertyCollection["Available"];

            SCOM_Object[mpp_ClusterAvailableCapacity].Value = available;
            // Used Percentage
            ManagementPackProperty mpp_ClusterUsedPercentage = mpc_Cluster.PropertyCollection["UsedPercentage"];

            SCOM_Object[mpp_ClusterUsedPercentage].Value = percentageUsed;

            // Get Nodes
            try
            {
                // Create SSH Connection to Cluster
                client = new SshClient(address, username, password);
                client.Connect();

                // Loop Though All Nodes
                for (int i = 1; i <= nodeCount; i++)
                {
                    // Get Interfaces for this Node
                    var cmd = client.CreateCommand("isi network interfaces list -v -z -a -n " + i + " --format json");
                    cmd.Execute();
                    // Collect Result (Will be In JSON Format
                    string result = cmd.Result;


                    JavaScriptSerializer     js         = new JavaScriptSerializer();
                    IsilonNetworkInterface[] interfaces = js.Deserialize <IsilonNetworkInterface[]>(result);

                    // Create New Node
                    IsilonNode newNode = new IsilonNode(clusterName, i, interfaces, address, community);

                    // Add Node to NodeList
                    NodeList.Add(newNode);
                }


                // Dispose of Cluster SSH Connection
                client.Disconnect();
                client.Dispose();
            }
            catch (Exception ex)
            {
                if (client.IsConnected)
                {
                    client.Disconnect();
                    client.Dispose();
                }
                Program.log.Error(clusterName + " : " + ex.Message);
            }
        }
Пример #3
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public void CreateScomObject(string clusterName, string NodeName)
        {
            // Create Root Entity Class & Display Name Prop
            ManagementPackClass    mpc_Entity            = SCOM.GetManagementPackClass("System.Entity");
            ManagementPackProperty mpp_EntityDisplayName = mpc_Entity.PropertyCollection["DisplayName"];

            // Create NetworkInterface Management Pack Class
            ManagementPackClass mpc_NetworkInterface = SCOM.GetManagementPackClass("AP.Isilon.NetworkInterface");

            // Create New NetworkInterface Object
            SCOM_Object = new CreatableEnterpriseManagementObject(SCOM.m_managementGroup, mpc_NetworkInterface);

            // Display Name of Root Entity (KEY Property)
            SCOM_Object[mpp_EntityDisplayName].Value = name;

            // Create Isilon Node Class & Index Prop
            ManagementPackClass    mpc_Node     = SCOM.GetManagementPackClass("AP.Isilon.Node");
            ManagementPackProperty mpp_NodeName = mpc_Node.PropertyCollection["Name"];

            // Set Parent Node Key Property
            SCOM_Object[mpp_NodeName].Value = NodeName;

            // Create Isilon Cluster Class & Name Prop
            ManagementPackClass    mpc_Cluster     = SCOM.GetManagementPackClass("AP.Isilon.Cluster");
            ManagementPackProperty mpp_ClusterName = mpc_Cluster.PropertyCollection["Name"];

            // Set Parent Cluster Key Property
            SCOM_Object[mpp_ClusterName].Value = clusterName;

            // Now we Can Set Properties of the Network Interface
            ManagementPackProperty mpp_NetworkInterfaceName = mpc_NetworkInterface.PropertyCollection["Name"];

            SCOM_Object[mpp_NetworkInterfaceName].Value = name;

            // IP Addresses
            string addresses = "";

            foreach (string address in ip_addrs)
            {
                addresses += address + ", ";
            }
            addresses = addresses.TrimEnd(new char[] { ',', ' ' });
            ManagementPackProperty mpp_NetworkInterfaceIPAddress = mpc_NetworkInterface.PropertyCollection["IPAddresses"];

            SCOM_Object[mpp_NetworkInterfaceIPAddress].Value = addresses;

            // SubNets
            string subnets = "";

            foreach (string owner in owners)
            {
                subnets += owner.Substring(owner.LastIndexOf('.') + 1) + ", ";
            }
            subnets = subnets.TrimEnd(new char[] { ',', ' ' });
            ManagementPackProperty mpp_NetworkInterfaceSubnet = mpc_NetworkInterface.PropertyCollection["Subnets"];

            SCOM_Object[mpp_NetworkInterfaceSubnet].Value = subnets;

            ManagementPackProperty mpp_NetworkInterfaceIndex = mpc_NetworkInterface.PropertyCollection["Index"];

            SCOM_Object[mpp_NetworkInterfaceIndex].Value = index;

            ManagementPackProperty mpp_NetworkInterfaceNicName = mpc_NetworkInterface.PropertyCollection["NicName"];

            SCOM_Object[mpp_NetworkInterfaceNicName].Value = nic_name;
        }