ROOT logo
// $Id: GledMonitor.cxx 2090 2008-12-02 01:13:01Z matevz $

// Copyright (C) 1999-2008, Matevz Tadel. All rights reserved.
// This file is part of GLED, released under GNU General Public License version 2.
// For the licensing terms see $GLEDSYS/LICENSE or http://www.gnu.org/.

#include "GledMonitor.h"
#include <Glasses/SaturnInfo.h>
#include "GledMonitor.c7"

#include <Gled/GledMirDefs.h>

#include <TMath.h>
#include <TSystem.h>

//__________________________________________________________________________
//
// Operator that collects local cpu & mem information and updates state
// of appropriate SaturnInfo.
// If bFillHistos is true fills load average histograms. To access them,
// type 'new TBrowser' and navigate: 'ROOT files'-><monitor>->LAvg, then
// double-click on histogram icon.

ClassImp(GledMonitor);

/**************************************************************************/

void GledMonitor::_init()
{
  mCpuSampleTime = 200; // Sampling time when getting CpuInfo [ms].
}

/**************************************************************************/

void GledMonitor::AdEnlightenment()
{
  Operator::AdEnlightenment();
  InitHistoGroups();
}

void GledMonitor::Operate(Operator::Arg* op_arg)
{
  Operator::PreOperate(op_arg);

  CpuInfo_t cpu; gSystem->GetCpuInfo(&cpu, mCpuSampleTime);
  MemInfo_t mem; gSystem->GetMemInfo(&mem);

  SaturnInfo* si = mSaturn->GetSaturnInfo();

  // !!!! here should realy send cpu/mem ... need setters in SaturnInfo.
  // !!!! also, CpuInfo_t should be fixed to include 'nice' usage.

  SP_MIR(si, SetMFree, mem.fMemFree);
  SP_MIR(si, SetSFree, mem.fSwapFree);

  SP_MIR(si, SetLAvg1,  cpu.fLoad1m);
  SP_MIR(si, SetLAvg5,  cpu.fLoad5m);
  SP_MIR(si, SetLAvg15, cpu.fLoad15m);

  SP_MIR(si, SetCU_Total, 0.01*TMath::Nint(100.0*cpu.fTotal));
  SP_MIR(si, SetCU_User,  0.01*TMath::Nint(100.0*cpu.fUser));
  SP_MIR(si, SetCU_Nice,  0);
  SP_MIR(si, SetCU_Sys,   0.01*TMath::Nint(100.0*cpu.fSys));
  SP_MIR(si, SetCU_Idle,  0.01*TMath::Nint(100.0*cpu.fIdle));

  if(bFillHistos) {
    h1LAvg1 ->Fill(cpu.fLoad1m);
    h1LAvg5 ->Fill(cpu.fLoad5m);
    h1LAvg15->Fill(cpu.fLoad15m);
  }

  Operator::PostOperate(op_arg);
}
 GledMonitor.cxx:1
 GledMonitor.cxx:2
 GledMonitor.cxx:3
 GledMonitor.cxx:4
 GledMonitor.cxx:5
 GledMonitor.cxx:6
 GledMonitor.cxx:7
 GledMonitor.cxx:8
 GledMonitor.cxx:9
 GledMonitor.cxx:10
 GledMonitor.cxx:11
 GledMonitor.cxx:12
 GledMonitor.cxx:13
 GledMonitor.cxx:14
 GledMonitor.cxx:15
 GledMonitor.cxx:16
 GledMonitor.cxx:17
 GledMonitor.cxx:18
 GledMonitor.cxx:19
 GledMonitor.cxx:20
 GledMonitor.cxx:21
 GledMonitor.cxx:22
 GledMonitor.cxx:23
 GledMonitor.cxx:24
 GledMonitor.cxx:25
 GledMonitor.cxx:26
 GledMonitor.cxx:27
 GledMonitor.cxx:28
 GledMonitor.cxx:29
 GledMonitor.cxx:30
 GledMonitor.cxx:31
 GledMonitor.cxx:32
 GledMonitor.cxx:33
 GledMonitor.cxx:34
 GledMonitor.cxx:35
 GledMonitor.cxx:36
 GledMonitor.cxx:37
 GledMonitor.cxx:38
 GledMonitor.cxx:39
 GledMonitor.cxx:40
 GledMonitor.cxx:41
 GledMonitor.cxx:42
 GledMonitor.cxx:43
 GledMonitor.cxx:44
 GledMonitor.cxx:45
 GledMonitor.cxx:46
 GledMonitor.cxx:47
 GledMonitor.cxx:48
 GledMonitor.cxx:49
 GledMonitor.cxx:50
 GledMonitor.cxx:51
 GledMonitor.cxx:52
 GledMonitor.cxx:53
 GledMonitor.cxx:54
 GledMonitor.cxx:55
 GledMonitor.cxx:56
 GledMonitor.cxx:57
 GledMonitor.cxx:58
 GledMonitor.cxx:59
 GledMonitor.cxx:60
 GledMonitor.cxx:61
 GledMonitor.cxx:62
 GledMonitor.cxx:63
 GledMonitor.cxx:64
 GledMonitor.cxx:65
 GledMonitor.cxx:66
 GledMonitor.cxx:67
 GledMonitor.cxx:68
 GledMonitor.cxx:69
 GledMonitor.cxx:70
 GledMonitor.cxx:71
 GledMonitor.cxx:72
 GledMonitor.cxx:73