Performance Counters Functions


Performance counters are based on several predefined JavaScript functions:

SNMPMonitor() - JavaScript function for performance counters which use the SNMP protocol
WMIMonitor() - JavaScript function for performance counters which use the WMI protocol
ApacheMonitor() - JavaScript function for Apache server performance counters which use the HTTP protocol
SQLMonitor() - JavaScript function for performance counters which use the ODBC interface

Each counter should be based on one of these functions. A value returned by this function is counter's value displayed in reports and graphs.

Inside the SNMPMonitor(), WMIMonitor(), ApacheMonitor() and SQLMonitor() you can use the following functions:

counter.SNMPGetValue(<oid_name>) - gets the value of the counter with the OID equal to <oid_name>.

counter.SNMPGetNextValue(<oid_name>) - gets the value of the next counter, which stays after the counter with the OID equal to <oid_name>.

counter.WMIGetValue(<wql_query>, <name>, <number>) - makes an sql query <wql_query> and returns the value from the <name> column and <number> string of the table which is the result of query execution.

counter.lastValue - returns the previous value of the counter.

counter.lastOIDName - returns the OID of the last SNMP request.

counter.ApacheGetValue(<ParamName>) - gets the value of <ParamName> parameter from the Apache server statistics file.

counter.SQLGetValue(<sql_query>) - returns the value stored in the first column of the first string of the table which is the result of <sql_query> execution.

Example of usage

function WMIMonitor()
{
          var freeSpace = (counter.WMIGetValue("SELECT PercentFreeSpace FROM Win32_PerfRawData_PerfDisk_LogicalDisk WHERE Name='_Total'", "PercentFreeSpace", 0)-0);
          var freeSpaceBase = (counter.WMIGetValue("SELECT PercentFreeSpace_Base FROM Win32_PerfRawData_PerfDisk_LogicalDisk WHERE Name='_Total'", "PercentFreeSpace_Base", 0)-0);


          if(freeSpaceBase > 0)
          {
                    var diskUsage = (freeSpace * 100 / freeSpaceBase);
                    return 100 - diskUsage;
          }


          return 0;
}

Next page