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)  

sarmeter.h
Go to the documentation of this file.
1 //
2 // Initial port performed by Stefan Eilemann (eilemann@gmail.com)
3 //
4 
5 #ifndef _SARMETER_H_
6 #define _SARMETER_H_
7 
8 #include "fieldmetergraph.h"
9 #include <unistd.h>
10 #include <sys/sysinfo.h>
11 #include <sys/elog.h>
12 
13 // some structs
14 typedef struct {
15  unsigned int recsize;
16  unsigned int numrec;
17 }
18 header;
19 
20 typedef struct {
21  char name[12];
22  char pad1[68];
23  struct iotime stat;
24  char pad2[4];
25 }
26 diskinfo;
27 
28 #define MAX_DISKS 16
29 #define BUFSIZE 0x2000
30 
31 // common function for all sar based graphs
32 class SarMeter
33 {
34 public:
35  static SarMeter *Instance();
36 
37  struct GfxInfo {
38  unsigned int swapBuf;
39  };
40 
41  struct DiskInfo {
42  unsigned int nDevices;
43 
44  unsigned int read[MAX_DISKS];
45  unsigned int write[MAX_DISKS];
46  };
47 
49  {
50  checkSadc();
51  return &_gi.info;
52  }
53 
55  {
56  checkSadc();
57  return &_di.info;
58  }
59 
60 private:
61  SarMeter();
62  ~SarMeter(void) {}
63 
64  int setupSadc( void );
65 
66  void checkSadc( void );
67 
68  bool readLine( void );
69  void parseBuffer( void );
70  void forwardBufferTo( char *ptr );
71 
72  void newGfxInfo( void );
73  void newDiskInfo( void );
74 
75 
77  int _input;
78  off_t _bufSize;
79  char _buf[BUFSIZE];
80 
81  struct {
82  gfxinfo current;
83  gfxinfo last;
85  } _gi;
86 
87  struct {
91  } _di;
92 };
93 
94 #endif
off_t _bufSize
Definition: sarmeter.h:78
gfxinfo last
Definition: sarmeter.h:83
SarMeter()
Definition: sarmeter.cc:19
void forwardBufferTo(char *ptr)
Definition: sarmeter.cc:170
DiskInfo info
Definition: sarmeter.h:90
void newGfxInfo(void)
Definition: sarmeter.cc:139
static SarMeter * _instance
Definition: sarmeter.h:76
int setupSadc(void)
Definition: sarmeter.cc:180
void parseBuffer(void)
Definition: sarmeter.cc:68
static SarMeter * Instance()
Definition: sarmeter.cc:11
GfxInfo * getGfxInfo(void)
Definition: sarmeter.h:48
struct SarMeter::@1 _di
~SarMeter(void)
Definition: sarmeter.h:62
void checkSadc(void)
Definition: sarmeter.cc:57
int _input
Definition: sarmeter.h:77
void newDiskInfo(void)
Definition: sarmeter.cc:151
char _buf[0x2000]
Definition: sarmeter.h:79
bool readLine(void)
Definition: sarmeter.cc:38
GfxInfo info
Definition: sarmeter.h:84
gfxinfo current
Definition: sarmeter.h:82
DiskInfo * getDiskInfo(void)
Definition: sarmeter.h:54
struct SarMeter::@0 _gi
#define MAX_DISKS
Definition: sarmeter.h:28
#define BUFSIZE
Definition: sarmeter.h:29
unsigned int nDevices
Definition: sarmeter.h:42
unsigned int read[16]
Definition: sarmeter.h:44
unsigned int write[16]
Definition: sarmeter.h:45
unsigned int swapBuf
Definition: sarmeter.h:38
unsigned int recsize
Definition: sarmeter.h:15
unsigned int numrec
Definition: sarmeter.h:16