LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-26-2010, 06:49 AM   #1
iqra
Member
 
Registered: May 2010
Posts: 34

Rep: Reputation: 15
Angry how to get system info


hiii!!

i want to get system info like up time, no of process etc.
for up time i got the got from net but it is giving me error. i.e.
error: storage size of ‘sys_info’ isn’t known
following is the code i m using

Code:
void sysinfo()
{
int days, hours, mins;
  struct sysinfo sys_info;
 
  if(sysinfo(&sys_info) != 0)
    perror("sysinfo");
 
  // Uptime
  days = sys_info.uptime / 86400;
  hours = (sys_info.uptime / 3600) - (days * 24);
  mins = (sys_info.uptime / 60) - (days * 1440) - (hours * 60);
 
  printf("Uptime: %ddays, %dhours, %dminutes, %ldseconds\n",
                      days, hours, mins, sys_info.uptime % 60);
 }

please tell whats wrong with the code? am i doing mistake somewhere??

Regards!
 
Old 05-26-2010, 10:01 AM   #2
jf.argentino
Member
 
Registered: Apr 2008
Location: Toulon (France)
Distribution: FEDORA CORE
Posts: 493

Rep: Reputation: 50
Are you sure to include <sys/sysinfo.h> header file? More over, you have to rename _YOUR_ "sysinfo" function since this name is already used by th "sysinfo" system function declared in the same header file.
 
1 members found this post helpful.
Old 05-26-2010, 02:18 PM   #3
iqra
Member
 
Registered: May 2010
Posts: 34

Original Poster
Rep: Reputation: 15
ohh yes i missed that header file... thanx for ur help..!!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
getting cpu info, system info thru system calls naveenisback Programming 7 06-11-2010 02:06 PM
How to find out if my system is i386, i486, or i586? Is there a system info command? mlsbraves Linux - General 6 02-17-2009 04:08 PM
System info brianhall Linux - Newbie 7 12-07-2006 12:04 PM
system info linux-idiot Linux - Newbie 10 03-15-2006 02:05 PM
System Info / System Audit munyard Linux - Software 1 01-08-2003 01:33 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration