hostres_storage_tbl.c (302408) | hostres_storage_tbl.c (310899) |
---|---|
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 --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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 * | 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 --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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 * $FreeBSD: stable/11/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c 248707 2013-03-25 19:12:36Z trociny $ | 29 * $FreeBSD: stable/11/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c 310899 2016-12-31 10:28:59Z ngie $ |
30 */ 31 32/* 33 * Host Resources MIB for SNMPd. Implementation for hrStorageTable 34 */ 35 36#include <sys/types.h> 37#include <sys/param.h> --- 110 unchanged lines hidden (view full) --- 148 149 STAILQ_FOREACH(map, &storage_map, link) 150 if (strcmp(map->a_name, name) == 0) 151 break; 152 153 if (map == NULL) { 154 /* new object - get a new index */ 155 if (next_storage_index > INT_MAX) { | 30 */ 31 32/* 33 * Host Resources MIB for SNMPd. Implementation for hrStorageTable 34 */ 35 36#include <sys/types.h> 37#include <sys/param.h> --- 110 unchanged lines hidden (view full) --- 148 149 STAILQ_FOREACH(map, &storage_map, link) 150 if (strcmp(map->a_name, name) == 0) 151 break; 152 153 if (map == NULL) { 154 /* new object - get a new index */ 155 if (next_storage_index > INT_MAX) { |
156 syslog(LOG_ERR, | 156 syslog(LOG_ERR, |
157 "%s: hrStorageTable index wrap", __func__); 158 errx(EX_SOFTWARE, "hrStorageTable index wrap"); 159 } 160 161 if ((map = malloc(sizeof(*map))) == NULL) { 162 syslog(LOG_ERR, "hrStorageTable: %s: %m", __func__ ); 163 return (NULL); 164 } --- 18 unchanged lines hidden (view full) --- 183 HRDBG("%s exists in hrStorageMap index=%d\n", 184 name, map->hrIndex); 185 } 186 187 if ((entry = malloc(sizeof(*entry))) == NULL) { 188 syslog(LOG_WARNING, "%s: %m", __func__); 189 return (NULL); 190 } | 157 "%s: hrStorageTable index wrap", __func__); 158 errx(EX_SOFTWARE, "hrStorageTable index wrap"); 159 } 160 161 if ((map = malloc(sizeof(*map))) == NULL) { 162 syslog(LOG_ERR, "hrStorageTable: %s: %m", __func__ ); 163 return (NULL); 164 } --- 18 unchanged lines hidden (view full) --- 183 HRDBG("%s exists in hrStorageMap index=%d\n", 184 name, map->hrIndex); 185 } 186 187 if ((entry = malloc(sizeof(*entry))) == NULL) { 188 syslog(LOG_WARNING, "%s: %m", __func__); 189 return (NULL); 190 } |
191 memset(entry, 0, sizeof(*entry)); | 191 memset(entry, 0, sizeof(*entry)); |
192 193 entry->index = map->hrIndex; 194 195 if ((entry->descr = strdup(map->a_name)) == NULL) { 196 free(entry); 197 return (NULL); 198 } 199 --- 169 unchanged lines hidden (view full) --- 369} 370 371/** 372 * Get swap info 373 */ 374static void 375storage_OS_get_swap(void) 376{ | 192 193 entry->index = map->hrIndex; 194 195 if ((entry->descr = strdup(map->a_name)) == NULL) { 196 free(entry); 197 return (NULL); 198 } 199 --- 169 unchanged lines hidden (view full) --- 369} 370 371/** 372 * Get swap info 373 */ 374static void 375storage_OS_get_swap(void) 376{ |
377 int nswapdev = 0; 378 size_t len = sizeof(nswapdev); | |
379 struct storage_entry *entry; 380 char swap_w_prefix[SE_DESC_MLEN]; | 377 struct storage_entry *entry; 378 char swap_w_prefix[SE_DESC_MLEN]; |
379 size_t len; 380 int nswapdev; |
|
381 | 381 |
382 len = sizeof(nswapdev); 383 nswapdev = 0; 384 |
|
382 if (sysctlbyname("vm.nswapdev", &nswapdev, &len, NULL,0 ) < 0) { 383 syslog(LOG_ERR, 384 "hrStorageTable: sysctlbyname(\"vm.nswapdev\") " 385 "failed. %m"); 386 assert(0); 387 return; 388 } 389 --- 273 unchanged lines hidden --- | 385 if (sysctlbyname("vm.nswapdev", &nswapdev, &len, NULL,0 ) < 0) { 386 syslog(LOG_ERR, 387 "hrStorageTable: sysctlbyname(\"vm.nswapdev\") " 388 "failed. %m"); 389 assert(0); 390 return; 391 } 392 --- 273 unchanged lines hidden --- |