memsensor.h

00001 /***************************************************************************
00002  *   Copyright (C) 2003 by Hans Karlsson                                   *
00003  *   karlsson.h@home.se                                                      *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  ***************************************************************************/
00010 #ifndef MEMSENSOR_H
00011 #define MEMSENSOR_H
00012 #include "sensor.h"
00013 #include <qglobal.h>
00014 #include <qstring.h>
00015 #include <qregexp.h>
00016 #include <kprocess.h>
00017 
00018 #ifdef __FreeBSD__
00019 #include <kprocio.h>
00020 #include <kvm.h>
00021 #include <osreldate.h>
00022 #endif
00023 
00024 class MemSensor :  public Sensor
00025 {
00026 Q_OBJECT
00027 public:
00028 
00029   MemSensor( int interval );
00030   ~MemSensor();
00031 
00032   int getMemTotal();
00033   int getMemFree();
00034   int getBuffers();
00035   int getCached();
00036 
00037   int getSwapTotal();
00038   int getSwapFree();
00039 
00040   void update();
00041   void setMaxValue( SensorParams *sp );
00042   QString getMemLine();
00043 
00044 private:
00045   QString meminfo;
00046   void readValues();
00047 #if defined __FreeBSD__ || defined(Q_OS_NETBSD)
00048   int pageshift;           /* log base 2 of the pagesize */
00049   QString sensorResult;
00050   int swapTotal;
00051   int swapUsed;
00052 # if (defined(__FreeBSD__) && __FreeBSD_version < 500018)
00053   KShellProcess ksp;
00054   bool MaxSet;
00055 
00056 # elif defined __FreeBSD__
00057   kvm_t *kd;
00058   kvm_swap swapinfo;
00059 # endif
00060 #endif
00061 
00062 private slots:
00063     void receivedStdout(KProcess *, char *buffer, int);
00064     void processExited(KProcess *);
00065 
00066 };
00067 
00068 #endif // MEMSENSOR_H
KDE Home | KDE Accessibility Home | Description of Access Keys