com.bigdata.counters.linux
Class SysstatUtil

java.lang.Object
  extended by com.bigdata.counters.linux.SysstatUtil

public class SysstatUtil
extends Object

Some utility methods related to integration with sysstat.

Version:
$Id: SysstatUtil.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson

Field Summary
protected static boolean DEBUG
          True iff the log level is DEBUG or less.
protected static boolean INFO
          True iff the log level is INFO or less.
protected static org.apache.log4j.Logger log
           
 
Constructor Summary
SysstatUtil()
           
 
Method Summary
static File getPath()
          Returns the path to the sysstat utilities (pidstat, sar, etc).
static DateFormat newDateFormat()
          Deprecated. sysstat only reports the TIME OF DAY. In order to get the UTC time it has to be corrected by the UTC time of the start of the current day. Since very little latency is expected between the report by sysstat of its performance counters and the parsing of those performance counters by our code, it is MUCH easier and more robust to simply use the current time as reported by System.currentTimeMillis().
static String[] splitDataLine(String data)
          Splits a data line into fields based on whitespace and skipping over the date field (index zero (0) is the index of the first non-date field).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.log4j.Logger log

DEBUG

protected static final boolean DEBUG
True iff the log level is DEBUG or less.


INFO

protected static final boolean INFO
True iff the log level is INFO or less.

Constructor Detail

SysstatUtil

public SysstatUtil()
Method Detail

getPath

public static final File getPath()
Returns the path to the sysstat utilities (pidstat, sar, etc). The default is /usr/bin. This may be overriden using the com.bigdata.counters.linux.sysstat.path property.

Returns:
The path.

splitDataLine

public static String[] splitDataLine(String data)
Splits a data line into fields based on whitespace and skipping over the date field (index zero (0) is the index of the first non-date field).

Note: Some fields can overflow, e.g., RSS. When this happens the fields in the data lines wind up eating into the whitespace to their right. This means that it is more robust to split the lines based on whitespace once we have skipped over the date field. Since we specify using PIDStatCollector.setEnvironment(Map) that we want an ISO date format, we know that the date field is 11 characters. The data lines are broken up by whitespace after that.

Note: Since we split on whitespace, the resulting strings are already trimmed.

Returns:
The fields.

newDateFormat

public static DateFormat newDateFormat()
Deprecated. sysstat only reports the TIME OF DAY. In order to get the UTC time it has to be corrected by the UTC time of the start of the current day. Since very little latency is expected between the report by sysstat of its performance counters and the parsing of those performance counters by our code, it is MUCH easier and more robust to simply use the current time as reported by System.currentTimeMillis().

Used to parse the timestamp associated with each row of sysstat output.

Note: This assumes that you have controlled the date format using the sysstat ISO date option.

Note: This is not thread-safe - use a distinct instance for each PIDStatCollector or SarCpuUtilizationCollector.



Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.