24 |
|
|
25 |
|
#include "statgrab.h" |
26 |
|
#include <sys/utsname.h> |
27 |
– |
#include "ukcprog.h" |
27 |
|
#include <stdio.h> |
28 |
|
#ifdef SOLARIS |
29 |
|
#include <kstat.h> |
41 |
|
kstat_named_t *kn; |
42 |
|
|
43 |
|
if((uname(&os)) < 0){ |
45 |
– |
errf("Failed to get os stats (%m)"); |
44 |
|
return NULL; |
45 |
|
} |
46 |
|
|
52 |
|
|
53 |
|
/* get uptime */ |
54 |
|
if ((kc = kstat_open()) == NULL) { |
57 |
– |
errf("kstat_open failure (%m)"); |
55 |
|
return NULL; |
56 |
|
} |
57 |
|
if((ksp=kstat_lookup(kc, "unix", -1, "system_misc"))==NULL){ |
61 |
– |
errf("failed to find lookup information (%m)"); |
58 |
|
return NULL; |
59 |
|
} |
60 |
|
if (kstat_read(kc, ksp, 0) == -1) { |
65 |
– |
errf("Failed to read kernel information (%m)"); |
61 |
|
return NULL; |
62 |
|
} |
63 |
|
if((kn=kstat_data_lookup(ksp, "boot_time")) == NULL){ |
69 |
– |
errf("Failed to get uptime (%m)"); |
64 |
|
return NULL; |
65 |
|
} |
66 |
|
boottime=(kn->value.ui32); |
67 |
< |
if((kstat_close(kc)) != 0){ |
68 |
< |
errf("Failed to close kstat control structure (%m)"); |
75 |
< |
return NULL; |
76 |
< |
} |
67 |
> |
|
68 |
> |
kstat_close(kc); |
69 |
|
|
70 |
|
time(&curtime); |
71 |
|
general_stat.uptime = curtime - boottime; |