Just info for anyone else interested... we've created this JScript to do
the job. This will also add the drive name and used space into the Notes
section for the device so that it can also be sent in the alert if you
want. Once the monitor is up again it clears it back out of the Notes.
 
//JScript
//Assumption: All instances between the first and last are valid
(continuity)
 
var oSnmpRqst =  new ActiveXObject("CoreAsp.SnmpRqst"); 
var nDeviceID = Context.GetProperty("DeviceID");
var oResult = oSnmpRqst.Initialize(nDeviceID);
if (oResult.Failed)
{
 Context.SetResult(1, "Initialization error " );
} 
else
{
 var sReturn = ""; //Good string to return
 var sBadReturn = ""; //Bad string to return
 var shrStorageDescr = "1.3.6.1.2.1.25.2.3.1.3."; //hrStorageDescr
 var shrStorageSize = "1.3.6.1.2.1.25.2.3.1.5."; //hrStorageSize
 var shrStorageUsed = "1.3.6.1.2.1.25.2.3.1.6."; //hrStorageUsed
 var i = 1; //First instance
 while(true) //Continue until we reach a non-existant instance
 {
  var shrDescr = oSnmpRqst.Get(shrStorageDescr + i); //hrStorageDescr
per instance
  var shrSize = oSnmpRqst.Get(shrStorageSize + i); //hrStorageSize per
instance
  var shrUsed = oSnmpRqst.Get(shrStorageUsed + i); //hrStorageUsed per
instance
  if (shrDescr.Failed) //We hit an instance that doesn't exist, time to
return a string
  {
   if(sBadReturn == "") //If there was no error
   {
    //Get the Open DB connection from the Context NameSpace
    var oDb = Context.GetDB;
    var sSql = "UPDATE Device SET sNote = '' WHERE nDeviceID = " +
nDeviceID; //Clear the notes
    var oRs = oDb.Execute(sSql);
    Context.SetResult(0, sReturn); //Return our good string
   }
   else //Something went wrong
   {
    // Get the Open DB connection from the Context NameSpace
    var oDb = Context.GetDB;
    var sSql = "UPDATE Device SET sNote = '" + sBadReturn + "' WHERE
nDeviceID = " + nDeviceID; //Note all bad drives
    var oRs = oDb.Execute(sSql);
    Context.SetResult(1, sBadReturn); //Return our bad string and notify
What'sUp Gold
   }
   break; //Exit the loop
  }
  else //There are still instances
  {
   iPercent = (parseInt(shrUsed) / parseInt(shrSize)) * 100; //Calculate
the % of drive space
   if(iPercent >= 90) //Set the drive space percentage here (90 = 90%)
   {
    if(sBadReturn != "") //Formatting
     sBadReturn = sBadReturn + " || "; //Formatting
    sBadReturn = sBadReturn + "[" + shrDescr + "]: " + shrUsed + " of "
+ shrSize + " (" + iPercent.toFixed(1) + "%)";
   }
   if(sReturn != "") //Formatting
    sReturn = sReturn + " || "; //Formatting
   sReturn = sReturn + "[" + shrDescr + "]: " + shrUsed + " of " +
shrSize + " (" + iPercent.toFixed(1) + "%)";
   i++; //Move on to next instance
  }
 }
}

________________________________

From: Rothfuss, Gregory 
Sent: Friday, October 24, 2008 12:05 PM
To: [email protected]
Subject: Active Script Monitor for Linux Drive Space in Percentage


Has anyone created a script that will do this?

________________________________

From: Ipswitch Technical Support [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 23, 2008 4:04 PM
To: Rothfuss, Gregory
Subject: Case Ref: 2-78983. Please quote this number in all
correspondence.



Hello Greg,

There is a way to do that, but it requires some scripting: either
Jscript or VBscript. 

Basically, you will need to create an active script monitor. In order to
be generic to all of your 50 + Linux servers, the script will loop
through the SNMP object 1.3.6.1.2.1.25.2.3.1.3 to find the instances
start with "/". Save the instance number. Then for each instance, find
the value HrStorageUsed, HrStorageSize. Get the percentage. If the
percentage is not satisfied, set the active script result to be failed.

WUG gives you the capability to build the active monitor, but you have
to do a lot of work. 

I will put in a feature request for this case. Hope in the future there
will be a ready to use active monitor...

Let us know if you have more questions.

Regards,

Min Zhang
Ipswitch Technical Support
http://support.ipswitch.com
Visit and see our new knowledgebase!



In response to your question:  "I need assistance in creating a drive
space monitor based on percentage of free space that will work for
approximately 50 linux servers which have drives/partituons of various
sizes. 

The percentage data is already being collected with performance monitors
so there should be a way, but I can't figure it out. 

Thanks 

--- 
Greg Rothfuss 
Network Services Supervisor - Support 
Information Services 
South Georgia Medical Center 
2501 N Patterson Street 
Valdosta, GA 31603 
Voice: (229)333-1158 
Pager: (229)333-1650 #1897 
FAX:   (229)333-1128 
E-mail: [EMAIL PROTECTED]".

Reply via email to