summaryrefslogtreecommitdiff
path: root/net/net-snmp/files
diff options
context:
space:
mode:
authorjoerg <joerg@pkgsrc.org>2007-02-05 19:18:37 +0000
committerjoerg <joerg@pkgsrc.org>2007-02-05 19:18:37 +0000
commitc39b7c9ccabe690f767e9e336f028af2c4381590 (patch)
treea663f99cfeb318436dca684fdf2e77a43d72c3d9 /net/net-snmp/files
parent6f82968b44304100378b00224057cd6d71798a77 (diff)
downloadpkgsrc-c39b7c9ccabe690f767e9e336f028af2c4381590.tar.gz
Fix DragonFly build changes. I have no clue to add an optional file
into the build system, so override cpu_nlist on DragonFly.
Diffstat (limited to 'net/net-snmp/files')
-rw-r--r--net/net-snmp/files/cpu_dragonfly.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/net/net-snmp/files/cpu_dragonfly.c b/net/net-snmp/files/cpu_dragonfly.c
new file mode 100644
index 00000000000..9d0ce4c0bf8
--- /dev/null
+++ b/net/net-snmp/files/cpu_dragonfly.c
@@ -0,0 +1,68 @@
+/*
+ * DragonFly kinfo interface
+ */
+#include <net-snmp/net-snmp-config.h>
+#include <net-snmp/net-snmp-includes.h>
+#include <net-snmp/agent/net-snmp-agent-includes.h>
+#include <net-snmp/agent/hardware/cpu.h>
+
+#include <sys/types.h>
+#include <sys/vmmeter.h>
+#include <kinfo.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+void _cpu_copy_stats( netsnmp_cpu_info *cpu );
+
+ /*
+ * Initialise the list of CPUs on the system
+ * (including descriptions)
+ */
+void init_cpu_nlist( void ) {
+ netsnmp_cpu_info *cpu;
+ int i;
+ size_t len;
+ char descr[ SNMP_MAXBUF ];
+
+ kinfo_get_cpus(&cpu_num);
+ len = sizeof(descr);
+ sysctlbyname("hw.model", descr, &len, NULL, 0);
+ for ( i = 0; i < cpu_num; i++ ) {
+ cpu = netsnmp_cpu_get_byIdx( i, 1 );
+ cpu->status = 2; /* running */
+ sprintf(cpu->name, "cpu%d", i);
+ sprintf(cpu->descr, "%s", descr);
+ }
+}
+
+
+ /*
+ * Load the latest CPU usage statistics
+ */
+int netsnmp_cpu_arch_load( netsnmp_cache *cache, void *magic ) {
+ struct vmmeter vmm;
+ size_t len;
+ struct kinfo_cputime cp_time;
+ netsnmp_cpu_info *cpu = netsnmp_cpu_get_byIdx( -1, 0 );
+
+ kinfo_get_sched_cputime(&cp_time);
+ len = sizeof(vmm);
+ sysctlbyname("vm.vmmeter", &vmm, &len, NULL, 0);
+
+ cpu->user_ticks = cp_time.cp_user;
+ cpu->nice_ticks = cp_time.cp_nice;
+ cpu->sys2_ticks = cp_time.cp_sys + cp_time.cp_intr;
+ cpu->idle_ticks = cp_time.cp_idle;
+ cpu->kern_ticks = cp_time.cp_sys;
+ cpu->intrpt_ticks = cp_time.cp_intr;
+
+ cpu->swapIn = vmm.v_swappgsin + vmm.v_vnodepgsin;
+ cpu->swapOut = vmm.v_swappgsout + vmm.v_vnodepgsout;
+ cpu->nInterrupts = vmm.v_intr;
+ cpu->nCtxSwitches = vmm.v_swtch;
+
+ /* Copy "overall" figures to cpu0 entry */
+ _cpu_copy_stats( cpu );
+
+ return 0;
+}