proc_utils.h
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef apmon_procutils_h
00040 #define apmon_procutils_h
00041
00042 #include <time.h>
00043 #include <stdexcept>
00044
00045 #ifndef WIN32
00046 #include <sys/wait.h>
00047 #endif
00048
00049 using namespace std;
00050
00056 class procutils_error : public runtime_error {
00057 public:
00058 procutils_error(char *msg) : runtime_error(msg) {}
00059 };
00060
00061
00062 class ProcUtils {
00063
00064 public:
00068 static void getCPUUsage(ApMon& apm, double& cpuUsage,
00069 double& cpuUsr, double& cpuSys,
00070 double& cpuNice, double& cpuIdle, int numCPUs)
00071 throw (runtime_error, procutils_error);
00072
00076 static void getSwapPages(ApMon& apm, double& pagesIn,
00077 double& pagesOut, double& swapIn,
00078 double& swapOut)
00079 throw (runtime_error, procutils_error);
00080
00086 static void getLoad(double& load1, double& load5, double& load15,
00087 double& processes) throw(procutils_error);
00088
00101 static void getProcesses(double& processes, double states[])
00102 throw(runtime_error);
00103
00108 static void getSysMem(double& totalMem, double& totalSwap)
00109 throw(procutils_error);
00110
00115 static void getMemUsed(double& usedMem, double&freeMem, double &usedSwap,
00116 double& freeSwap)
00117 throw(procutils_error);
00118
00126 static void getNetworkInterfaces(int &nInterfaces, char names[][20])
00127 throw(procutils_error);
00128
00141 static void getNetInfo(ApMon& apm, double **vNetIn, double **vNetOut,
00142 double **vNetErrs)
00143 throw(runtime_error, procutils_error);
00144
00152 static void getNetstatInfo(ApMon& apm, double nsockets[], double
00153 tcp_states[]) throw(runtime_error);
00154
00158 static int getNumCPUs() throw(procutils_error);
00159
00164 static void getCPUInfo(ApMon& apm) throw(procutils_error);
00165
00169 static long getBootTime() throw (procutils_error);
00170
00174 static double getUpTime() throw(procutils_error);
00175
00176
00181 static int countOpenFiles(long pid) throw(procutils_error);
00182 };
00183
00184 #endif