-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
inex-usage - Print Total Ram Used ram Total Swap Used Swap Number of processes Example: { "UPTIME_DAYS": 0 , "UPTIME_HOURS": 0 , "UPTIME_MINUTES": 56 , "UPTIME_SECONDS": 34 , "LOAD_AVG_1MIN": 10816 , "LOAD_AVG_5MIN": 19520 , "LOAD_AVG_15MIN": 18592 , "TOTAL_RAM": 2034244 , "FREE_RAM": 416428 , "SHARED_RAM": 0 , "BUFFERED_RAM": 85244 , "TOTAL_RAM_UNIT": 2034244 , "FREE_RAM_UNIT": 416428 , "TOTAL_SWAP": 2147324 , "FREE_SWAP": 2147324 , "TOTAL_HIGH": 0 , "NUMBER_OF_PROCESSES": 329 }
- Loading branch information
Showing
5 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.TH inex\-edid "1" | ||
.SH NAME | ||
\fBinex\-usage\fP \- Print Total Ram, Used ram, Total Swap, Used Swap, Number of processes. | ||
.SH SYNOPSIS | ||
usage: \- inex\-usage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include <sys/sysinfo.h> | ||
#include <stdio.h> | ||
|
||
int main() { | ||
int days, hours, mins; | ||
struct sysinfo sys_info; | ||
if(sysinfo(&sys_info) != 0) | ||
perror("sysinfo"); | ||
|
||
days = sys_info.uptime / 86400; | ||
hours = (sys_info.uptime / 3600) - (days * 24); | ||
mins = (sys_info.uptime / 60) - (days * 1440) - (hours * 60); | ||
|
||
printf("{\n"); // | ||
printf(" \"UPTIME_DAYS\": %d ,\n", days); // | ||
printf(" \"UPTIME_HOURS\": %d ,\n", hours); // | ||
printf(" \"UPTIME_MINUTES\": %d ,\n", mins); // | ||
printf(" \"UPTIME_SECONDS\": %ld ,\n", sys_info.uptime % 60); // | ||
printf(" \"LOAD_AVG_1MIN\": %ld ,\n", sys_info.loads[0]); // | ||
printf(" \"LOAD_AVG_5MIN\": %ld ,\n", sys_info.loads[1]); // | ||
printf(" \"LOAD_AVG_15MIN\": %ld ,\n", sys_info.loads[2]); // | ||
printf(" \"TOTAL_RAM\": %ld ,\n", sys_info.totalram / 1024); // | ||
printf(" \"FREE_RAM\": %ld ,\n", sys_info.freeram / 1024); // | ||
printf(" \"SHARED_RAM\": %ld ,\n", sys_info.sharedram / 1024); // | ||
printf(" \"BUFFERED_RAM\": %ld ,\n", sys_info.bufferram / 1024); // | ||
printf(" \"TOTAL_RAM_UNIT\": %llu ,\n", sys_info.totalram *(unsigned long long)sys_info.mem_unit / 1024); // | ||
printf(" \"FREE_RAM_UNIT\": %llu ,\n", sys_info.freeram *(unsigned long long)sys_info.mem_unit/ 1024); // | ||
printf(" \"TOTAL_SWAP\": %ld ,\n", sys_info.totalswap / 1024); // | ||
printf(" \"FREE_SWAP\": %ld ,\n", sys_info.freeswap / 1024); // | ||
printf(" \"TOTAL_HIGH\": %ld ,\n", sys_info.totalhigh / 1024); // | ||
printf(" \"NUMBER_OF_PROCESSES\": %d \n", sys_info.procs); // | ||
printf("}\n"); // | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters