Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Static Public Member Functions | Private Attributes
Paul::SysInfo Class Reference

#include <sysinfo.h>

Collaboration diagram for Paul::SysInfo:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 SysInfo (void)
void refresh (void)
const std::string & getOSName (void)
const std::string & getOSFamily (void)
const std::string & getOSVersion (void)
const std::string & getPlatform (void)
unsigned int getPhysicalCPUs (void)
unsigned int getLogicalCPUs (void)
unsigned int getMainMemorySize (void)
unsigned int getVirtualMemorySize (void)

Static Public Member Functions

static unsigned int diskAvailable (const std::string &path)
static unsigned int diskFree (const std::string &path)
static unsigned int diskTotal (const std::string &path)

Private Attributes

std::string osFamily
std::string osName
std::string osVersion
std::string platform
unsigned int physicalCPUs
unsigned int logicalCPUs
unsigned int mainMemorySize
unsigned int virtualMemorySize

Detailed Description

Definition at line 9 of file sysinfo.h.


Constructor & Destructor Documentation

Definition at line 25 of file sysinfo.cpp.

{
    struct utsname u;
    if (uname(&u) == 0) {
        if (strcmp(u.sysname, "Linux") == 0) {
            osFamily = "linux";
        } else {
            osFamily = "unknown";
        }
        osName = "generallinux";
        osVersion = u.version;
    }
    
    std::ifstream p("/proc/cpuinfo");
    std::string s;
    unsigned int p_num = 0;
    while (getline(p, s)) {
        // found processor line
        if (s.find("processor", 0) != std::string::npos) {
            p_num++;
        }
        if ((s.find("vendor_id", 0) != std::string::npos) && platform.empty()) {
            std::vector<std::string> t;
            Arc::tokenize(s, t, ":");
            std::string p = Arc::trim(t[1]);
            if (p == "GenuineIntel") {
                platform = "i386";
            } else if (p == "AMD64") { // XXX not sure
                platform = "amd64";
            } else {
                platform = "unknown";
            }
        }
    }
    p.close();
    physicalCPUs = p_num;
    logicalCPUs = p_num;

    std::ifstream m("/proc/meminfo");
    unsigned int swap_size = 0;
    while (getline(m, s)) {
        if (s.find("MemTotal:") != std::string::npos) {
            std::vector<std::string> t;
            Arc::tokenize(s, t, ":");
            std::string size = Arc::trim(t[1]);
            mainMemorySize = Arc::stringtoui(size)/1024;
        }
        if (s.find("SwapTotal:") != std::string::npos) {
            std::vector<std::string> t;
            Arc::tokenize(s, t, ":");
            std::string size = Arc::trim(t[1]);
            swap_size = Arc::stringtoui(size);
        }
    }
    virtualMemorySize = (mainMemorySize + swap_size)/1024;
    m.close();
}

Here is the call graph for this function:


Member Function Documentation

unsigned int Paul::SysInfo::diskAvailable ( const std::string &  path) [static]

Definition at line 83 of file sysinfo.cpp.

{
    struct fs_usage fsu;
    int ret;
    ret = get_fs_usage(path.c_str(), NULL, &fsu);
    if (ret == 0) {
        return (fsu.fsu_blocksize * fsu.fsu_bavail)/(1024*1024);
    }
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int Paul::SysInfo::diskFree ( const std::string &  path) [static]

Definition at line 105 of file sysinfo.cpp.

{
    struct fs_usage fsu;
    int ret;
    ret = get_fs_usage(path.c_str(), NULL, &fsu);
    if (ret == 0) {
        return (fsu.fsu_blocksize * fsu.fsu_bfree)/(1024*1024);
    }
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int Paul::SysInfo::diskTotal ( const std::string &  path) [static]

Definition at line 94 of file sysinfo.cpp.

{
    struct fs_usage fsu;
    int ret;
    ret = get_fs_usage(path.c_str(), NULL, &fsu);
    if (ret == 0) {
        return (fsu.fsu_blocksize * fsu.fsu_blocks)/(1024*1024);
    }
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int Paul::SysInfo::getLogicalCPUs ( void  ) [inline]

Definition at line 29 of file sysinfo.h.

{ return logicalCPUs; };

Here is the caller graph for this function:

unsigned int Paul::SysInfo::getMainMemorySize ( void  ) [inline]

Definition at line 30 of file sysinfo.h.

{ return mainMemorySize; };

Here is the caller graph for this function:

const std::string& Paul::SysInfo::getOSFamily ( void  ) [inline]

Definition at line 25 of file sysinfo.h.

{ return osFamily; };

Here is the caller graph for this function:

const std::string& Paul::SysInfo::getOSName ( void  ) [inline]

Definition at line 24 of file sysinfo.h.

{ return osName; };

Here is the caller graph for this function:

const std::string& Paul::SysInfo::getOSVersion ( void  ) [inline]

Definition at line 26 of file sysinfo.h.

{ return osVersion; };

Here is the caller graph for this function:

unsigned int Paul::SysInfo::getPhysicalCPUs ( void  ) [inline]

Definition at line 28 of file sysinfo.h.

{ return physicalCPUs; };

Here is the caller graph for this function:

const std::string& Paul::SysInfo::getPlatform ( void  ) [inline]

Definition at line 27 of file sysinfo.h.

{ return platform; };

Here is the caller graph for this function:

unsigned int Paul::SysInfo::getVirtualMemorySize ( void  ) [inline]

Definition at line 31 of file sysinfo.h.

{ return virtualMemorySize; };

Here is the caller graph for this function:

void Paul::SysInfo::refresh ( void  )

Definition at line 116 of file sysinfo.cpp.

{
    // NOP
}

Here is the caller graph for this function:


Member Data Documentation

unsigned int Paul::SysInfo::logicalCPUs [private]

Definition at line 18 of file sysinfo.h.

unsigned int Paul::SysInfo::mainMemorySize [private]

Definition at line 19 of file sysinfo.h.

std::string Paul::SysInfo::osFamily [private]

Definition at line 13 of file sysinfo.h.

std::string Paul::SysInfo::osName [private]

Definition at line 14 of file sysinfo.h.

std::string Paul::SysInfo::osVersion [private]

Definition at line 15 of file sysinfo.h.

unsigned int Paul::SysInfo::physicalCPUs [private]

Definition at line 17 of file sysinfo.h.

std::string Paul::SysInfo::platform [private]

Definition at line 16 of file sysinfo.h.

unsigned int Paul::SysInfo::virtualMemorySize [private]

Definition at line 20 of file sysinfo.h.


The documentation for this class was generated from the following files: