"Fossies" - the Fresh Open Source Software Archive

Member "xosview-1.23/irix65/sarmeter.h" (11 Jul 2020, 1607 Bytes) of package /linux/misc/xosview-1.23.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "sarmeter.h" see the Fossies "Dox" file reference documentation.

    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 
   48     GfxInfo *getGfxInfo( void )
   49         {
   50             checkSadc();
   51             return &_gi.info;
   52         }
   53 
   54     DiskInfo *getDiskInfo( void )
   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 
   76     static SarMeter *_instance;
   77     int    _input;
   78     off_t  _bufSize;
   79     char   _buf[BUFSIZE];
   80 
   81     struct {
   82         gfxinfo current;
   83         gfxinfo last;
   84         GfxInfo info;
   85     } _gi;
   86 
   87     struct {
   88         diskinfo current[MAX_DISKS];
   89         diskinfo last[MAX_DISKS];
   90         DiskInfo info;
   91     } _di;
   92 };
   93 
   94 #endif