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 \
|
DisplayOptionsPanel.c FunctionBar.c Hashtable.c Header.c htop.c ListItem.c \
|
||||||
LoadAverageMeter.c MemoryMeter.c Meter.c MetersPanel.c Object.c Panel.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 \
|
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 \
|
UsersTable.c Vector.c AvailableColumnsPanel.c AffinityPanel.c \
|
||||||
HostnameMeter.c OpenFilesScreen.c Affinity.c IncSet.c Action.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 \
|
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 \
|
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 \
|
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
|
HostnameMeter.h OpenFilesScreen.h Affinity.h IncSet.h Action.h
|
||||||
|
|
||||||
if HTOP_LINUX
|
if HTOP_LINUX
|
||||||
myhtopplatsources = linux/Platform.c linux/IOPriorityPanel.c linux/IOPriority.c \
|
myhtopplatsources = linux/Platform.c linux/IOPriorityPanel.c linux/IOPriority.c \
|
||||||
linux/LinuxProcess.c linux/LinuxProcessList.c linux/LinuxCRT.c \
|
linux/LinuxProcess.c linux/LinuxProcessList.c linux/LinuxCRT.c
|
||||||
linux/UptimeMeter.c
|
|
||||||
|
|
||||||
myhtopplatheaders = linux/Platform.h linux/IOPriorityPanel.h linux/IOPriority.h \
|
myhtopplatheaders = linux/Platform.h linux/IOPriorityPanel.h linux/IOPriority.h \
|
||||||
linux/LinuxProcess.h linux/LinuxProcessList.h linux/LinuxCRT.h \
|
linux/LinuxProcess.h linux/LinuxProcessList.h linux/LinuxCRT.h
|
||||||
linux/UptimeMeter.h
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if HTOP_FREEBSD
|
if HTOP_FREEBSD
|
||||||
|
|
|
@ -6,12 +6,9 @@ in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "UptimeMeter.h"
|
#include "UptimeMeter.h"
|
||||||
|
#include "Platform.h"
|
||||||
#include "ProcessList.h"
|
|
||||||
#include "CRT.h"
|
#include "CRT.h"
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
/*{
|
/*{
|
||||||
#include "Meter.h"
|
#include "Meter.h"
|
||||||
}*/
|
}*/
|
||||||
|
@ -21,13 +18,11 @@ int UptimeMeter_attributes[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static void UptimeMeter_setValues(Meter* this, char* buffer, int len) {
|
static void UptimeMeter_setValues(Meter* this, char* buffer, int len) {
|
||||||
double uptime = 0;
|
int totalseconds = Platform_getUptime();
|
||||||
FILE* fd = fopen(PROCDIR "/uptime", "r");
|
if (totalseconds == -1) {
|
||||||
if (fd) {
|
snprintf(buffer, len, "(unknown)");
|
||||||
fscanf(fd, "%64lf", &uptime);
|
return;
|
||||||
fclose(fd);
|
|
||||||
}
|
}
|
||||||
int totalseconds = (int) ceil(uptime);
|
|
||||||
int seconds = totalseconds % 60;
|
int seconds = totalseconds % 60;
|
||||||
int minutes = (totalseconds/60) % 60;
|
int minutes = (totalseconds/60) % 60;
|
||||||
int hours = (totalseconds/3600) % 24;
|
int hours = (totalseconds/3600) % 24;
|
|
@ -20,6 +20,8 @@ in the source distribution for its full text.
|
||||||
#include "ClockMeter.h"
|
#include "ClockMeter.h"
|
||||||
#include "HostnameMeter.h"
|
#include "HostnameMeter.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
/*{
|
/*{
|
||||||
#include "Action.h"
|
#include "Action.h"
|
||||||
}*/
|
}*/
|
||||||
|
@ -67,3 +69,12 @@ MeterClass* Platform_meterTypes[] = {
|
||||||
NULL
|
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 "BatteryMeter.h"
|
||||||
#include "ClockMeter.h"
|
#include "ClockMeter.h"
|
||||||
#include "HostnameMeter.h"
|
#include "HostnameMeter.h"
|
||||||
|
#include "UptimeMeter.h"
|
||||||
|
|
||||||
/*{
|
/*{
|
||||||
#include "Action.h"
|
#include "Action.h"
|
||||||
|
@ -33,6 +34,7 @@ MeterClass* Platform_meterTypes[] = {
|
||||||
&TasksMeter_class,
|
&TasksMeter_class,
|
||||||
&BatteryMeter_class,
|
&BatteryMeter_class,
|
||||||
&HostnameMeter_class,
|
&HostnameMeter_class,
|
||||||
|
&UptimeMeter_class,
|
||||||
&AllCPUsMeter_class,
|
&AllCPUsMeter_class,
|
||||||
&AllCPUs2Meter_class,
|
&AllCPUs2Meter_class,
|
||||||
&LeftCPUsMeter_class,
|
&LeftCPUsMeter_class,
|
||||||
|
@ -43,3 +45,6 @@ MeterClass* Platform_meterTypes[] = {
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int Platform_getUptime() {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
|
@ -15,5 +15,6 @@ void Platform_setBindings(Htop_Action* keys);
|
||||||
|
|
||||||
extern MeterClass* Platform_meterTypes[];
|
extern MeterClass* Platform_meterTypes[];
|
||||||
|
|
||||||
|
int Platform_getUptime();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue