xosview  1.23
About: xosview is an X Windows based system monitor (cpu, memory, swap and network usage; interrupt and serial activities; load average).
  Fossies Dox: xosview-1.23.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

pagemeter.cc
Go to the documentation of this file.
1 //
2 // Copyright (c) 1994, 1995 by Mike Romberg ( romberg@fsl.noaa.gov )
3 //
4 // NetBSD port:
5 // Copyright (c) 1995, 1996, 1997-2002 by Brian Grayson (bgrayson@netbsd.org)
6 //
7 // This file was originally written by Brian Grayson for the NetBSD and
8 // xosview projects.
9 //
10 // This file may be distributed under terms of the GPL or of the BSD
11 // license, whichever you choose. The full license notices are
12 // contained in the files COPYING.GPL and COPYING.BSD, which you
13 // should have received. If not, contact one of the xosview
14 // authors for a copy.
15 //
16 
17 #include "pagemeter.h"
18 #include "kernel.h"
19 #include <stdlib.h>
20 
21 
22 PageMeter::PageMeter( XOSView *parent, double total )
23  : FieldMeterGraph( parent, 3, "PAGE", "IN/OUT/IDLE" ) {
24  total_ = total;
25  BSDPageInit();
27 }
28 
30 }
31 
34 
35  setfieldcolor( 0, parent_->getResource("pageInColor") );
36  setfieldcolor( 1, parent_->getResource("pageOutColor") );
37  setfieldcolor( 2, parent_->getResource("pageIdleColor") );
38  priority_ = atoi( parent_->getResource("pagePriority") );
39  dodecay_ = parent_->isResourceTrue("pageDecay");
40  useGraph_ = parent_->isResourceTrue("pageGraph");
41  SetUsedFormat( parent_->getResource("pageUsedFormat") );
42 }
43 
44 void PageMeter::checkevent( void ) {
45  getpageinfo();
46  drawfields();
47 }
48 
49 void PageMeter::getpageinfo( void ) {
50  uint64_t info[2];
51  BSDGetPageStats(NULL, info);
52 
53  fields_[0] = info[0] - previnfo_[0];
54  fields_[1] = info[1] - previnfo_[1];
55  previnfo_[0] = info[0];
56  previnfo_[1] = info[1];
57 
58  if (total_ < fields_[0] + fields_[1])
59  total_ = fields_[0] + fields_[1];
60 
61  fields_[2] = total_ - fields_[0] - fields_[1];
63 }
virtual void drawfields(int mandatory=0)
virtual void checkResources(void)
double total_
Definition: fieldmeter.h:41
void setfieldcolor(int field, const char *color)
Definition: fieldmeter.cc:108
void setUsed(double val, double total)
Definition: fieldmeter.cc:76
double * fields_
Definition: fieldmeter.h:40
void SetUsedFormat(const char *const str)
Definition: fieldmeter.cc:60
int priority_
Definition: meter.h:54
XOSView * parent_
Definition: meter.h:52
~PageMeter(void)
Definition: pagemeter.cc:29
void getpageinfo(void)
Definition: pagemeter.cc:49
PageMeter(XOSView *parent, double total)
Definition: pagemeter.cc:22
void checkevent(void)
Definition: pagemeter.cc:44
void checkResources(void)
Definition: pagemeter.cc:32
uint64_t previnfo_[2]
Definition: pagemeter.h:36
int isResourceTrue(const char *name)
Definition: xwin.h:89
const char * getResource(const char *name)
Definition: xwin.cc:362
void BSDPageInit()
Definition: kernel.cc:294
void BSDGetPageStats(uint64_t *meminfo, uint64_t *pageinfo)
Definition: kernel.cc:301