Skip to content
WJunction - Webmaster Forum

Linux system info ( C)

Status
Not open for further replies.
5bab0549.png



Compiled Binary ( compiled using gcc )

http://dl.dropbox.com/u/8626323/c/sysinfo

usage instructions :
Code:
wget [URL]http://dl.dropbox.com/u/8626323/c/sysinfo[/URL]
./sysinfo
source .. nothin complex :P

to compile

save the code to a file and call it sysinfo.c, then use gcc to compile it
gcc sysinfo.c


PHP:
#include <stdio.h>
#include <sys/sysinfo.h>
int main(){
int days, hours, mins;struct sysinfo wj_sysinfo;
if(sysinfo(&wj_sysinfo) != 0)perror("sysinfo");
days = wj_sysinfo.uptime / 86400;hours = (wj_sysinfo.uptime / 3600) - (days * 24);mins = (wj_sysinfo.uptime / 60) - (days * 1440) - (hours * 60);
printf("Wjunction linux Info\n");printf("Uptime: %ddays, %dhours, %dminutes, %ldseconds\n",days, hours, mins, wj_sysinfo.uptime % 60);
printf("Load Avgs: 1min(%ld) 5min(%ld) 15min(%ld)\n",wj_sysinfo.loads[0], wj_sysinfo.loads[1], wj_sysinfo.loads[2]);printf("Total Ram: %ldk\tFree: %ldk\n", wj_sysinfo.totalram / 1024,wj_sysinfo.freeram / 1024);
printf("Number of processes: %d\n", wj_sysinfo.procs);return 0;
}
 

6 comments

Status
Not open for further replies.

About the author

D
Active Member · Joined
coding in php and python
1,544
Messages
7
Reactions
38
Points

Advertise on WJunction

Reach 1000's of webmasters, hosts & affiliates. Banner & sponsored-thread slots available.

Contact us
Back
Top Bottom