开发者

Determine a drive is SAN [closed]

开发者 https://www.devze.com 2022-12-21 13:22 出处:网络
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post.
Closed. This question needs details or clarity. It is not currently accepting answers.

Want to improve this question? Add details and clarify the problem by editing this post.

Closed 7 years ago.

Improve this question 开发者_C百科

Can somebody please let me know how we can determine if a local disk or SAN.

Thanks


There is no "OS agnostic" way to determine if the file system is back-ended by SAN.

That is, please let us know what OS you're using so we can help determine the OS specific way to determine if this (other than asking your storage administrator).


SAN is a Storage Area Network topology incorporated into a physical network topology, it which means that storage is provided for sharing/storing data via the network (usually tcp/ip)...It is similar to NFS (Network File Share), or using the Microsoft specific Server Message Block protocol to designate a share on the server with a drive letter used - Universal Naming Convention where a shared drive is mapped to a drive letter in the form of '\\servername\foo'.

Can you please clarify if that is what you are looking for? How to determine if a drive is mapped to the shared drive such as '\\servername\foo'?

Have a look at this thread here...on mapping drives and disconnecting mapped drives here. And here to check if a path is on a network here.

Edit: Thanks to zombiesheep for the clarification due to my confusion after being told by somebody else during my training for CompTIA Network+ 2009.....duh!

Hope this helps, Best regards, Tom.


Here you go, using C# and WMI. Using this you can type in "enumSANDrives " from a command prompt and it will list them out. You might have to tweak the descriptions a little and manually look at the WMI class through Scriptomatic or something to match up your particular SAN(s).

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.IO; 
using System.Management;
using System.Data.SqlClient;
using Microsoft.Win32;
using System.Net;
using System.Net.NetworkInformation;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using System.Security.Principal;

namespace EnumSANDrives
{
    class Program
    {


        static void Main(string[] args)
        {
            //1. Start with the Win32_DiskDrive class and query for instances of Win32_DiskPartition using the DeviceID property and the 
            //Win32_DiskDriveToDiskPartition association class. Now you have a collection of the partitions on the physical drive.
            //2. Query for the Win32_LogicalDisk that represents the partition using the Win32_DiskPartition.DeviceID property and 
            //Win32_LogicalDiskToPartition association class.
            //3. Get the drive letter from the Win32_LogicalDisk.DeviceID.

            ConnectionOptions connOptions = new ConnectionOptions();
            connOptions.Username = "<username>";
            connOptions.Password = "<pwd>";
            connOptions.Authentication = AuthenticationLevel.Packet; 
            connOptions.Impersonation = ImpersonationLevel.Impersonate;
            connOptions.EnablePrivileges = true;
            ManagementScope manScope = new ManagementScope(String.Format(@"\\{0}\ROOT\CIMV2", machine), connOptions);
            manScope.Connect();
            ObjectQuery oQueryDiskDrive = new ObjectQuery("select * from Win32_DiskDrive");
            ManagementObjectSearcher oSearcherDiskDrive = new ManagementObjectSearcher(manScope, oQueryDiskDrive);
            ManagementObjectCollection oReturnDiskDrive = oSearcherDiskDrive.Get();
            foreach (ManagementObject DiskDrive in oReturnDiskDrive)
            {
                ObjectQuery oQueryDiskPartition = new ObjectQuery("ASSOCIATORS OF {Win32_DiskDrive.DeviceID='" + DiskDrive["DeviceID"] + "'} WHERE AssocClass = Win32_DiskDriveToDiskPartition");
                ManagementObjectSearcher oSearcherDiskPartition = new ManagementObjectSearcher(manScope, oQueryDiskPartition);
                ManagementObjectCollection oReturnDiskPartition = oSearcherDiskPartition.Get();
                foreach (ManagementObject DiskPartition in oReturnDiskPartition)
                {
                    ObjectQuery oQueryLogicalDisk = new ObjectQuery("ASSOCIATORS OF {Win32_DiskPartition.DeviceID='" + DiskPartition["DeviceID"] + "'} WHERE AssocClass = Win32_LogicalDiskToPartition");
                    ManagementObjectSearcher oSearcherLogicalDisk = new ManagementObjectSearcher(manScope, oQueryLogicalDisk);
                    ManagementObjectCollection oReturnLogicalDisk = oSearcherLogicalDisk.Get();
                    foreach (ManagementObject LogicalDisk in oReturnLogicalDisk)
                    {
                        try
                        {
                            //Console.Write("Drive Name : " + LogicalDisk["DeviceID"].ToString());
                            if (DiskDrive["PNPDeviceID"] != null)
                            {
                                if (DiskDrive["PNPDeviceID"].ToString().Contains("VEN_EMC"))
                                {
                                    Console.WriteLine("Drive Name : " + LogicalDisk["DeviceID"].ToString() + " - " + "EMC SAN " + DiskDrive["Model"].ToString());
                                }
                                if (DiskDrive["PNPDeviceID"].ToString().Contains("VEN_IBM"))
                                {
                                    Console.WriteLine("Drive Name : " + LogicalDisk["DeviceID"].ToString() + " - " + "IBM SAN " + DiskDrive["Model"].ToString());
                                }
                                if (DiskDrive["PNPDeviceID"].ToString().Contains("VEN_COMPAQ"))
                                {
                                    Console.WriteLine("Drive Name : " + LogicalDisk["DeviceID"].ToString() + " - " + "HP SAN " + DiskDrive["Model"].ToString());
                                }



                            }
                            //Console.WriteLine("Size : " + BytesToGB(DiskDrive["Size"].ToString()));
                            //Console.WriteLine("Used Space : " + BytesToGB((Convert.ToDouble(DiskDrive["Size"].ToString()) - Convert.ToDouble(LogicalDisk["FreeSpace"].ToString())).ToString()));
                            //Console.WriteLine("Free Space : " + BytesToGB(LogicalDisk["FreeSpace"].ToString()));
                        }
                        catch (Exception)
                        {
                            continue;
                        }
                    }
                }
            }

        }
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号