From 2bb476d52448ddc0833667feb126d7e6f2342b2d Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 10 Jun 2015 15:32:29 -0400 Subject: Add a new function to LuminaOS: DiskUsage() This returns the current stats about the available disks on the system (current read/write rates on FreeBSD - not implemented on other OS's yet). Also use this new function in the systemmonitor desktop plugin. --- libLumina/LuminaOS-Debian.cpp | 3 ++ libLumina/LuminaOS-DragonFly.cpp | 3 ++ libLumina/LuminaOS-FreeBSD.cpp | 21 ++++++++ libLumina/LuminaOS-Linux.cpp | 4 ++ libLumina/LuminaOS-OpenBSD.cpp | 4 ++ libLumina/LuminaOS-kFreeBSD.cpp | 3 ++ libLumina/LuminaOS-template.cpp | 3 ++ libLumina/LuminaOS.h | 3 +- .../systemmonitor/MonitorWidget.cpp | 6 ++- .../desktop-plugins/systemmonitor/MonitorWidget.ui | 60 +++++++++++++++++++--- 10 files changed, 99 insertions(+), 11 deletions(-) diff --git a/libLumina/LuminaOS-Debian.cpp b/libLumina/LuminaOS-Debian.cpp index d1d5d344..82374fed 100644 --- a/libLumina/LuminaOS-Debian.cpp +++ b/libLumina/LuminaOS-Debian.cpp @@ -269,4 +269,7 @@ int LOS::MemoryUsagePercent(){ return qRound(per); } +QStringList LOS::DiskUsage(){ //Returns: List of current read/write stats for each device + return QStringList(); //not implemented yet +} #endif diff --git a/libLumina/LuminaOS-DragonFly.cpp b/libLumina/LuminaOS-DragonFly.cpp index dde24d0c..79f84e65 100644 --- a/libLumina/LuminaOS-DragonFly.cpp +++ b/libLumina/LuminaOS-DragonFly.cpp @@ -207,4 +207,7 @@ int LOS::MemoryUsagePercent(){ return -1; //not implemented yet } +QStringList LOS::DiskUsage(){ //Returns: List of current read/write stats for each device + return QStringList(); //not implemented yet +} #endif diff --git a/libLumina/LuminaOS-FreeBSD.cpp b/libLumina/LuminaOS-FreeBSD.cpp index ae394f38..fe001ab2 100644 --- a/libLumina/LuminaOS-FreeBSD.cpp +++ b/libLumina/LuminaOS-FreeBSD.cpp @@ -325,4 +325,25 @@ int LOS::MemoryUsagePercent(){ return qRound(perc); } +QStringList LOS::DiskUsage(){ //Returns: List of current read/write stats for each device + QStringList info = LUtils::getCmdOutput("iostat -dx -t IDE -t SCSI -t da"); + if(info.length()<3){ return QStringList(); } //nothing from command + QStringList labs = info[1].split(" ",QString::SkipEmptyParts); + QStringList out; + QString fmt = "%1: %2 %3"; + for(int i=2; i2 && labs.length()>2){ + out << fmt.arg(data[0], data[1]+" "+labs[1], data[2]+" "+labs[2]); + } + } + } + + return out; +} + #endif diff --git a/libLumina/LuminaOS-Linux.cpp b/libLumina/LuminaOS-Linux.cpp index 2368f773..ebf49a08 100644 --- a/libLumina/LuminaOS-Linux.cpp +++ b/libLumina/LuminaOS-Linux.cpp @@ -235,4 +235,8 @@ int LOS::MemoryUsagePercent(){ return -1; //not implemented yet } +QStringList LOS::DiskUsage(){ //Returns: List of current read/write stats for each device + return QStringList(); //not implemented yet +} + #endif diff --git a/libLumina/LuminaOS-OpenBSD.cpp b/libLumina/LuminaOS-OpenBSD.cpp index 10bb4e15..f33fed97 100644 --- a/libLumina/LuminaOS-OpenBSD.cpp +++ b/libLumina/LuminaOS-OpenBSD.cpp @@ -244,4 +244,8 @@ int LOS::MemoryUsagePercent(){ return -1; //not implemented yet } +QStringList LOS::DiskUsage(){ //Returns: List of current read/write stats for each device + return QStringList(); //not implemented yet +} + #endif diff --git a/libLumina/LuminaOS-kFreeBSD.cpp b/libLumina/LuminaOS-kFreeBSD.cpp index 8954d685..91de843c 100644 --- a/libLumina/LuminaOS-kFreeBSD.cpp +++ b/libLumina/LuminaOS-kFreeBSD.cpp @@ -185,5 +185,8 @@ int LOS::MemoryUsagePercent(){ return -1; //not implemented yet } +QStringList LOS::DiskUsage(){ //Returns: List of current read/write stats for each device + return QStringList(); //not implemented yet +} #endif #endif diff --git a/libLumina/LuminaOS-template.cpp b/libLumina/LuminaOS-template.cpp index eb233913..298f9ddd 100644 --- a/libLumina/LuminaOS-template.cpp +++ b/libLumina/LuminaOS-template.cpp @@ -133,4 +133,7 @@ int LOS::MemoryUsagePercent(){ return -1; //not implemented yet } +QStringList LOS::DiskUsage(){ //Returns: List of current read/write stats for each device + return QStringList(); //not implemented yet +} #endif diff --git a/libLumina/LuminaOS.h b/libLumina/LuminaOS.h index 738be5e4..2780c80c 100644 --- a/libLumina/LuminaOS.h +++ b/libLumina/LuminaOS.h @@ -1,6 +1,6 @@ //=========================================== // Lumina-DE source code -// Copyright (c) 2014, Ken Moore +// Copyright (c) 2014-15, Ken Moore // Available under the 3-clause BSD license // See the LICENSE file for full details //=========================================== @@ -96,6 +96,7 @@ public: static QStringList CPUTemperatures(); //Returns: List containing the temperature of any CPU's ("50C" for example) static int CPUUsagePercent(); //Returns: Overall percentage of the amount of CPU cycles in use (-1 for errors) static int MemoryUsagePercent(); //Returns: Overall percentage of the amount of available memory in use (-1 for errors) + static QStringList DiskUsage(); //Returns: List of current read/write stats for each device }; #endif diff --git a/lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.cpp b/lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.cpp index f5bff7b3..0d568a45 100644 --- a/lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.cpp +++ b/lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.cpp @@ -26,8 +26,9 @@ MonitorWidget::~MonitorWidget(){ void MonitorWidget::LoadIcons(){ ui->tabWidget->setTabIcon(0,LXDG::findIcon("appointment-recurring","") ); //Summary - ui->tabWidget->setTabIcon(1,LXDG::findIcon("cpu","") ); //CPU Log - ui->tabWidget->setTabIcon(2,LXDG::findIcon("media-flash-memory-stick","") ); //Mem Log + ui->tabWidget->setTabIcon(1,LXDG::findIcon("drive-harddisk","") ); //Disk Usage + //ui->tabWidget->setTabIcon(1,LXDG::findIcon("cpu","") ); //CPU Log + //ui->tabWidget->setTabIcon(2,LXDG::findIcon("media-flash-memory-stick","") ); //Mem Log } void MonitorWidget::UpdateStats(){ @@ -43,6 +44,7 @@ void MonitorWidget::UpdateStats(){ ui->progress_mem->setValue(perc); if(perc<0){ ui->progress_mem->setEnabled(false); } //disable this for future checks } + ui->label_diskinfo->setText( LOS::DiskUsage().join("\n") ); //Also perform/update the logs as necessary // -- TO DO -- } diff --git a/lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.ui b/lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.ui index c3a58017..0c1fd500 100644 --- a/lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.ui +++ b/lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.ui @@ -31,7 +31,7 @@ 0 - + Summary @@ -80,15 +80,59 @@ - + - CPU Log - - - - - Memory Log + Disk Usage + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::NoFrame + + + true + + + + + 0 + 0 + 292 + 90 + + + + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + + -- cgit