ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/os_info.c
(Generate patch)

Comparing projects/libstatgrab/src/libstatgrab/os_info.c (file contents):
Revision 1.18 by tdb, Wed Apr 7 21:08:40 2004 UTC vs.
Revision 1.22 by ats, Sun Nov 7 12:31:33 2004 UTC

# Line 46 | Line 46
46   #include <time.h>
47   #include <sys/time.h>
48   #endif
49 + #ifdef HPUX
50 + #include <sys/param.h>
51 + #include <sys/pstat.h>
52 + #include <time.h>
53 + #endif
54  
55 + #include "tools.h"
56 +
57   sg_host_info *sg_get_host_info(){
58  
59 <        static sg_host_info general_stat;      
59 >        static sg_host_info general_stat;
60          static struct utsname os;
61  
62 + #ifdef HPUX
63 +        struct pst_static *pstat_static;
64 +        time_t currtime;
65 +        long boottime;
66 + #endif
67   #ifdef SOLARIS
68          time_t boottime,curtime;
69          kstat_ctl_t *kc;
# Line 69 | Line 81 | sg_host_info *sg_get_host_info(){
81   #endif
82  
83          if((uname(&os)) < 0){
84 <                sg_set_error(SG_ERROR_UNAME, NULL);
84 >                sg_set_error_with_errno(SG_ERROR_UNAME, NULL);
85                  return NULL;
86          }
87          
# Line 80 | Line 92 | sg_host_info *sg_get_host_info(){
92          general_stat.hostname = os.nodename;
93  
94          /* get uptime */
95 + #ifdef HPUX
96 +        pstat_static = sg_get_pstat_static();
97 +        if (pstat_static == NULL) {
98 +                return NULL;
99 +        }
100 +
101 +        currtime = time(NULL);
102 +
103 +        boottime = pstat_static->boot_time;
104 +
105 +        general_stat.uptime = currtime - boottime;
106 + #endif
107   #ifdef SOLARIS
108          if ((kc = kstat_open()) == NULL) {
109                  sg_set_error(SG_ERROR_KSTAT_OPEN, NULL);
# Line 106 | Line 130 | sg_host_info *sg_get_host_info(){
130   #endif
131   #if defined(LINUX) || defined(CYGWIN)
132          if ((f=fopen("/proc/uptime", "r")) == NULL) {
133 <                sg_set_error(SG_ERROR_OPEN, "/proc/uptime");
133 >                sg_set_error_with_errno(SG_ERROR_OPEN, "/proc/uptime");
134                  return NULL;
135          }
136          if((fscanf(f,"%lu %*d",&general_stat.uptime)) != 1){
# Line 120 | Line 144 | sg_host_info *sg_get_host_info(){
144          mib[1] = KERN_BOOTTIME;
145          size = sizeof boottime;
146          if (sysctl(mib, 2, &boottime, &size, NULL, 0) < 0){
147 <                sg_set_error(SG_ERROR_SYSCTL, "CTL_KERN.KERN_BOOTTIME");
147 >                sg_set_error_with_errno(SG_ERROR_SYSCTL,
148 >                                        "CTL_KERN.KERN_BOOTTIME");
149                  return NULL;
150          }
151          time(&curtime);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines