QString sysInfo::getMinimalStats(){
    netStat();
    cpuUsage();
    memPerc();
    bytesTransmitted = getSizeUnit(bytesTransmitted);
    bytesReceived = getSizeUnit(bytesReceived);
    //Sende the CPU usage %, the RAM usage %, the amount of transmitted data in the applicable unit, the amount of received data in the applicable unit
    QString stats = cpuPerc + "%" + "#" + memoryLoad + "%" + "#"+ bytesTransmitted + "#" + bytesReceived;
    return stats;
}
QString sysInfo::getDetailedStats(){
    cpuUsage();
    memPerc();
    netStat();
    cpuStats();
    getDiskDetails();
    osVersion();
    listProcesses();
    QString stats = "";
    bytesTransmitted = getSizeUnit(bytesTransmitted);
    bytesReceived = getSizeUnit(bytesReceived);
    //Add the netstat info to the stats string
    stats = stats + "Data Transmitted," + bytesTransmitted + "#Data Received," + bytesReceived + "#Packets Transmitted," + packetsTransmitted + "#Packets Received," + packetsReceived + "#Errors Transmitting," + transmitErrors + "#Errors Receiving," + receiveErrors;
    //Add the cpuStats to the stats string
    stats = stats + "#Number of Processors," + _cpuCount;
    //Add the OS Version
    stats = stats + "#Operating System," + osVers;
    //Add the various logical drive details
    for(int i = 0; i < filesystems.length(); i++){
        QString cap = capacitys.at(i);
        cap.chop(cap.length() - cap.indexOf("."));
        cap = getSizeUnit(cap);
        QString used = useds.at(i);
        used = getSizeUnit(used);
        stats = stats + "#Drive Label," + filesystems.at(i) + ",Total Capacity," + cap+ ",Used Space," + used;
    }
    //Add RAM and CPU
    physMem.chop(physMem.length()- physMem.indexOf("."));
    physMem = getSizeUnit(physMem);
    freePhysMem.chop(freePhysMem.length() - freePhysMem.indexOf("."));
    freePhysMem = getSizeUnit(freePhysMem);
    stats = stats + "#Total RAM,"+physMem+"#Used RAM,"+freePhysMem+"#% RAM in use,"+memoryLoad+"#% CPU in use,"+cpuPerc;
    //Add the process/task related info
    stats = stats + "#Amount of Processes active," + procCount;
    for(int j = 0; j < procIDs.length(); j++){
        stats = stats + "#" + procIDs.at(j) + "," + procNames.at(j);
    }
    return stats;
}
Esempio n. 3
0
void getDisk() {
    struct statvfs root;
    statvfs("/", &root);
    remaining = root.f_bfree * root.f_bsize;
    getSizeUnit();
}