Skip to content

Commit

Permalink
Add getusage.c as inex-usage:
Browse files Browse the repository at this point in the history
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
eloaders committed Jan 20, 2014
1 parent 6948703 commit 61ecb31
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ dependency_build ?= git \
make:
@printf "\033[1;31mCompile edid-decode as inex-decode \033[0m$1\n"
$(CC) -o inex-edid edid-decode.c $(CFLAGS) $(additional_confflags)
$(CC) -o inex-usage getusage.c $(CFLAGS) $(additional_confflags)
$(CC) -o inex-cpuid cpu.c -static $(CC_OPTS_LIBCPUID) $(additional_confflags)
@printf "\033[1;31mCompile src/i-nex stage 1 \033[0m$1\n"
$(GBC) $(GBCOPTS) src/i-nex
Expand All @@ -82,11 +83,13 @@ self:
chmod +x i-nex
chmod +x inex-edid
chmod +x inex-cpuid
chmod +x inex-usage
chmod +x debian/check_kernel
chmod +x debian/i-nex-lspci
$(INSTALL) 0755 i-nex inex$(bindir)
$(INSTALL) 0755 inex-edid inex$(bindir)
$(INSTALL) 0755 inex-cpuid inex$(bindir)
$(INSTALL) 0755 inex-usage inex$(bindir)
$(INSTALL) 0755 src/i-nex/i-nex.gambas inex$(bindir)
$(INSTALL) 0755 pixmaps/i-nex.xpm inex/usr/share/pixmaps/
$(INSTALL) 0755 debian/i-nex.desktop inex/usr/share/applications/
Expand Down Expand Up @@ -144,6 +147,7 @@ clean:

$(RM_COM) $(RMFILE_OPT) inex-edid
$(RM_COM) $(RMFILE_OPT) inex-cpuid
$(RM_COM) $(RMFILE_OPT) inex-usage
$(RM_COM) $(RMDIR_OPT) `find . -name ".gambas"`
$(RM_COM) $(RMDIR_OPT) `find . -name "*.gambas"`
$(RM_COM) $(RMDIR_OPT) `find . -name ".directory"`
Expand Down Expand Up @@ -175,11 +179,13 @@ install:
chmod +x i-nex
chmod +x inex-edid
chmod +x inex-cpuid
chmod +x inex-usage
chmod +x debian/check_kernel
chmod +x debian/i-nex-lspci
$(INSTALL) 0755 i-nex $(DESTDIR)$(bindir)
$(INSTALL) 0755 inex-edid $(DESTDIR)$(bindir)
$(INSTALL) 0755 inex-cpuid $(DESTDIR)$(bindir)
$(INSTALL) 0755 inex-usage $(DESTDIR)$(bindir)
$(INSTALL) 0755 src/i-nex/i-nex.gambas $(DESTDIR)$(bindir)
$(INSTALL) 0755 pixmaps/i-nex.xpm $(DESTDIR)/usr/share/pixmaps/
$(INSTALL) 0755 debian/i-nex.desktop $(DESTDIR)/usr/share/applications/
Expand Down Expand Up @@ -208,6 +214,7 @@ uninstall:
rm $(DESTDIR)$(bindir)/i-nex
rm $(DESTDIR)$(bindir)/inex-edid
rm $(DESTDIR)$(bindir)/inex-cpuid
rm $(DESTDIR)$(bindir)/inex-usage
rm $(DESTDIR)$(bindir)/i-nex.gambas
rm $(DESTDIR)/usr/share/pixmaps/i-nex.xpm
rm $(DESTDIR)/usr/share/applications/i-nex.desktop
Expand Down
5 changes: 5 additions & 0 deletions debian/manpages/inex-usage.1
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
3 changes: 2 additions & 1 deletion debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ override_dh_installman:
dh_installman debian/manpages/i-nex.1 -p i-nex
dh_installman debian/manpages/i-nex.gambas.1 -p i-nex
dh_installman debian/manpages/inex-edid.1 -p i-nex
dh_installman debian/manpages/inex-cpuid.1 -p i-nex
dh_installman debian/manpages/inex-cpuid.1 -p i-nex
dh_installman debian/manpages/inex-usage.1 -p i-nex
35 changes: 35 additions & 0 deletions getusage.c
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;
}
1 change: 1 addition & 0 deletions install-self-inex
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ bindir="/usr/bin/"
install -m 0755 usr/bin/i-nex $bindir
install -m 0755 usr/bin/inex-edid $bindir
install -m 0755 usr/bin/inex-cpuid $bindir
install -m 0755 usr/bin/inex-usage $bindir
install -m 0755 usr/bin/i-nex.gambas $bindir
install -m 0755 usr/share/pixmaps/i-nex.xpm /usr/share/pixmaps/
install -m 0755 usr/share/applications/i-nex.desktop /usr/share/applications/
Expand Down

0 comments on commit 61ecb31

Please sign in to comment.