WAP to report behaviour of Linux kernel including kernel version, CPUtype and model. (CPU information)
#include<stdio.h>
#include<sys/vfs.h>
#include<sys/sysinfo.h>
#include<sys/utsname.h>
int main()
{
int r,a,q,p,b;
struct sysinfo s1;
struct utsname s2;
struct statfs s3;
r=sysinfo(&s1);
q=uname(&s2);
p=statfs("./",&s3);
a=(1024*1024);
b=(a*1024);
if(r==0&&q==0&&p==0)
{
printf("\nSystem name:%s",s2.sysname);
printf("\nVersion:%s",s2.version);
printf("\nRelease:%s",s2.release);
printf("\nMachine:%s",s2.machine);
printf("\nTotal RAM:%ldMB",(s1.totalram/a));
printf("\nFree RAM:%ld MB",(s1.freeram/a));
printf("\nUsed RAM:%ld MB",((s1.totalram-s1.freeram)/a));
printf("\nTotal Size of partition:%ldGB\n",(s3.f_bsize*s3.f_blocks)/b);
}
else
{
printf("ERROR\n");
}
return 0;
}
#include<sys/vfs.h>
#include<sys/sysinfo.h>
#include<sys/utsname.h>
int main()
{
int r,a,q,p,b;
struct sysinfo s1;
struct utsname s2;
struct statfs s3;
r=sysinfo(&s1);
q=uname(&s2);
p=statfs("./",&s3);
a=(1024*1024);
b=(a*1024);
if(r==0&&q==0&&p==0)
{
printf("\nSystem name:%s",s2.sysname);
printf("\nVersion:%s",s2.version);
printf("\nRelease:%s",s2.release);
printf("\nMachine:%s",s2.machine);
printf("\nTotal RAM:%ldMB",(s1.totalram/a));
printf("\nFree RAM:%ld MB",(s1.freeram/a));
printf("\nUsed RAM:%ld MB",((s1.totalram-s1.freeram)/a));
printf("\nTotal Size of partition:%ldGB\n",(s3.f_bsize*s3.f_blocks)/b);
}
else
{
printf("ERROR\n");
}
return 0;
}
Comments
Post a Comment