Monitor disk space

  • How do you monitor disk space of each drive, for example if E drive is our data drive, F drive is our log drive, if they are 20% space left of the total space, i would like to send me a notification,

    how do you usually do that?

    Thanks

  • you could buy a 3rd party tool which monitors it, or you could write your own WMI Queries to get OS data, wrap it in a powershell script which sends and email and use windows scheduled tasks to execute it on a schedule

    have a look for a tool called scriptomatic from the Mircosoft scripting guys, it will allow you to write WMI queries in seconds assuming you know the right classes to query.

  • I have a stored proc which writes free space into a table ( so I can track growth if required ) I then have a ssrs report which shows me the ouput. The whole thing runs every 3 hours and is linked to an email alert set to whatever space % I feel is critical. Obviously this is relative as 20% of a 20TB lun may not be an issue, but 20% of a 100GB lun may.

    [font="Comic Sans MS"]The GrumpyOldDBA[/font]
    www.grumpyolddba.co.uk
    http://sqlblogcasts.com/blogs/grumpyolddba/

  • Hi,

    You can create a script using the extended stored procedure "xp_fixeddrives" to check the space usage in each of the hard drives.

    Regards,

    Shodhan

  • Shodhan (2/16/2012)


    Hi,

    You can create a script using the extended stored procedure "xp_fixeddrives" to check the space usage in each of the hard drives.

    Regards,

    Shodhan

    Although that's not going to help you if you use mount points is this only looks at root drives.



    Shamless self promotion - read my blog http://sirsql.net

  • I have a stored procedure that utilizes the xp_fixeddrives extended stored proc that gives you the ability to set both a percentage and fixed free space amount in which to validate against. Alerts are only raised if it fails both tests. Let me know if you're interested.

  • And we use xp_cmdshell to WMI tools.

    Jared
    CE - Microsoft

  • Here's a real quick way to check space using powershell within a function http://sirsql.net/blog/2010/11/23/quick-powershell-disk-space-check.html.

    This can be easily adjusted to load the information into a database for storage, alerting, reporting and trending.



    Shamless self promotion - read my blog http://sirsql.net

  • People still use xp_cmdshell :w00t:

  • jasonmorris (2/17/2012)


    People still use xp_cmdshell :w00t:

    What's wrong with it? I have not really read any convincing evidence to not use it if it is secured properly.

    Jared
    CE - Microsoft

  • jasonmorris (2/17/2012)


    People still use xp_cmdshell :w00t:

    Why not, this is the one that has served us for years & has been exceptional for a DBA in handling things like that :Whistling:.


    Sujeet Singh

  • Just seems an antiquated way of getting drive statistics when WMI is available.

    Most shops / auditors require that is locked out even though they don't understand it can be secured.

    Hey but giving everybody Powershell is fine.

  • jasonmorris (2/17/2012)


    Just seems an antiquated way of getting drive statistics when WMI is available.

    Most shops / auditors require that is locked out even though they don't understand it can be secured.

    Hey but giving everybody Powershell is fine.

    I think in many shops it is mainly that PowerShell is a new skillset to learn and administer. Also, cmd accesses WMI much in the same way that PowerShell does. PowerShell itself has to be secured properly. I think once more and more people use PowerShell, cmd will become antiquated. Until then, it is just as useful for many tasks and just as secure; i.e. Why fix something that isn't broken 🙂

    Jared
    CE - Microsoft

  • Nicholas Cain (2/16/2012)


    Here's a real quick way to check space using powershell within a function http://sirsql.net/blog/2010/11/23/quick-powershell-disk-space-check.html.

    This can be easily adjusted to load the information into a database for storage, alerting, reporting and trending.

    I tried the update2 powershell script, and I got an error, any ideas?

    Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)

    At \\CNOCMF01\Staff_C$\xicao\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:21 char:5

    + GWMI <<<< -ComputerName $Servername Win32_LogicalDisk -Filter "DriveType = 3 AND Size > 0" |

    + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], COMException

    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

    Also, how this can be inputted to a table to monitor?

    thanks

  • Check that the computer you are trying to check for exists, that you have permission to access WMI and that there are no firewalls in the way.



    Shamless self promotion - read my blog http://sirsql.net

Viewing 15 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic. Login to reply