Rio Project 4.2 API Documentation



org.rioproject.system.measurable
Class SigarHelper

java.lang.Object
  extended by org.rioproject.system.measurable.SigarHelper

public class SigarHelper
extends Object

This class is used to help in loading and using Hyperic SIGAR.

Note:Hyperic SIGAR is licensed under the GPL with a FLOSS license exception, allowing it to be included with the Rio Apache License v2 distribution. If for some reason the GPL cannot be used with your distribution of Rio, remove the RIO_HOME/lib/hyperic directory.

This class does not explicitly include and Hyperic SIGAR classes, it uses reflection to access and use SIGAR. In this way if there is an issue including SIGAR, the distribution has no hard-coded dependencies for the technology.

Author:
Dennis Reedy

Field Summary
static String COMPONENT
           
 
Method Summary
 long getFileSystemFree(String fileSystem)
          Get the amount of available K-bytes for the file system
 long getFileSystemTotal(String fileSystem)
          Get the number of total K-bytes for the file system
 long getFileSystemUsed(String fileSystem)
          Get the amount of used K-bytes for the file system
 double getFileSystemUsedPercent(String fileSystem)
          Get the percentage of disk used
 long getFreeSystemMemory()
          Get the amount of free system memory
 double getFreeSystemMemoryPercent()
          Get the percent of free system memory
static SigarHelper getInstance()
          Get an instance of the SigarHelper.
 double[] getLoadAverage()
          Get the load average for the machine
 long getPid()
          Get the pid for the current process
 double getProcessCpuPercentage(long pid)
          Get the CPU utilization (percentage) for a process
 long getProcessCpuSys(long pid)
          Get the CPU system (kernel) usage for a process
 long getProcessCpuUser(long pid)
          Get the CPU user usage for a process
 long getProcessResidentMemory(long pid)
          Get the amount of real memory the process has available to it
 long getProcessSharedMemory(long pid)
          Get the amount of shared memory the process has available to it
 long getProcessVirtualMemorySize(long pid)
          Get the amount of virtual memory the process has available to it
 long getRam()
          Get the amount of system RAM.
 double getSystemCpuPercentage()
          Get the cpu kernel usage
 long getTotalSystemMemory()
          Get the amount of system memory
 long getUsedSystemMemory()
          Get the amount of used system memory
 double getUsedSystemMemoryPercent()
          Get the percent of used system memory
 double getUserCpuPercentage()
          Get the cpu user usage
 long matchChild(int ppid, String[] sPids)
          Using the process identifier (pid) of a parent, find the matching child process using a bottom up approach
static boolean sigarAvailable()
          Check if SIGAR is available.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPONENT

public static final String COMPONENT
Method Detail

getInstance

public static SigarHelper getInstance()
Get an instance of the SigarHelper.

Returns:
An instance of the SigarHelper.

sigarAvailable

public static boolean sigarAvailable()
Check if SIGAR is available.

Returns:
True if SIGAR is available, false otherwise.

getPid

public long getPid()
Get the pid for the current process

Returns:
The process id (pid) for the executing process. If the pid cannot be obtained return -1.

matchChild

public long matchChild(int ppid,
                       String[] sPids)
Using the process identifier (pid) of a parent, find the matching child process using a bottom up approach

Parameters:
ppid - The parent pid
sPids - Array of child pids
Returns:
The matching child pid, or -1 if not found.

getSystemCpuPercentage

public double getSystemCpuPercentage()
Get the cpu kernel usage

Returns:
The cpu kernel use as a percentage; or -1 if not available.

getUserCpuPercentage

public double getUserCpuPercentage()
Get the cpu user usage

Returns:
The cpu user use as a percentage; or -1 if not available.

getLoadAverage

public double[] getLoadAverage()
Get the load average for the machine

Returns:
The system load averages for the past 1, 5, and 15 minutes. If the load average could not be obtained, return an array with a single element whose value is set to -1

getProcessCpuPercentage

public double getProcessCpuPercentage(long pid)
Get the CPU utilization (percentage) for a process

Parameters:
pid - The process id (pid) to obtain the CPU utilization (percentage) for
Returns:
The CPU utilization (percentage) for a process, or -1 if not available

getProcessCpuUser

public long getProcessCpuUser(long pid)
Get the CPU user usage for a process

Parameters:
pid - The process id (pid) to obtain the CPU user usage
Returns:
The cpu user usage for the process; or -1 if not available.

getProcessCpuSys

public long getProcessCpuSys(long pid)
Get the CPU system (kernel) usage for a process

Parameters:
pid - The process id (pid) to obtain the CPU system (kernel) usage
Returns:
The cpu system (kernel) usage for the process; or -1 if not available.

getProcessVirtualMemorySize

public long getProcessVirtualMemorySize(long pid)
Get the amount of virtual memory the process has available to it

Parameters:
pid - The process id (pid)
Returns:
The amount of virtual memory (in bytes) or -1 if not available

getProcessResidentMemory

public long getProcessResidentMemory(long pid)
Get the amount of real memory the process has available to it

Parameters:
pid - The process id (pid)
Returns:
The amount of real memory (in bytes) or -1 if not available

getProcessSharedMemory

public long getProcessSharedMemory(long pid)
Get the amount of shared memory the process has available to it

Parameters:
pid - The process id (pid)
Returns:
The amount of shared memory (in bytes) or -1 if not available

getFileSystemFree

public long getFileSystemFree(String fileSystem)
Get the amount of available K-bytes for the file system

Parameters:
fileSystem - The fileSystem name
Returns:
The amount of available K-bytes for the file system, or -1 if not available

getFileSystemUsed

public long getFileSystemUsed(String fileSystem)
Get the amount of used K-bytes for the file system

Parameters:
fileSystem - The fileSystem name
Returns:
The amount of used K-bytes for the file system, or -1 if not available

getFileSystemTotal

public long getFileSystemTotal(String fileSystem)
Get the number of total K-bytes for the file system

Parameters:
fileSystem - The fileSystem name
Returns:
The number of K-bytes for the file system, or -1 if not available

getFileSystemUsedPercent

public double getFileSystemUsedPercent(String fileSystem)
Get the percentage of disk used

Parameters:
fileSystem - The fileSystem name
Returns:
The percentage of disk used, or -1 if not available

getRam

public long getRam()
Get the amount of system RAM.

Returns:
Get the amount of system Random Access Memory (in MB), or -1 if not available

getTotalSystemMemory

public long getTotalSystemMemory()
Get the amount of system memory

Returns:
The total amount of system memory (in MB), or -1 if not available

getFreeSystemMemoryPercent

public double getFreeSystemMemoryPercent()
Get the percent of free system memory

Returns:
The percent of free system memory, or -1 if not available

getFreeSystemMemory

public long getFreeSystemMemory()
Get the amount of free system memory

Returns:
The amount of free system memory, or -1 if not available

getUsedSystemMemoryPercent

public double getUsedSystemMemoryPercent()
Get the percent of used system memory

Returns:
The percent of used system memory, or -1 if not available

getUsedSystemMemory

public long getUsedSystemMemory()
Get the amount of used system memory

Returns:
The amount of used system memory (in MB), or -1 if not available

Copyright © Rio Project.

Copyright © 2006-2011 Rio Project. All Rights Reserved.