niedziela, 21 sierpnia 2016

Sysinfo os in class

#include <iostream>
#include <sys/sysinfo.h>
#include <sys/utsname.h>
#include <sys/types.h>
#include <unistd.h>
using namespace std;

class System_Info
{
private:
struct sysinfo s_info;
struct utsname u_name;
struct Version
{
char *a;
char *b;
char *c;
char *d;
};
uid_t my_uid;
gid_t my_gid;
public:
System_Info()
{
uname(&u_name);
sysinfo(&s_info);
my_uid=geteuid();
my_gid=getegid();
 
}
void write_Info()
{
struct Version My_Info;
My_Info.a=u_name.sysname;
My_Info.b=u_name.release;
My_Info.c=u_name.version;
My_Info.d=u_name.machine;
cout<<"How many process : "<<s_info.procs<<endl;
cout<<"Total RAM: "<<s_info.totalram/(1024*1024)<<endl;
cout<<"Free RAM : "<<s_info.freeram/(1024*1024)<<endl;
cout<<"Information of os system:\n";
cout<<My_Info.a<<endl;
cout<<My_Info.b<<endl;
cout<<My_Info.c<<endl;
cout<<My_Info.d<<endl;
cout<<"Number identification user and group:\n";
cout<<int(my_uid)<<"    "<<int(my_gid)<<endl;

}
 
};

int main(int argc, char** argv)
{
System_Info My_Os;
My_Os.write_Info();
return 0;
}

Brak komentarzy:

Prześlij komentarz