|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--Monitor.Omr.CpuMonitor
Locally monitor the CPU load.
This class locally monitors the percentage of CPU usage in the host. The
frequency in which this monitoring occurs is holded by a Frequency
object.
The value of the currently percentage of CPU usage is holded by a
CurrentRange
object. The monitoring performed by a
CpuMonitor
object can be suspended and
resumed. These operations are controlled by a SuspendMonitor
object.
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
CpuMonitor(CurrentRange cr,
Frequency fobj,
SuspendMonitor smonitor)
|
Method Summary | |
void |
run()
Continuously check and calculate the percentage of CPU use. |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public CpuMonitor(CurrentRange cr, Frequency fobj, SuspendMonitor smonitor)
Method Detail |
public void run()
extraiValores
where
the values of us, us_low, sy
and id
are extracted.
Two reads of /proc/stat
are made in an interval of 2 seconds. The percentage of CPU use is then calculated
using the values extracted in both reads. The thread then waits for t
seconds and then repeats the loop. t
is obtained using the method
get
of the Frequency
object,
responsible for holding the frequency in which the monitoring process must
occur. The frequency is passed by the user, using the method
change_frequency
that belongs to the Rmo interface.
After calculating the percentage of CPU use, the loop always check if it must
suspend the monitoring process by calling the method
is_monitor_suspended
that belongs to a SuspendMonitor
object.
This method will stop the monitoring thread
if the user called the method suspend
that belongs to the
Rmo interface. The monitoring thread will be resumed when the user calls
resume, also from the
Rmo interface.
run
in class java.lang.Thread
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |