Alert for Logical disk space capacity available for Hosts .
Hello,
I am requesting a help here. I have enabled a Host Monitoring rule for LogicalDisk capacity available. The rule is calculating the space based on the % of capacity available. I would like to set it at GB level instead of %. Foe example if there is a les than 10GB available on C drive alert should trigger. Rule condition is as below. I just tried to multiply the Host.LogicalDiskCapacityAvailable.fatal by 1024. But it didnt work. I think it will not work as I guessed it.
Ok, this is a good thing to do, since % isn't always the most important thing to monitor for. e.g. you always need 50GB free disk space on a datastore, regardless of % in use.
**** ALWAYS COPY A RULE, AND THEN MODIFY IT ***
First, you have to determine what you are going to compare, and what threshold you want to compare it to. Sadly, this particular rule isn't written very clearly as an example.
The current rule uses a scope of VMWVirtualMachineLogicalDisk:
The fatal rule condition is currently:
try{
vmStateObjs = #vmState from $scope.virtualMachine#;
I created the rule as you guided last week. The rule is created without any issues. But it is not validating the low disk space of any configured physical Hosts. I am not getting any alerts also. Any help here is greately appreciated.
I have set up the alerts for my Physical boxes to monitor the space available in logical drives in GBs instead of %. Followed the below simple steps to achieve it.
Copied the Host LogicalDiskCapacityAvailable rules from Host Monitoring rules and modified the fatal rule as
Also copied Host.LogicalDiskCapacityAvailable registry variable and modified it as Host.LogicalDiskCapacityAvailableGB with the desired static value in MBs. (Ex: entered 1024 to trigger if the space is available less than 1 GB).
I found the spave Available property in logicaldisk topology metrc which calculates the drive space available in MBs instead of %. I just modified the fatal rule condition by replacing #capacityAvailable# to #spaceAvailable#. It worked for me.
But we need to exclude CD/DVD drives in the rule scope. else alert triggers for them also.
john_s_main
132 Posts
471
1
Posted August 28th, 2012 13:00
Ok, this is a good thing to do, since % isn't always the most important thing to monitor for. e.g. you always need 50GB free disk space on a datastore, regardless of % in use.
**** ALWAYS COPY A RULE, AND THEN MODIFY IT ***
First, you have to determine what you are going to compare, and what threshold you want to compare it to. Sadly, this particular rule isn't written very clearly as an example.
The current rule uses a scope of VMWVirtualMachineLogicalDisk:
The fatal rule condition is currently:
try{
vmStateObjs = #vmState from $scope.virtualMachine#;
tmpList0 = vmStateObjs?.values(vmStateObjs?.topologyObjects[0]);
if(tmpList0==null || tmpList0.size() == 0) {
return false;
}
vmState= tmpList0.get(0)?.getValue();
qObjs = #capacityAvailable from $scope.hostLogicalDisk#;
tmpList = qObjs?.values(qObjs?.topologyObjects[0]);
if(tmpList==null || tmpList.size() == 0) {
return false;
}
availbility = tmpList.get(0)?.getValue()?.getAvg();
if((vmState==null) || (availbility == null) || (!vmState?.equalsIgnoreCase("poweredOn")))
return false;
@rulette_data["VmState"] = vmState;
@rulette_data["Availbility"] = availbility ;
if(availbility<=registry("VMW:vmLogicalDrive.fatal")) return true;
else return false;
} catch (Exception e) {return false;}
availbility is stored as 0-100 (%) of the total disk space on the logical drive.
In order to create a rule which compares to actual disk free, we need a different query
to retrieve 'spaceAvailable', which is stored in megabytes.
So, for our new rule, we will need:
qObjs = #spaceAvailable from $scope.hostLogicalDisk#;
tmpList = qObjs?.values(qObjs?.topologyObjects[0]);
if(tmpList==null || tmpList.size() == 0) {
return false;
}
spaceAvailable = tmpList.get(0)?.getValue()?.getAvg();
return spaceAvailable;
Now, we can change the comparisons in the Critical and Fatal to alert
on the comparison of spaceAvailable to a new registry variable called
Host.LogicalDiskCapacityAvailable.fatal which is set to a value of 10240,
and Host.LogicalDiskCapacityAvailable.critical which could be set to something like 20480.
Both are in megabytes to match the scale of spaceAvailable.
The new fatal rule would then be something like:
try{
vmStateObjs = #vmState from $scope.virtualMachine#;
tmpList0 = vmStateObjs?.values(vmStateObjs?.topologyObjects[0]);
if(tmpList0==null || tmpList0.size() == 0) {
return false;
}
vmState= tmpList0.get(0)?.getValue();
qObjs = #spaceAvailable from $scope.hostLogicalDisk#;
tmpList = qObjs?.values(qObjs?.topologyObjects[0]);
if(tmpList==null || tmpList.size() == 0) {
return false;
}
spaceAvailable = tmpList.get(0)?.getValue()?.getAvg();
if((vmState==null) || (spaceAvailable == null) || (!vmState?.equalsIgnoreCase("poweredOn")))
return false;
@rulette_data["VmState"] = vmState;
@rulette_data["spaceAvailable"] = spaceAvailable ;
if(spaceAvailable<=registry("Host.LogicalDiskCapacityAvailable.fatal")) return true;
else return false;
} catch (Exception e) {return false;}
Notice that the @rulette_data values are set in the Fatal level,
and then can be used in the Critical level without re-calculating them.
The Critical condition would then become:
try{
vmState = @rulette_data["VmState"];
spaceAvailable = @rulette_data["spaceAvailable"];
if((vmState==null) || (spaceAvailable==null) || (!vmState?.equalsIgnoreCase("poweredOn"))) return false;
if(spaceAvailable<=registry("Host.LogicalDiskCapacityAvailable.critical")) return true;
else return false;
} catch (Exception e) {return false;}
You will also want to look at the Behaviour tab, as you want to prevent 'thrashing'
if space available goes over and under a threshold on a regular basis.
You might want your rule to be set to something like Fire after 2 consecutive failures, waiting 30 min between.