9 Replies Latest reply on Mar 24, 2012 5:06 AM by dirch201110141

    Alarm for VM Free space metric

    cjwirweazel Novice

       

      i have a script that will show me the free space on the VM Guest OS disk

       

       

       

       

       

      Get-VM | Where { $_.PowerState -eq "PoweredOn" } | Get-VMGuest | Select VMName -ExpandProperty Disks | Select VMName, Path, @{Name="DiskFreeGB";Expression={[math]::Round((($_.FreeSpace)/1GB),2)}}

       

       

       

       

       

      I have seen that you can set up alarms though PCLI and was wondering if any has had a go at it with something like the above.

       

       

       

       

       

      I don't really know where to start with it so any help would be great

       

       

       

       

       

      chris

       

       

        • 1. Re: Alarm for VM Free space metric
          LucD Guru
          User ModeratorsvExpertCommunity Warriors

          The triggers that are available to fire an alarm are either a performance metric, an event or a state.

          See AlarmExpression.

          Afaik none of these has an option to use the free disk space from a guest as a trigger.

           

          But you can always run your script on a scheduler and send an email when the free space percentage exceeds a threshold.

          You only will not be using the vCenter Alarms.

           

           

           

          ____________

          Blog: LucD notes

          Twitter: lucd22

          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
          1 person found this helpful
          • 2. Re: Alarm for VM Free space metric
            cjwirweazel Novice

             

            thanks for that - was hoping i had missed something

             

             

             

             

             

            so scheduled task to run script

             

             

             

             

             

            any advice on getting it to read the data rather than output to a file?

             

             

             

             

             

             

             

             

            cheers

             

             

             

             

             

            Chris

             

             

            • 3. Re: Alarm for VM Free space metric
              LucD Guru
              vExpertUser ModeratorsCommunity Warriors

              Sorry, not sure I understand that question about reading the data.

              Can you elaborate ?

               

               

               

               

              ____________

              Blog: LucD notes

              Twitter: lucd22

              Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
              • 4. Re: Alarm for VM Free space metric
                cjwirweazel Novice

                 

                the current script outputs to a CSV file

                 

                 

                 

                 

                 

                i am not sure how to get the script to look at the data in that script and find those with free space under a threshold and send an email

                 

                 

                 

                 

                 

                 

                 

                 

                cheers

                 

                 

                 

                 

                 

                chris

                 

                 

                • 5. Re: Alarm for VM Free space metric
                  LucD Guru
                  Community WarriorsvExpertUser Moderators

                  Try the attached script.

                   

                   

                   

                   

                  ____________

                  Blog: LucD notes

                  Twitter: lucd22

                  Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                  • 6. Re: Alarm for VM Free space metric
                    cjwirweazel Novice

                    thats awesome - thank you vewry much

                    • 7. Re: Alarm for VM Free space metric
                      dirch201110141 Novice

                      This subject is always interesting - servers running out of disk space. For a couple of weeks my collegue and I have been looking for at way to trigger an event in Virtual Center when one of the dearly beloved virtual machines runs low on free space.

                      This mail thread seems to show that this is not possible through Virtual Center - at least not in december 2010.

                      Now were running 5.0 so the question is if anything has changed here? Could it be that a new event has arrived saying "fireTriggerWhenVMisAbove80percent" so we can see it in Virtual Center as well as send a trap to HPO ?

                       

                      We're looking at this from two different angles:

                       

                      1) Fire an event (hopefully an snmp trap) when free space falls below an absolute value (say: 1 Gb)

                      2) Fire an event (again, in best case an snmp trap) when space falls below a relative value (say: 80%)

                      • 8. Re: Alarm for VM Free space metric
                        LucD Guru
                        User ModeratorsvExpertCommunity Warriors

                        Afaik, vSphere 5 didn't bring any new triggers to do what you're looking at.

                         

                        I think you could have better luck writing something in your monitor (HPO), that monitors the values you want to check regularly (with PowerCLI) and then raises an alarm in HPO.

                        Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                        • 9. Re: Alarm for VM Free space metric
                          dirch201110141 Novice

                          A speedy answer as always. Thank you.

                          We can get HPO to do it I am sure and we will be looking in that direction now.

                          The challenge of bending Virtual Center to my will and get the complete status of hosts and VMs in one view through VC must wait to another time