added uptime function
This commit is contained in:

committed by
Aaron Marcher (drkhsh)

parent
83c98554ed
commit
85a2b9b79d
18
slstatus.c
18
slstatus.c
@ -18,6 +18,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/statvfs.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
@ -521,6 +522,23 @@ temp(const char *file)
|
||||
return smprintf("%d°C", temperature / 1000);
|
||||
}
|
||||
|
||||
/* uptime */
|
||||
char *
|
||||
uptime(const char *null)
|
||||
{
|
||||
struct sysinfo info;
|
||||
int hours = 0;
|
||||
int minutes = 0;
|
||||
|
||||
/* get info */
|
||||
sysinfo(&info);
|
||||
hours = info.uptime / 3600;
|
||||
minutes = (info.uptime - hours * 3600 ) / 60;
|
||||
|
||||
/* return it */
|
||||
return smprintf("%dh %dm", hours, minutes);
|
||||
}
|
||||
|
||||
/* username */
|
||||
char *
|
||||
username(const char *null)
|
||||
|
Reference in New Issue
Block a user