Preliminary support for kfreebsd.
Reviewed-by: Craig Small <csmall@debian.org> Last-Update: 2019-02-07 Gbp-Pq: Name 26_kfreebsd.patch
This commit is contained in:
parent
9adb25a92f
commit
1e85beac1b
|
@ -12,7 +12,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#if defined(__FreeBSD__)
|
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#if !defined(CPUSTATES)
|
#if !defined(CPUSTATES)
|
||||||
#include <sys/dkstat.h>
|
#include <sys/dkstat.h>
|
||||||
|
@ -92,7 +92,7 @@ void init_cpu_sysctl( void ) {
|
||||||
#elif defined(KERN_CPTIME) /* OpenBSD */
|
#elif defined(KERN_CPTIME) /* OpenBSD */
|
||||||
#define NETSNMP_KERN_CPU KERN_CPTIME
|
#define NETSNMP_KERN_CPU KERN_CPTIME
|
||||||
|
|
||||||
#elif defined(__FreeBSD__)
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||||
#define NETSNMP_KERN_MCPU 1 /* Enable support for multi-cpu stats. Valid for FreeBSD >=6.4, >=7.1, >=8.0 and beyond */
|
#define NETSNMP_KERN_MCPU 1 /* Enable support for multi-cpu stats. Valid for FreeBSD >=6.4, >=7.1, >=8.0 and beyond */
|
||||||
#define NETSNMP_KERN_MCPU_TYPE NETSNMP_CPU_STATS
|
#define NETSNMP_KERN_MCPU_TYPE NETSNMP_CPU_STATS
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ void init_cpu_sysctl( void ) {
|
||||||
#define NETSNMP_VM_STATS_TYPE struct uvmexp
|
#define NETSNMP_VM_STATS_TYPE struct uvmexp
|
||||||
#endif /* VM_UVMEXP2 || VM_UVMEXP */
|
#endif /* VM_UVMEXP2 || VM_UVMEXP */
|
||||||
|
|
||||||
#elif defined(__FreeBSD__) /* FreeBSD */
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) /* FreeBSD */
|
||||||
#define NETSNMP_VM_STATS VM_METER
|
#define NETSNMP_VM_STATS VM_METER
|
||||||
#define NETSNMP_VM_STATS_TYPE struct vmmeter
|
#define NETSNMP_VM_STATS_TYPE struct vmmeter
|
||||||
#define NS_VM_INTR v_intr
|
#define NS_VM_INTR v_intr
|
||||||
|
@ -172,10 +172,10 @@ int netsnmp_cpu_arch_load( netsnmp_cache *cache, void *magic ) {
|
||||||
*/
|
*/
|
||||||
NETSNMP_CPU_STATS cpu_stats[CPUSTATES];
|
NETSNMP_CPU_STATS cpu_stats[CPUSTATES];
|
||||||
size_t cpu_size = sizeof(cpu_stats);
|
size_t cpu_size = sizeof(cpu_stats);
|
||||||
#if !defined(__FreeBSD__) && !defined(__NetBSD__)
|
#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && !defined(__NetBSD__)
|
||||||
int cpu_mib[] = { CTL_KERN, NETSNMP_KERN_CPU };
|
int cpu_mib[] = { CTL_KERN, NETSNMP_KERN_CPU };
|
||||||
#endif
|
#endif
|
||||||
#ifdef __FreeBSD__
|
#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__))
|
||||||
static int cp_times = -1;
|
static int cp_times = -1;
|
||||||
#endif
|
#endif
|
||||||
#ifdef KERN_CPTIME2
|
#ifdef KERN_CPTIME2
|
||||||
|
@ -192,7 +192,7 @@ int netsnmp_cpu_arch_load( netsnmp_cache *cache, void *magic ) {
|
||||||
size_t mem_size = sizeof(NETSNMP_VM_STATS_TYPE);
|
size_t mem_size = sizeof(NETSNMP_VM_STATS_TYPE);
|
||||||
netsnmp_cpu_info *cpu = netsnmp_cpu_get_byIdx( -1, 0 );
|
netsnmp_cpu_info *cpu = netsnmp_cpu_get_byIdx( -1, 0 );
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__NetBSD__)
|
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
|
||||||
sysctlbyname("kern.cp_time", cpu_stats, &cpu_size, NULL, 0);
|
sysctlbyname("kern.cp_time", cpu_stats, &cpu_size, NULL, 0);
|
||||||
#else
|
#else
|
||||||
sysctl(cpu_mib, 2, cpu_stats, &cpu_size, NULL, 0);
|
sysctl(cpu_mib, 2, cpu_stats, &cpu_size, NULL, 0);
|
||||||
|
@ -229,7 +229,7 @@ int netsnmp_cpu_arch_load( netsnmp_cache *cache, void *magic ) {
|
||||||
mcpu_size = cpu_num*sizeof(cpu_stats);
|
mcpu_size = cpu_num*sizeof(cpu_stats);
|
||||||
mcpu_stats = malloc(mcpu_size);
|
mcpu_stats = malloc(mcpu_size);
|
||||||
sysctlbyname("kern.cp_time", mcpu_stats, &mcpu_size, NULL, 0);
|
sysctlbyname("kern.cp_time", mcpu_stats, &mcpu_size, NULL, 0);
|
||||||
#elif defined(__FreeBSD__)
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||||
if (cp_times == -1) {
|
if (cp_times == -1) {
|
||||||
int ret = sysctlbyname("kern.cp_times", NULL, &mcpu_size, NULL, 0);
|
int ret = sysctlbyname("kern.cp_times", NULL, &mcpu_size, NULL, 0);
|
||||||
cp_times = ret == -1 ? 0 : 1;
|
cp_times = ret == -1 ? 0 : 1;
|
||||||
|
|
Loading…
Reference in New Issue