Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
1dd165c1
Commit
1dd165c1
authored
Nov 27, 2014
by
Hisham Muhammad
Browse files
Merge branch 'master' into freebsd
parents
a9f05c2a
ca03094b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Makefile.am
View file @
1dd165c1
...
...
@@ -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
...
...
linux/
UptimeMeter.c
→
UptimeMeter.c
View file @
1dd165c1
...
...
@@ -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
;
...
...
linux/
UptimeMeter.h
→
UptimeMeter.h
View file @
1dd165c1
File moved
linux/Platform.c
View file @
1dd165c1
...
...
@@ -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
);
}
unsupported/Platform.c
View file @
1dd165c1
...
...
@@ -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
;
}
unsupported/Platform.h
View file @
1dd165c1
...
...
@@ -15,5 +15,6 @@ void Platform_setBindings(Htop_Action* keys);
extern
MeterClass
*
Platform_meterTypes
[];
int
Platform_getUptime
();
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment