|
1 | | -#if defined(HAVE_SYS_SYSCTL_H) && \ |
2 | | - defined(HAVE_SYS_TYPES_H) && \ |
3 | | - defined(HAVE_SYS_SOCKET_H) && \ |
4 | | - defined(HAVE_NET_IF_H) && \ |
5 | | - defined(HAVE_NET_IF_MIB_H) && \ |
6 | | - defined(HAVE_NET_IF_TYPES_H) && \ |
7 | | - defined(HAVE_GETLOADAVG) && \ |
8 | | - defined(HAVE_SYSCTL) && \ |
9 | | - defined(HAVE_TYPE_STRUCT_IFMIBDATA) && \ |
10 | | - defined(HAVE_CONST_CTL_NET) && \ |
11 | | - defined(HAVE_CONST_PF_LINK) && \ |
12 | | - defined(HAVE_CONST_NETLINK_GENERIC) && \ |
13 | | - defined(HAVE_CONST_IFMIB_IFDATA) && \ |
14 | | - defined(HAVE_CONST_IFDATA_GENERAL) && \ |
15 | | - defined(HAVE_CONST_CTL_KERN) && \ |
16 | | - defined(HAVE_CONST_KERN_BOOTTIME) |
| 1 | +#if defined(HAVE_SYS_SYSCTL_H) && defined(HAVE_SYS_TYPES_H) && \ |
| 2 | + defined(HAVE_CONST_CTL_KERN) && defined(HAVE_CONST_KERN_BOOTTIME) |
17 | 3 | #include <vmstat.h> |
18 | 4 | #include <sys/sysctl.h> |
19 | 5 | #include <sys/types.h> |
| 6 | + |
| 7 | +#ifndef VMSTAT_BOOT_TIME |
| 8 | +#define VMSTAT_BOOT_TIME |
| 9 | +static int BOOT_TIME_MIB[] = { CTL_KERN, KERN_BOOTTIME }; |
| 10 | + |
| 11 | +VALUE vmstat_boot_time(VALUE self) { |
| 12 | + struct timeval tv; |
| 13 | + size_t size = sizeof(tv); |
| 14 | + |
| 15 | + if (sysctl(BOOT_TIME_MIB, 2, &tv, &size, NULL, 0) == 0) { |
| 16 | + return rb_time_new(tv.tv_sec, tv.tv_usec); |
| 17 | + } else { |
| 18 | + return Qnil; |
| 19 | + } |
| 20 | +} |
| 21 | +#endif // VMSTAT_BOOT_TIME |
| 22 | + |
| 23 | +#if defined(HAVE_SYS_SOCKET_H) && defined(HAVE_NET_IF_H) && \ |
| 24 | + defined(HAVE_NET_IF_MIB_H) && defined(HAVE_NET_IF_TYPES_H) && \ |
| 25 | + defined(HAVE_GETLOADAVG) && defined(HAVE_SYSCTL) && \ |
| 26 | + defined(HAVE_TYPE_STRUCT_IFMIBDATA) && defined(HAVE_CONST_CTL_NET) && \ |
| 27 | + defined(HAVE_CONST_PF_LINK) && defined(HAVE_CONST_NETLINK_GENERIC) && \ |
| 28 | + defined(HAVE_CONST_IFMIB_IFDATA) && defined(HAVE_CONST_IFDATA_GENERAL) |
20 | 29 | #include <sys/socket.h> |
21 | 30 | #include <net/if.h> |
22 | 31 | #include <net/if_mib.h> |
@@ -52,21 +61,6 @@ VALUE vmstat_network_interfaces(VALUE self) { |
52 | 61 |
|
53 | 62 | return devices; |
54 | 63 | } |
55 | | -#endif |
56 | | - |
57 | | -#ifndef VMSTAT_BOOT_TIME |
58 | | -#define VMSTAT_BOOT_TIME |
59 | | -static int BOOT_TIME_MIB[] = { CTL_KERN, KERN_BOOTTIME }; |
60 | | - |
61 | | -VALUE vmstat_boot_time(VALUE self) { |
62 | | - struct timeval tv; |
63 | | - size_t size = sizeof(tv); |
64 | | - |
65 | | - if (sysctl(BOOT_TIME_MIB, 2, &tv, &size, NULL, 0) == 0) { |
66 | | - return rb_time_new(tv.tv_sec, tv.tv_usec); |
67 | | - } else { |
68 | | - return Qnil; |
69 | | - } |
70 | | -} |
| 64 | +#endif // VMSTAT_NETWORK_INTERFACES |
71 | 65 | #endif |
72 | 66 | #endif |
0 commit comments