| # Gaudi Framework, version v21r11 |

Home |  | Generated: 30 Sep 2010

# proc_utils.h

Go to the documentation of this file.

    00001
    00007 /*
    00008  * ApMon - Application Monitoring Tool
    00009  * Version: 2.2.0
    00010  *
    00011  * Copyright (C) 2006 California Institute of Technology
    00012  *
    00013  * Permission is hereby granted, free of charge, to use, copy and modify
    00014  * this software and its documentation (the "Software") for any
    00015  * purpose, provided that existing copyright notices are retained in
    00016  * all copies and that this notice is included verbatim in any distributions
    00017  * or substantial portions of the Software.
    00018  * This software is a part of the MonALISA framework (http://monalisa.cacr.caltech.edu).
    00019  * Users of the Software are asked to feed back problems, benefits,
    00020  * and/or suggestions about the software to the MonALISA Development Team
    00021  * (developers@monalisa.cern.ch). Support for this software - fixing of bugs,
    00022  * incorporation of new features - is done on a best effort basis. All bug
    00023  * fixes and enhancements will be made available under the same terms and
    00024  * conditions as the original software,
    00025
    00026  * IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
    00027  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
    00028  * OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
    00029  * EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    00030
    00031  * THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
    00032  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
    00033  * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS
    00034  * PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO
    00035  * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
    00036  * MODIFICATIONS.
    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