hostres_snmp.h (154133) | hostres_snmp.h (160341) |
---|---|
1/* 2 * Copyright (c) 2005-2006 The FreeBSD Project 3 * All rights reserved. 4 * 5 * Author: Victor Cruceru <soc-victor@freebsd.org> 6 * 7 * Redistribution of this software and documentation and use in source and 8 * binary forms, with or without modification, are permitted provided that --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * Host Resources MIB for SNMPd. 30 * | 1/* 2 * Copyright (c) 2005-2006 The FreeBSD Project 3 * All rights reserved. 4 * 5 * Author: Victor Cruceru <soc-victor@freebsd.org> 6 * 7 * Redistribution of this software and documentation and use in source and 8 * binary forms, with or without modification, are permitted provided that --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * Host Resources MIB for SNMPd. 30 * |
31 * $FreeBSD: head/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.h 154133 2006-01-09 12:33:45Z harti $ | 31 * $FreeBSD: head/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.h 160341 2006-07-14 09:07:56Z harti $ |
32 */ 33 34#ifndef HOSTRES_SNMP_H_1132245017 | 32 */ 33 34#ifndef HOSTRES_SNMP_H_1132245017 |
35#define HOSTRES_SNMP_H_1132245017 | 35#define HOSTRES_SNMP_H_1132245017 |
36 37#include <sys/types.h> 38#include <sys/queue.h> 39 40#include <stdio.h> 41#include <fcntl.h> 42#include <kvm.h> 43#include <devinfo.h> 44 45#include <bsnmp/asn1.h> 46#include <bsnmp/snmp.h> 47 48#include <bsnmp/snmpmod.h> 49 50/* 51 * Default package directory for hrSWInstalledTable. Can be overridden 52 * via SNMP or configuration file. 53 */ | 36 37#include <sys/types.h> 38#include <sys/queue.h> 39 40#include <stdio.h> 41#include <fcntl.h> 42#include <kvm.h> 43#include <devinfo.h> 44 45#include <bsnmp/asn1.h> 46#include <bsnmp/snmp.h> 47 48#include <bsnmp/snmpmod.h> 49 50/* 51 * Default package directory for hrSWInstalledTable. Can be overridden 52 * via SNMP or configuration file. 53 */ |
54#define PATH_PKGDIR "/var/db/pkg" | 54#define PATH_PKGDIR "/var/db/pkg" |
55 56/* 57 * These are the default maximum caching intervals for the various tables 58 * in seconds. They can be overridden from the configuration file. 59 */ | 55 56/* 57 * These are the default maximum caching intervals for the various tables 58 * in seconds. They can be overridden from the configuration file. 59 */ |
60#define HR_STORAGE_TBL_REFRESH 7 61#define HR_FS_TBL_REFRESH 7 62#define HR_DISK_TBL_REFRESH 7 63#define HR_NETWORK_TBL_REFRESH 7 64#define HR_SWINS_TBL_REFRESH 120 65#define HR_SWRUN_TBL_REFRESH 3 | 60#define HR_STORAGE_TBL_REFRESH 7 61#define HR_FS_TBL_REFRESH 7 62#define HR_DISK_TBL_REFRESH 7 63#define HR_NETWORK_TBL_REFRESH 7 64#define HR_SWINS_TBL_REFRESH 120 65#define HR_SWRUN_TBL_REFRESH 3 |
66 67struct tm; 68struct statfs; 69 70/* a debug macro */ 71#ifndef NDEBUG 72 73#define HRDBG(...) do { \ --- 14 unchanged lines hidden (view full) --- 88#define IS_KERNPROC(kp) (((kp)->ki_flag & P_KTHREAD) == P_KTHREAD) 89 90enum snmpTCTruthValue { 91 SNMP_TRUE = 1, 92 SNMP_FALSE= 2 93}; 94 95/* The number of CPU load samples per one minute, per each CPU */ | 66 67struct tm; 68struct statfs; 69 70/* a debug macro */ 71#ifndef NDEBUG 72 73#define HRDBG(...) do { \ --- 14 unchanged lines hidden (view full) --- 88#define IS_KERNPROC(kp) (((kp)->ki_flag & P_KTHREAD) == P_KTHREAD) 89 90enum snmpTCTruthValue { 91 SNMP_TRUE = 1, 92 SNMP_FALSE= 2 93}; 94 95/* The number of CPU load samples per one minute, per each CPU */ |
96#define MAX_CPU_SAMPLES 4 | 96#define MAX_CPU_SAMPLES 4 |
97 | 97 |
98 |
|
98/* | 99/* |
100 * max len (including '\0'), for device_entry::descr field below, 101 * according to MIB 102 */ 103#define DEV_DESCR_MLEN (64 + 1) 104 105/* 106 * max len (including '\0'), for device_entry::name and 107 * device_map_entry::name_key fields below, according to MIB 108 */ 109#define DEV_NAME_MLEN (32 + 1) 110 111/* 112 * max len (including '\0'), for device_entry::location and 113 * device_map_entry::location_key fields below, according to MIB 114 */ 115#define DEV_LOC_MLEN (128 + 1) 116 117/* |
|
99 * This structure is used to hold a SNMP table entry 100 * for HOST-RESOURCES-MIB's hrDeviceTable 101 */ 102struct device_entry { 103 int32_t index; | 118 * This structure is used to hold a SNMP table entry 119 * for HOST-RESOURCES-MIB's hrDeviceTable 120 */ 121struct device_entry { 122 int32_t index; |
104 struct asn_oid type; 105 u_char descr[64 + 1]; 106 struct asn_oid id; 107 int32_t status; /* enum DeviceStatus */ | 123 const struct asn_oid *type; 124 u_char *descr; 125 const struct asn_oid *id; /* only oid_zeroDotZero as (*id) value*/ 126 int32_t status; /* enum DeviceStatus */ |
108 uint32_t errors; 109 | 127 uint32_t errors; 128 |
110#define HR_DEVICE_FOUND 0x001 | 129#define HR_DEVICE_FOUND 0x001 |
111 /* not dectected by libdevice, so don't try to refresh it*/ | 130 /* not dectected by libdevice, so don't try to refresh it*/ |
112#define HR_DEVICE_IMMUTABLE 0x002 | 131#define HR_DEVICE_IMMUTABLE 0x002 |
113 114 /* next 3 are not from the SNMP mib table, only to be used internally */ 115 uint32_t flags; | 132 133 /* next 3 are not from the SNMP mib table, only to be used internally */ 134 uint32_t flags; |
116 u_char name[32 + 1]; 117 u_char location[128 + 1]; | 135 136 u_char *name; 137 u_char *location; |
118 TAILQ_ENTRY(device_entry) link; 119}; 120 121/* 122 * Next structure is used to keep o list of mappings from a specific 123 * name (a_name) to an entry in the hrFSTblEntry; 124 * We are trying to keep the same index for a specific name at least 125 * for the duration of one SNMP agent run. 126 */ 127struct device_map_entry { 128 int32_t hrIndex; /* used for hrDeviceTblEntry::index */ 129 130 /* map key is the pair (name_key, location_key) */ | 138 TAILQ_ENTRY(device_entry) link; 139}; 140 141/* 142 * Next structure is used to keep o list of mappings from a specific 143 * name (a_name) to an entry in the hrFSTblEntry; 144 * We are trying to keep the same index for a specific name at least 145 * for the duration of one SNMP agent run. 146 */ 147struct device_map_entry { 148 int32_t hrIndex; /* used for hrDeviceTblEntry::index */ 149 150 /* map key is the pair (name_key, location_key) */ |
131 u_char name_key[32 + 1]; /* copy of device name */ 132 u_char location_key[128 + 1]; | 151 u_char *name_key; /* copy of device name */ 152 u_char *location_key; |
133 134 /* 135 * Next may be NULL if the respective hrDeviceTblEntry 136 * is (temporally) gone. 137 */ 138 struct device_entry *entry_p; 139 STAILQ_ENTRY(device_map_entry) link; 140}; --- 86 unchanged lines hidden (view full) --- 227 228/* Find an item in hrDeviceTbl by name. */ 229struct device_entry *device_find_by_name(const char *); 230 231/* Create a new entry out of thin air. */ 232struct device_entry *device_entry_create(const char *, const char *, 233 const char *); 234 | 153 154 /* 155 * Next may be NULL if the respective hrDeviceTblEntry 156 * is (temporally) gone. 157 */ 158 struct device_entry *entry_p; 159 STAILQ_ENTRY(device_map_entry) link; 160}; --- 86 unchanged lines hidden (view full) --- 247 248/* Find an item in hrDeviceTbl by name. */ 249struct device_entry *device_find_by_name(const char *); 250 251/* Create a new entry out of thin air. */ 252struct device_entry *device_entry_create(const char *, const char *, 253 const char *); 254 |
255/* Delete an entry from hrDeviceTbl */ 256void device_entry_delete(struct device_entry *entry); 257 |
|
235/* Init the things for hrProcessorTable. */ 236void init_processor_tbl(void); 237 238/* Finalization routine for hrProcessorTable. */ 239void fini_processor_tbl(void); 240 241/* Start the processor table CPU load collector. */ 242void start_processor_tbl(struct lmodule *); --- 59 unchanged lines hidden --- | 258/* Init the things for hrProcessorTable. */ 259void init_processor_tbl(void); 260 261/* Finalization routine for hrProcessorTable. */ 262void fini_processor_tbl(void); 263 264/* Start the processor table CPU load collector. */ 265void start_processor_tbl(struct lmodule *); --- 59 unchanged lines hidden --- |