コード例 #1
0
int main(int argc, int *argv[])
{
	
	printf("GNU libc version: %s\n", gnu_get_libc_version());
	printf("GNU libc release: %s\n", gnu_get_libc_release());
	exit(EXIT_SUCCESS);
}
コード例 #2
0
ファイル: util.c プロジェクト: jagu-sayan/SayanLib
void	serverReport(int fd)
{
	if (fd < 0)
		return ;
	float			size;
	struct sysinfo	info;
	struct statfs	stat;
	struct utsname	sys;
	FILE			*out;
	FILE			*cpuinfo;
	char			buf[2000];

	out = fdopen(fd, "w");
	if (sysinfo(&info) == 0)
	{
		fprintf(out, "RAM : (");
		fprintf(out, "%.2lu%s %s", info.freeram, getFormatBytes(info.freeram), "free + ");
		fprintf(out, "%.2lu%s %s", info.sharedram, getFormatBytes(info.sharedram), "shared + ");
		fprintf(out, "%.2lu%s %s", info.bufferram, getFormatBytes(info.bufferram), "buffers) / ");
		fprintf(out, "%.2lu%s %s", info.totalram, getFormatBytes(info.totalram), "total\n");
	}
	if (statfs(".", &stat) == 0)
	{
		fprintf(out, "DISK: ");
		size = stat.f_bfree * stat.f_bsize;
		fprintf(out, "%.2f%s %s", size, getFormatBytes(size), "free / ");
		size = stat.f_blocks * stat.f_bsize;
		fprintf(out, "%.2f%s %s", size, getFormatBytes(size), "total\n");
	}

	fprintf(out, "%d processes running\n", info.procs);
	fprintf(out, "%s\n", gnu_get_libc_release());

	if (uname(&sys) == 0)
	{
		fprintf(out, "%s\n", sys.sysname);
		fprintf(out, "%s\n", sys.machine);
		fprintf(out, "%s\n", sys.release);
		fprintf(out, "%s\n", sys.version);
		fprintf(out, "nodename %s\n", sys.nodename);
	}

	cpuinfo = fopen("/proc/cpuinfo", "rb");
	if (cpuinfo != NULL)
	{
		while (fgets(buf, 2000, cpuinfo) != NULL)
			fprintf(out, "%s\n", buf);
	}
	fclose(cpuinfo);
}