mirror of https://github.com/xzeldon/htop.git
Merge branch 'master' into freebsd
This commit is contained in:
commit
1dd165c14b
10
Makefile.am
10
Makefile.am
|
@ -20,7 +20,7 @@ ClockMeter.c ColorsPanel.c ColumnsPanel.c CPUMeter.c CRT.c \
|
|||
DisplayOptionsPanel.c FunctionBar.c Hashtable.c Header.c htop.c ListItem.c \
|
||||
LoadAverageMeter.c MemoryMeter.c Meter.c MetersPanel.c Object.c Panel.c \
|
||||
BatteryMeter.c Process.c ProcessList.c RichString.c ScreenManager.c Settings.c \
|
||||
SignalsPanel.c String.c SwapMeter.c TasksMeter.c TraceScreen.c \
|
||||
SignalsPanel.c String.c SwapMeter.c TasksMeter.c UptimeMeter.c TraceScreen.c \
|
||||
UsersTable.c Vector.c AvailableColumnsPanel.c AffinityPanel.c \
|
||||
HostnameMeter.c OpenFilesScreen.c Affinity.c IncSet.c Action.c
|
||||
|
||||
|
@ -30,17 +30,15 @@ CPUMeter.h CRT.h DisplayOptionsPanel.h FunctionBar.h \
|
|||
Hashtable.h Header.h htop.h ListItem.h LoadAverageMeter.h MemoryMeter.h \
|
||||
BatteryMeter.h Meter.h MetersPanel.h Object.h Panel.h ProcessList.h RichString.h \
|
||||
ScreenManager.h Settings.h SignalsPanel.h String.h SwapMeter.h TasksMeter.h \
|
||||
TraceScreen.h UsersTable.h Vector.h Process.h AffinityPanel.h \
|
||||
UptimeMeter.h TraceScreen.h UsersTable.h Vector.h Process.h AffinityPanel.h \
|
||||
HostnameMeter.h OpenFilesScreen.h Affinity.h IncSet.h Action.h
|
||||
|
||||
if HTOP_LINUX
|
||||
myhtopplatsources = linux/Platform.c linux/IOPriorityPanel.c linux/IOPriority.c \
|
||||
linux/LinuxProcess.c linux/LinuxProcessList.c linux/LinuxCRT.c \
|
||||
linux/UptimeMeter.c
|
||||
linux/LinuxProcess.c linux/LinuxProcessList.c linux/LinuxCRT.c
|
||||
|
||||
myhtopplatheaders = linux/Platform.h linux/IOPriorityPanel.h linux/IOPriority.h \
|
||||
linux/LinuxProcess.h linux/LinuxProcessList.h linux/LinuxCRT.h \
|
||||
linux/UptimeMeter.h
|
||||
linux/LinuxProcess.h linux/LinuxProcessList.h linux/LinuxCRT.h
|
||||
endif
|
||||
|
||||
if HTOP_FREEBSD
|
||||
|
|
|
@ -6,12 +6,9 @@ in the source distribution for its full text.
|
|||
*/
|
||||
|
||||
#include "UptimeMeter.h"
|
||||
|
||||
#include "ProcessList.h"
|
||||
#include "Platform.h"
|
||||
#include "CRT.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
/*{
|
||||
#include "Meter.h"
|
||||
}*/
|
||||
|
@ -21,13 +18,11 @@ int UptimeMeter_attributes[] = {
|
|||
};
|
||||
|
||||
static void UptimeMeter_setValues(Meter* this, char* buffer, int len) {
|
||||
double uptime = 0;
|
||||
FILE* fd = fopen(PROCDIR "/uptime", "r");
|
||||
if (fd) {
|
||||
fscanf(fd, "%64lf", &uptime);
|
||||
fclose(fd);
|
||||
int totalseconds = Platform_getUptime();
|
||||
if (totalseconds == -1) {
|
||||
snprintf(buffer, len, "(unknown)");
|
||||
return;
|
||||
}
|
||||
int totalseconds = (int) ceil(uptime);
|
||||
int seconds = totalseconds % 60;
|
||||
int minutes = (totalseconds/60) % 60;
|
||||
int hours = (totalseconds/3600) % 24;
|
|
@ -20,6 +20,8 @@ in the source distribution for its full text.
|
|||
#include "ClockMeter.h"
|
||||
#include "HostnameMeter.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
/*{
|
||||
#include "Action.h"
|
||||
}*/
|
||||
|
@ -67,3 +69,12 @@ MeterClass* Platform_meterTypes[] = {
|
|||
NULL
|
||||
};
|
||||
|
||||
int Platform_getUptime() {
|
||||
double uptime = 0;
|
||||
FILE* fd = fopen(PROCDIR "/uptime", "r");
|
||||
if (fd) {
|
||||
fscanf(fd, "%64lf", &uptime);
|
||||
fclose(fd);
|
||||
}
|
||||
int totalseconds = (int) floor(uptime);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ in the source distribution for its full text.
|
|||
#include "BatteryMeter.h"
|
||||
#include "ClockMeter.h"
|
||||
#include "HostnameMeter.h"
|
||||
#include "UptimeMeter.h"
|
||||
|
||||
/*{
|
||||
#include "Action.h"
|
||||
|
@ -33,6 +34,7 @@ MeterClass* Platform_meterTypes[] = {
|
|||
&TasksMeter_class,
|
||||
&BatteryMeter_class,
|
||||
&HostnameMeter_class,
|
||||
&UptimeMeter_class,
|
||||
&AllCPUsMeter_class,
|
||||
&AllCPUs2Meter_class,
|
||||
&LeftCPUsMeter_class,
|
||||
|
@ -43,3 +45,6 @@ MeterClass* Platform_meterTypes[] = {
|
|||
NULL
|
||||
};
|
||||
|
||||
int Platform_getUptime() {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -15,5 +15,6 @@ void Platform_setBindings(Htop_Action* keys);
|
|||
|
||||
extern MeterClass* Platform_meterTypes[];
|
||||
|
||||
int Platform_getUptime();
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue