add rpm 5.1.6
git-svn-id: https://svn.disconnected-by-peer.at/svn/linamh/trunk/linamh@523 6952d904-891a-0410-993b-d76249ca496b
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=248329
|
||||
|
||||
--- net-snmp-5.1.2/local/snmpconf.orig 2004-04-20 16:20:51.000000000 +0200
|
||||
+++ net-snmp-5.1.2/local/snmpconf 2007-07-09 15:34:48.000000000 +0200
|
||||
@@ -585,6 +585,7 @@
|
||||
}
|
||||
}
|
||||
close(O);
|
||||
+ system("restorecon $outputf");
|
||||
}
|
||||
}
|
||||
|
||||
14
net-analyzer/net-snmp/files/net-snmp-5.4-exec-crash.patch
Normal file
14
net-analyzer/net-snmp/files/net-snmp-5.4-exec-crash.patch
Normal file
@@ -0,0 +1,14 @@
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=243536
|
||||
|
||||
--- net-snmp-5.4/agent/mibgroup/agent/extend.c.orig 2006-10-18 21:07:35.000000000 +0200
|
||||
+++ net-snmp-5.4/agent/mibgroup/agent/extend.c 2007-06-27 14:30:08.000000000 +0200
|
||||
@@ -448,6 +448,9 @@
|
||||
extension->command = strdup( exec_command );
|
||||
if (cptr)
|
||||
extension->args = strdup( cptr );
|
||||
+ } else {
|
||||
+ snmp_log(LOG_ERR, "Duplicate MIBOID '%s' detected in exec statement, only the first one will be used.\n", exec_name);
|
||||
+ return;
|
||||
}
|
||||
|
||||
#ifndef USING_UCD_SNMP_EXTENSIBLE_MODULE
|
||||
20
net-analyzer/net-snmp/files/net-snmp-5.4-makefile.patch
Normal file
20
net-analyzer/net-snmp/files/net-snmp-5.4-makefile.patch
Normal file
@@ -0,0 +1,20 @@
|
||||
diff -ru net-snmp-5.4~/agent/mibgroup/Makefile.in net-snmp-5.4/agent/mibgroup/Makefile.in
|
||||
--- net-snmp-5.4~/agent/mibgroup/Makefile.in 2006-11-26 16:43:18.000000000 +0100
|
||||
+++ net-snmp-5.4/agent/mibgroup/Makefile.in 2006-11-26 16:44:49.000000000 +0100
|
||||
@@ -22,9 +22,13 @@
|
||||
.c.o:
|
||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
|
||||
|
||||
-OBJS = @mib_module_list_o@
|
||||
-LOBJS = @mib_module_list_lo@
|
||||
-SRCS = @mib_module_list_c@
|
||||
+@mib_module_list_o@
|
||||
+@mib_module_list_lo@
|
||||
+@mib_module_list_c@
|
||||
+
|
||||
+OBJS = $(mib_module_list_o)
|
||||
+LOBJS = $(mib_module_list_lo)
|
||||
+SRCS = $(mib_module_list_c)
|
||||
|
||||
all: standardall $(LOBJS)
|
||||
|
||||
192
net-analyzer/net-snmp/files/net-snmp-5.4.1-CVE-2008-2292.patch
Normal file
192
net-analyzer/net-snmp/files/net-snmp-5.4.1-CVE-2008-2292.patch
Normal file
@@ -0,0 +1,192 @@
|
||||
r16770 | dts12 | 2007-12-22 22:22:44 +0300 (Сбт, 22 Дек 2007) | 2 lines
|
||||
|
||||
CHANGES: perl: BUG: 1826174: Check for buffer overflow when printing values.
|
||||
|
||||
CHANGES: python: BUG: 1826174: Check for buffer overflow when printing values.
|
||||
Addresses CVE-2008-2292
|
||||
|
||||
--- perl/SNMP/SNMP.xs (revision 16769)
|
||||
+++ perl/SNMP/SNMP.xs (revision 16770)
|
||||
@@ -470,14 +470,16 @@
|
||||
if (flag == USE_ENUMS) {
|
||||
for(ep = tp->enums; ep; ep = ep->next) {
|
||||
if (ep->value == *var->val.integer) {
|
||||
- strcpy(buf, ep->label);
|
||||
+ strncpy(buf, ep->label, buf_len);
|
||||
+ buf[buf_len-1] = '\0';
|
||||
len = strlen(buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!len) {
|
||||
- sprintf(buf,"%ld", *var->val.integer);
|
||||
+ snprintf(buf, buf_len, "%ld", *var->val.integer);
|
||||
+ buf[buf_len-1] = '\0';
|
||||
len = strlen(buf);
|
||||
}
|
||||
break;
|
||||
@@ -486,21 +488,25 @@
|
||||
case ASN_COUNTER:
|
||||
case ASN_TIMETICKS:
|
||||
case ASN_UINTEGER:
|
||||
- sprintf(buf,"%lu", (unsigned long) *var->val.integer);
|
||||
+ snprintf(buf, buf_len, "%lu", (unsigned long) *var->val.integer);
|
||||
+ buf[buf_len-1] = '\0';
|
||||
len = strlen(buf);
|
||||
break;
|
||||
|
||||
case ASN_OCTET_STR:
|
||||
case ASN_OPAQUE:
|
||||
- memcpy(buf, (char*)var->val.string, var->val_len);
|
||||
len = var->val_len;
|
||||
+ if ( len > buf_len )
|
||||
+ len = buf_len;
|
||||
+ memcpy(buf, (char*)var->val.string, len);
|
||||
break;
|
||||
|
||||
case ASN_IPADDRESS:
|
||||
- ip = (u_char*)var->val.string;
|
||||
- sprintf(buf, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
|
||||
- len = strlen(buf);
|
||||
- break;
|
||||
+ ip = (u_char*)var->val.string;
|
||||
+ snprintf(buf, buf_len, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
|
||||
+ buf[buf_len-1] = '\0';
|
||||
+ len = strlen(buf);
|
||||
+ break;
|
||||
|
||||
case ASN_NULL:
|
||||
break;
|
||||
@@ -512,14 +518,14 @@
|
||||
break;
|
||||
|
||||
case SNMP_ENDOFMIBVIEW:
|
||||
- sprintf(buf,"%s", "ENDOFMIBVIEW");
|
||||
- break;
|
||||
+ snprintf(buf, buf_len, "%s", "ENDOFMIBVIEW");
|
||||
+ break;
|
||||
case SNMP_NOSUCHOBJECT:
|
||||
- sprintf(buf,"%s", "NOSUCHOBJECT");
|
||||
- break;
|
||||
+ snprintf(buf, buf_len, "%s", "NOSUCHOBJECT");
|
||||
+ break;
|
||||
case SNMP_NOSUCHINSTANCE:
|
||||
- sprintf(buf,"%s", "NOSUCHINSTANCE");
|
||||
- break;
|
||||
+ snprintf(buf, buf_len, "%s", "NOSUCHINSTANCE");
|
||||
+ break;
|
||||
|
||||
case ASN_COUNTER64:
|
||||
#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
|
||||
@@ -538,19 +544,19 @@
|
||||
#endif
|
||||
|
||||
case ASN_BIT_STR:
|
||||
- snprint_bitstring(buf, sizeof(buf), var, NULL, NULL, NULL);
|
||||
+ snprint_bitstring(buf, buf_len, var, NULL, NULL, NULL);
|
||||
len = strlen(buf);
|
||||
break;
|
||||
#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
|
||||
case ASN_OPAQUE_FLOAT:
|
||||
- if (var->val.floatVal)
|
||||
- sprintf(buf,"%f", *var->val.floatVal);
|
||||
- break;
|
||||
+ if (var->val.floatVal)
|
||||
+ snprintf(buf, buf_len, "%f", *var->val.floatVal);
|
||||
+ break;
|
||||
|
||||
case ASN_OPAQUE_DOUBLE:
|
||||
- if (var->val.doubleVal)
|
||||
- sprintf(buf,"%f", *var->val.doubleVal);
|
||||
- break;
|
||||
+ if (var->val.doubleVal)
|
||||
+ snprintf(buf, buf_len, "%f", *var->val.doubleVal);
|
||||
+ break;
|
||||
#endif
|
||||
|
||||
case ASN_NSAP:
|
||||
--- python/netsnmp/client_intf.c (revision 16961)
|
||||
+++ python/netsnmp/client_intf.c (revision 16962)
|
||||
@@ -330,14 +330,15 @@
|
||||
if (flag == USE_ENUMS) {
|
||||
for(ep = tp->enums; ep; ep = ep->next) {
|
||||
if (ep->value == *var->val.integer) {
|
||||
- strcpy(buf, ep->label);
|
||||
+ strncpy(buf, ep->label, buf_len);
|
||||
+ buf[buf_len -1] = 0;
|
||||
len = STRLEN(buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!len) {
|
||||
- sprintf(buf,"%ld", *var->val.integer);
|
||||
+ snprintf(buf,"%ld", buf_len, *var->val.integer);
|
||||
len = STRLEN(buf);
|
||||
}
|
||||
break;
|
||||
@@ -346,19 +347,21 @@
|
||||
case ASN_COUNTER:
|
||||
case ASN_TIMETICKS:
|
||||
case ASN_UINTEGER:
|
||||
- sprintf(buf,"%lu", (unsigned long) *var->val.integer);
|
||||
+ snprintf(buf, buf_len, "%lu", (unsigned long) *var->val.integer);
|
||||
len = STRLEN(buf);
|
||||
break;
|
||||
|
||||
case ASN_OCTET_STR:
|
||||
case ASN_OPAQUE:
|
||||
- memcpy(buf, (char*)var->val.string, var->val_len);
|
||||
len = var->val_len;
|
||||
+ if (len > buf_len)
|
||||
+ len = buf_len;
|
||||
+ memcpy(buf, (char*)var->val.string, len);
|
||||
break;
|
||||
|
||||
case ASN_IPADDRESS:
|
||||
ip = (u_char*)var->val.string;
|
||||
- sprintf(buf, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
|
||||
+ snprintf(buf, buf_len, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
|
||||
len = STRLEN(buf);
|
||||
break;
|
||||
|
||||
@@ -372,13 +375,13 @@
|
||||
break;
|
||||
|
||||
case SNMP_ENDOFMIBVIEW:
|
||||
- sprintf(buf,"%s", "ENDOFMIBVIEW");
|
||||
+ snprintf(buf, buf_len, "%s", "ENDOFMIBVIEW");
|
||||
break;
|
||||
case SNMP_NOSUCHOBJECT:
|
||||
- sprintf(buf,"%s", "NOSUCHOBJECT");
|
||||
+ snprintf(buf, buf_len, "%s", "NOSUCHOBJECT");
|
||||
break;
|
||||
case SNMP_NOSUCHINSTANCE:
|
||||
- sprintf(buf,"%s", "NOSUCHINSTANCE");
|
||||
+ snprintf(buf, buf_len, "%s", "NOSUCHINSTANCE");
|
||||
break;
|
||||
|
||||
case ASN_COUNTER64:
|
||||
@@ -398,18 +401,18 @@
|
||||
#endif
|
||||
|
||||
case ASN_BIT_STR:
|
||||
- snprint_bitstring(buf, sizeof(buf), var, NULL, NULL, NULL);
|
||||
+ snprint_bitstring(buf, buf_len, var, NULL, NULL, NULL);
|
||||
len = STRLEN(buf);
|
||||
break;
|
||||
#ifdef OPAQUE_SPECIAL_TYPES
|
||||
case ASN_OPAQUE_FLOAT:
|
||||
if (var->val.floatVal)
|
||||
- sprintf(buf,"%f", *var->val.floatVal);
|
||||
+ snprintf(buf, buf_len, "%f", *var->val.floatVal);
|
||||
break;
|
||||
|
||||
case ASN_OPAQUE_DOUBLE:
|
||||
if (var->val.doubleVal)
|
||||
- sprintf(buf,"%f", *var->val.doubleVal);
|
||||
+ snprintf(buf, buf_len, "%f", *var->val.doubleVal);
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
Fix clientaddr functionality. Includes further memory leak and newline fixes.
|
||||
|
||||
Previously, the clientaddr option in snmp.conf was parsed, but the actual
|
||||
clientaddr was used to bind(), yet sendmsg() was still called with 0.0.0.0.
|
||||
|
||||
This patch alters:
|
||||
- netsnmp_udp_fmtaddr: include both sides of addr_pair for debugging.
|
||||
- netsnmp_udp_transport: Set addr_pair->local_addr in the remote && client_socket path.
|
||||
- netsnmp_udp_transport: Print a debugging error on failure to bind()
|
||||
- netsnmp_udp_transport: Print out the full client open addr_pair data.
|
||||
|
||||
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
|
||||
Status: Merged in upstream r16654
|
||||
Tracking-URL: https://sourceforge.net/tracker/?func=detail&atid=312694&aid=1775124&group_id=12694
|
||||
|
||||
Further fixes:
|
||||
Revision 16681
|
||||
add missing newline in debug msg
|
||||
Revision 16704
|
||||
CHANGES: snmplib: BUG: Coverity #183: fix memory leak if IP_PKTINFO fails
|
||||
Revision 16716
|
||||
CHANGES: snmplib: Do not leak memory whenever an udp address is formatted.
|
||||
|
||||
Fixes bug: bugs.gentoo.org/180266
|
||||
|
||||
diff -Naur net-snmp-5.4.1.orig/snmplib/snmpUDPDomain.c net-snmp-5.4.1/snmplib/snmpUDPDomain.c
|
||||
--- net-snmp-5.4.1.orig/snmplib/snmpUDPDomain.c 2007-06-11 02:15:24.000000000 +0400
|
||||
+++ net-snmp-5.4.1/snmplib/snmpUDPDomain.c 2007-12-27 18:15:56.000000000 +0300
|
||||
@@ -104,11 +104,13 @@
|
||||
char tmp[64];
|
||||
to = (struct sockaddr_in *) &(addr_pair->remote_addr);
|
||||
if (to == NULL) {
|
||||
- return strdup("UDP: unknown");
|
||||
+ sprintf(tmp, "UDP: [%s]->unknown",
|
||||
+ inet_ntoa(addr_pair->local_addr));
|
||||
+ } else {
|
||||
+ sprintf(tmp, "UDP: [%s]->", inet_ntoa(addr_pair->local_addr));
|
||||
+ sprintf(tmp + strlen(tmp), "[%s]:%hd",
|
||||
+ inet_ntoa(to->sin_addr), ntohs(to->sin_port));
|
||||
}
|
||||
-
|
||||
- sprintf(tmp, "UDP: [%s]:%hu",
|
||||
- inet_ntoa(to->sin_addr), ntohs(to->sin_port));
|
||||
return strdup(tmp);
|
||||
}
|
||||
}
|
||||
@@ -642,6 +644,7 @@
|
||||
if (setsockopt(t->sock, SOL_IP, IP_PKTINFO, &sockopt, sizeof sockopt) == -1) {
|
||||
DEBUGMSGTL(("netsnmp_udp", "couldn't set IP_PKTINFO: %s\n",
|
||||
strerror(errno)));
|
||||
+ netsnmp_transport_free(t);
|
||||
return NULL;
|
||||
}
|
||||
DEBUGMSGTL(("netsnmp_udp", "set IP_PKTINFO\n"));
|
||||
@@ -667,10 +670,24 @@
|
||||
if (client_socket) {
|
||||
struct sockaddr_in client_addr;
|
||||
netsnmp_sockaddr_in2(&client_addr, client_socket, NULL);
|
||||
+ addr_pair.local_addr = client_addr.sin_addr;
|
||||
client_addr.sin_port = 0;
|
||||
- bind(t->sock, (struct sockaddr *)&client_addr,
|
||||
+ rc = bind(t->sock, (struct sockaddr *)&client_addr,
|
||||
sizeof(struct sockaddr));
|
||||
+ if ( rc != 0 ) {
|
||||
+ DEBUGMSGTL(("netsnmp_udp", "failed to bind for clientaddr: %d %s\n",
|
||||
+ errno, strerror(errno)));
|
||||
+ netsnmp_udp_close(t);
|
||||
+ netsnmp_transport_free(t);
|
||||
+ return NULL;
|
||||
+ }
|
||||
}
|
||||
+
|
||||
+ str = netsnmp_udp_fmtaddr(NULL, (void *)&addr_pair,
|
||||
+ sizeof(netsnmp_udp_addr_pair));
|
||||
+ DEBUGMSGTL(("netsnmp_udp", "client open %s\n", str));
|
||||
+ free(str);
|
||||
+
|
||||
/*
|
||||
* Save the (remote) address in the
|
||||
* transport-specific data pointer for later use by netsnmp_udp_send.
|
||||
@@ -839,12 +856,12 @@
|
||||
if (host == NULL) {
|
||||
DEBUGMSGTL(("netsnmp_sockaddr_in",
|
||||
"servname not numeric, "
|
||||
- "check if it really is a destination)"));
|
||||
+ "check if it really is a destination)\n"));
|
||||
host = port;
|
||||
port = NULL;
|
||||
} else {
|
||||
DEBUGMSGTL(("netsnmp_sockaddr_in",
|
||||
- "servname not numeric"));
|
||||
+ "servname not numeric\n"));
|
||||
free(peername);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,538 @@
|
||||
r16694 | rstory | 2007-09-14 17:11:59 +0400 (Птн, 14 Сен 2007) | 3 lines
|
||||
|
||||
Apple patches
|
||||
- add/fix disk/partition tables on darwin
|
||||
|
||||
Also fixes incorrect hrFSStorageIndex
|
||||
|
||||
http://bugs.gentoo.org/show_bug.cgi?id=211660
|
||||
http://sourceforge.net/tracker/index.php?func=detail&aid=1696044&group_id=12694&atid=312694
|
||||
|
||||
--- agent/mibgroup/host/hr_partition.c (revision 16693)
|
||||
+++ agent/mibgroup/host/hr_partition.c (revision 16694)
|
||||
@@ -1,8 +1,17 @@
|
||||
-
|
||||
/*
|
||||
* Host Resources MIB - partition device group implementation - hr_partition.c
|
||||
*
|
||||
*/
|
||||
+/* Portions of this file are subject to the following copyright(s). See
|
||||
+ * the Net-SNMP's COPYING file for more details and other copyrights
|
||||
+ * that may apply:
|
||||
+ */
|
||||
+/*
|
||||
+ * Portions of this file are copyrighted by:
|
||||
+ * Copyright (C) 2007 Apple, Inc. All rights reserved.
|
||||
+ * Use is subject to license terms specified in the COPYING file
|
||||
+ * distributed with the Net-SNMP package.
|
||||
+ */
|
||||
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
#include <fcntl.h>
|
||||
@@ -35,6 +44,9 @@
|
||||
static int HRP_savedDiskIndex;
|
||||
static int HRP_savedPartIndex;
|
||||
static char HRP_savedName[1024];
|
||||
+#ifdef NETSNMP_CAN_GET_DISK_LABEL
|
||||
+static char HRP_savedLabel[1024];
|
||||
+#endif
|
||||
|
||||
static int HRP_DiskIndex;
|
||||
|
||||
@@ -135,6 +147,7 @@
|
||||
(name[HRPART_DISK_NAME_LENGTH] &
|
||||
((1 << HRDEV_TYPE_SHIFT) - 1));
|
||||
|
||||
+ DEBUGMSGTL(("host/hr_partition", "... low index %d\n", LowDiskIndex));
|
||||
while (HRP_DiskIndex < LowDiskIndex) {
|
||||
Init_HR_Partition(); /* moves to next disk */
|
||||
if (HRP_DiskIndex == -1)
|
||||
@@ -144,6 +157,7 @@
|
||||
|
||||
for (;;) {
|
||||
part_idx = Get_Next_HR_Partition();
|
||||
+ DEBUGMSGTL(("host/hr_partition", "... part index %d\n", part_idx));
|
||||
if (part_idx == 0)
|
||||
break;
|
||||
newname[HRPART_DISK_NAME_LENGTH] =
|
||||
@@ -225,8 +239,13 @@
|
||||
long_return = part_idx;
|
||||
return (u_char *) & long_return;
|
||||
case HRPART_LABEL:
|
||||
+#ifdef NETSNMP_CAN_GET_DISK_LABEL
|
||||
+ *var_len = strlen(HRP_savedLabel);
|
||||
+ return (u_char *) HRP_savedLabel;
|
||||
+#else
|
||||
*var_len = strlen(HRP_savedName);
|
||||
return (u_char *) HRP_savedName;
|
||||
+#endif
|
||||
case HRPART_ID: /* Use the device number */
|
||||
sprintf(string, "0x%x", (int) stat_buf.st_rdev);
|
||||
*var_len = strlen(string);
|
||||
@@ -259,9 +278,11 @@
|
||||
static void
|
||||
Init_HR_Partition(void)
|
||||
{
|
||||
+ DEBUGMSGTL(("host/hr_partition", "Init_HR_Partition\n"));
|
||||
HRP_DiskIndex = Get_Next_HR_Disk();
|
||||
if (HRP_DiskIndex != -1)
|
||||
HRP_DiskIndex &= ((1 << HRDEV_TYPE_SHIFT) - 1);
|
||||
+ DEBUGMSGTL(("host/hr_partition", "... %d\n",HRP_DiskIndex));
|
||||
|
||||
HRP_index = -1;
|
||||
}
|
||||
@@ -272,6 +293,7 @@
|
||||
char string[1024];
|
||||
int fd;
|
||||
|
||||
+ DEBUGMSGTL(("host/hr_partition", "Get_Next_HR_Partition %d\n",HRP_DiskIndex));
|
||||
if (HRP_DiskIndex == -1) {
|
||||
return 0;
|
||||
}
|
||||
@@ -309,4 +331,7 @@
|
||||
HRP_savedDiskIndex = disk_idx;
|
||||
HRP_savedPartIndex = part_idx;
|
||||
(void) Get_Next_HR_Disk_Partition(HRP_savedName, sizeof(HRP_savedName), HRP_index);
|
||||
+#ifdef NETSNMP_CAN_GET_DISK_LABEL
|
||||
+ (void) Get_HR_Disk_Label(HRP_savedLabel, sizeof(HRP_savedLabel), HRP_savedName);
|
||||
+#endif
|
||||
}
|
||||
Index: agent/mibgroup/host/hr_filesys.c
|
||||
===================================================================
|
||||
--- agent/mibgroup/host/hr_filesys.c (revision 16693)
|
||||
+++ agent/mibgroup/host/hr_filesys.c (revision 16694)
|
||||
@@ -2,11 +2,25 @@
|
||||
* Host Resources MIB - File System device group implementation - hr_filesys.c
|
||||
*
|
||||
*/
|
||||
+/* Portions of this file are subject to the following copyright(s). See
|
||||
+ * the Net-SNMP's COPYING file for more details and other copyrights
|
||||
+ * that may apply:
|
||||
+ */
|
||||
+/*
|
||||
+ * Portions of this file are copyrighted by:
|
||||
+ * Copyright (C) 2007 Apple, Inc. All rights reserved.
|
||||
+ * Use is subject to license terms specified in the COPYING file
|
||||
+ * distributed with the Net-SNMP package.
|
||||
+ */
|
||||
|
||||
#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/memory.h>
|
||||
#include "host_res.h"
|
||||
#include "hr_filesys.h"
|
||||
#include "hr_storage.h"
|
||||
+#include "hr_disk.h"
|
||||
#include <net-snmp/utilities.h>
|
||||
|
||||
#if HAVE_MNTENT_H
|
||||
@@ -535,7 +549,7 @@
|
||||
long_return = 2; /* others probably aren't */
|
||||
return (u_char *) & long_return;
|
||||
case HRFSYS_STOREIDX:
|
||||
- long_return = fsys_idx + HRS_TYPE_FIXED_MAX;
|
||||
+ long_return = fsys_idx + NETSNMP_MEM_TYPE_MAX;
|
||||
return (u_char *) & long_return;
|
||||
case HRFSYS_FULLDUMP:
|
||||
return when_dumped(HRFS_entry->HRFS_name, FULL_DUMP, var_len);
|
||||
Index: agent/mibgroup/host/hr_disk.c
|
||||
===================================================================
|
||||
--- agent/mibgroup/host/hr_disk.c (revision 16693)
|
||||
+++ agent/mibgroup/host/hr_disk.c (revision 16694)
|
||||
@@ -2,6 +2,16 @@
|
||||
* Host Resources MIB - disk device group implementation - hr_disk.c
|
||||
*
|
||||
*/
|
||||
+/* Portions of this file are subject to the following copyright(s). See
|
||||
+ * the Net-SNMP's COPYING file for more details and other copyrights
|
||||
+ * that may apply:
|
||||
+ */
|
||||
+/*
|
||||
+ * Portions of this file are copyrighted by:
|
||||
+ * Copyright (C) 2007 Apple, Inc. All rights reserved.
|
||||
+ * Use is subject to license terms specified in the COPYING file
|
||||
+ * distributed with the Net-SNMP package.
|
||||
+ */
|
||||
|
||||
#include <net-snmp/net-snmp-config.h>
|
||||
#include "host_res.h"
|
||||
@@ -65,6 +75,15 @@
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
+#ifdef darwin
|
||||
+#include <CoreFoundation/CoreFoundation.h>
|
||||
+#include <IOKit/IOKitLib.h>
|
||||
+#include <IOKit/storage/IOBlockStorageDriver.h>
|
||||
+#include <IOKit/storage/IOMedia.h>
|
||||
+#include <IOKit/IOBSD.h>
|
||||
+#include <DiskArbitration/DADisk.h>
|
||||
+#endif
|
||||
+
|
||||
#ifdef linux
|
||||
/*
|
||||
* define BLKGETSIZE from <linux/fs.h>:
|
||||
@@ -79,6 +98,27 @@
|
||||
|
||||
#define HRD_MONOTONICALLY_INCREASING
|
||||
|
||||
+/*************************************************************
|
||||
+ * constants for enums for the MIB node
|
||||
+ * hrDiskStorageAccess (INTEGER / ASN_INTEGER)
|
||||
+ */
|
||||
+#define HRDISKSTORAGEACCESS_READWRITE 1
|
||||
+#define HRDISKSTORAGEACCESS_READONLY 2
|
||||
+
|
||||
+
|
||||
+/*************************************************************
|
||||
+ * constants for enums for the MIB node
|
||||
+ * hrDiskStorageMedia (INTEGER / ASN_INTEGER)
|
||||
+ */
|
||||
+#define HRDISKSTORAGEMEDIA_OTHER 1
|
||||
+#define HRDISKSTORAGEMEDIA_UNKNOWN 2
|
||||
+#define HRDISKSTORAGEMEDIA_HARDDISK 3
|
||||
+#define HRDISKSTORAGEMEDIA_FLOPPYDISK 4
|
||||
+#define HRDISKSTORAGEMEDIA_OPTICALDISKROM 5
|
||||
+#define HRDISKSTORAGEMEDIA_OPTICALDISKWORM 6
|
||||
+#define HRDISKSTORAGEMEDIA_OPTICALDISKRW 7
|
||||
+#define HRDISKSTORAGEMEDIA_RAMDISK 8
|
||||
+
|
||||
/*********************
|
||||
*
|
||||
* Kernel & interface information,
|
||||
@@ -132,6 +172,19 @@
|
||||
static struct disklabel HRD_info;
|
||||
#endif
|
||||
|
||||
+#ifdef darwin
|
||||
+static int64_t HRD_cap;
|
||||
+static int HRD_access;
|
||||
+static int HRD_type;
|
||||
+static int HRD_removeble;
|
||||
+static char HRD_model[40];
|
||||
+static int HRD_saved_access;
|
||||
+static int HRD_saved_type;
|
||||
+static int HRD_saved_removeble;
|
||||
+static int _get_type_from_protocol( const char *prot );
|
||||
+static int _get_type_value( const char *str_type );
|
||||
+#endif
|
||||
+
|
||||
static void parse_disk_config(const char *, char *);
|
||||
static void free_disk_config(void);
|
||||
|
||||
@@ -185,6 +238,8 @@
|
||||
"/dev/rdsk/c%dt%dd0s0", 0, 7);
|
||||
Add_HR_Disk_entry("/dev/rdsk/c%dd%ds%d", 0, 7, 0, 15,
|
||||
"/dev/rdsk/c%dd%ds0", 0, 7);
|
||||
+#elif defined(darwin)
|
||||
+ Add_HR_Disk_entry("/dev/disk%ds%d", -1, -1, 0, 32, "/dev/disk%d", 1, 32);
|
||||
#elif defined(freebsd4) || defined(freebsd5)
|
||||
Add_HR_Disk_entry("/dev/ad%ds%d%c", 0, 1, 1, 4, "/dev/ad%ds%d", 'a', 'h');
|
||||
Add_HR_Disk_entry("/dev/da%ds%d%c", 0, 1, 1, 4, "/dev/da%ds%d", 'a', 'h');
|
||||
@@ -484,6 +539,7 @@
|
||||
Init_HR_Disk();
|
||||
for (;;) {
|
||||
disk_idx = Get_Next_HR_Disk();
|
||||
+ DEBUGMSGTL(("host/hr_disk", "... index %d\n", disk_idx));
|
||||
if (disk_idx == -1)
|
||||
break;
|
||||
newname[HRDISK_ENTRY_NAME_LENGTH] = disk_idx;
|
||||
@@ -749,7 +805,13 @@
|
||||
HRD_history[iindex] = 0;
|
||||
return ((HRDEV_DISK << HRDEV_TYPE_SHIFT) + iindex);
|
||||
}
|
||||
+ DEBUGMSGTL(("host/hr_disk",
|
||||
+ "Get_Next_HR_Disk: can't query %s\n", string));
|
||||
}
|
||||
+ else {
|
||||
+ DEBUGMSGTL(("host/hr_disk",
|
||||
+ "Get_Next_HR_Disk: can't open %s\n", string));
|
||||
+ }
|
||||
HRD_history[iindex] = now;
|
||||
HRD_index++;
|
||||
}
|
||||
@@ -801,6 +863,66 @@
|
||||
return 0;
|
||||
}
|
||||
|
||||
+#ifdef darwin
|
||||
+int
|
||||
+Get_HR_Disk_Label(char *string, size_t str_len, const char *devfull)
|
||||
+{
|
||||
+ DASessionRef sess_ref;
|
||||
+ DADiskRef disk;
|
||||
+ CFDictionaryRef desc;
|
||||
+ CFStringRef str_ref;
|
||||
+ CFStringEncoding sys_encoding = CFStringGetSystemEncoding();
|
||||
+
|
||||
+ DEBUGMSGTL(("host/hr_disk", "Disk Label type %s\n", devfull));
|
||||
+
|
||||
+ sess_ref = DASessionCreate( NULL );
|
||||
+ if (NULL == sess_ref) {
|
||||
+ strncpy(string, devfull, str_len);
|
||||
+ string[str_len-1] = 0;
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ disk = DADiskCreateFromBSDName( NULL, sess_ref, devfull );
|
||||
+ if (NULL == disk) {
|
||||
+ CFRelease(sess_ref);
|
||||
+ strncpy(string, devfull, str_len);
|
||||
+ string[str_len-1] = 0;
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ desc = DADiskCopyDescription( disk );
|
||||
+ if (NULL == desc) {
|
||||
+ snmp_log(LOG_ERR,
|
||||
+ "diskmgr: couldn't get disk description for %s, skipping\n",
|
||||
+ devfull);
|
||||
+ CFRelease(disk);
|
||||
+ CFRelease(sess_ref);
|
||||
+ strncpy(string, devfull, str_len);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ /** model */
|
||||
+ str_ref = (CFStringRef)
|
||||
+ CFDictionaryGetValue(desc, kDADiskDescriptionMediaNameKey);
|
||||
+ if (str_ref) {
|
||||
+ strncpy(string, CFStringGetCStringPtr(str_ref, sys_encoding),
|
||||
+ str_len);
|
||||
+ string[str_len-1] = 0;
|
||||
+ DEBUGMSGTL(("verbose:diskmgr:darwin", " name %s\n", string));
|
||||
+ }
|
||||
+ else {
|
||||
+ strncpy(string, devfull, str_len);
|
||||
+ string[str_len-1] = 0;
|
||||
+ }
|
||||
+
|
||||
+ CFRelease(disk);
|
||||
+ CFRelease(desc);
|
||||
+ CFRelease(sess_ref);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
static void
|
||||
Save_HR_Disk_Specific(void)
|
||||
{
|
||||
@@ -822,6 +944,13 @@
|
||||
#ifdef DIOCGDINFO
|
||||
HRD_savedCapacity = HRD_info.d_secperunit / 2;
|
||||
#endif
|
||||
+#ifdef darwin
|
||||
+ HRD_savedCapacity = HRD_cap / 1024;
|
||||
+ HRD_saved_access = HRD_access;
|
||||
+ HRD_saved_type = HRD_type;
|
||||
+ HRD_saved_removeble = HRD_removeble;
|
||||
+#endif
|
||||
+
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -845,6 +974,11 @@
|
||||
sizeof(HRD_savedModel)-1);
|
||||
HRD_savedModel[ sizeof(HRD_savedModel)-1 ] = 0;
|
||||
#endif
|
||||
+#ifdef darwin
|
||||
+ strncpy(HRD_savedModel, HRD_model,
|
||||
+ sizeof(HRD_savedModel)-1);
|
||||
+ HRD_savedModel[ sizeof(HRD_savedModel)-1 ] = 0;
|
||||
+#endif
|
||||
}
|
||||
|
||||
static const char *
|
||||
@@ -900,6 +1034,104 @@
|
||||
result = ioctl(fd, DIOCGDINFO, &HRD_info);
|
||||
#endif
|
||||
|
||||
+#ifdef darwin
|
||||
+ DASessionRef sess_ref;
|
||||
+ DADiskRef disk;
|
||||
+ CFDictionaryRef desc;
|
||||
+ CFStringRef str_ref;
|
||||
+ CFNumberRef number_ref;
|
||||
+ CFBooleanRef bool_ref;
|
||||
+ CFStringEncoding sys_encoding = CFStringGetSystemEncoding();
|
||||
+
|
||||
+ sess_ref = DASessionCreate( NULL );
|
||||
+ if (NULL == sess_ref)
|
||||
+ return -1;
|
||||
+
|
||||
+ disk = DADiskCreateFromBSDName( NULL, sess_ref, devfull );
|
||||
+ if (NULL == disk) {
|
||||
+ CFRelease(sess_ref);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ desc = DADiskCopyDescription( disk );
|
||||
+ if (NULL == desc) {
|
||||
+ CFRelease(disk);
|
||||
+ CFRelease(sess_ref);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ number_ref = (CFNumberRef)
|
||||
+ CFDictionaryGetValue(desc, kDADiskDescriptionMediaSizeKey);
|
||||
+ if (number_ref)
|
||||
+ CFNumberGetValue(number_ref, kCFNumberSInt64Type, &HRD_cap);
|
||||
+ else
|
||||
+ HRD_cap = 0;
|
||||
+ DEBUGMSGTL(("verbose:diskmgr:darwin", " size %lld\n", HRD_cap));
|
||||
+
|
||||
+ /** writable? */
|
||||
+ bool_ref = (CFBooleanRef)
|
||||
+ CFDictionaryGetValue(desc, kDADiskDescriptionMediaWritableKey);
|
||||
+ if (bool_ref) {
|
||||
+ HRD_access = CFBooleanGetValue(bool_ref);
|
||||
+ }
|
||||
+ else
|
||||
+ HRD_access = 0;
|
||||
+ DEBUGMSGTL(("verbose:diskmgr:darwin", " writable %d\n",
|
||||
+ HRD_access));
|
||||
+
|
||||
+ /** removable? */
|
||||
+ bool_ref = (CFBooleanRef)
|
||||
+ CFDictionaryGetValue(desc, kDADiskDescriptionMediaRemovableKey);
|
||||
+ if (bool_ref) {
|
||||
+ HRD_removeble = CFBooleanGetValue(bool_ref);
|
||||
+ }
|
||||
+ else
|
||||
+ HRD_removeble = 0;
|
||||
+ DEBUGMSGTL(("verbose:diskmgr:darwin", " removable %d\n",
|
||||
+ HRD_removeble));
|
||||
+
|
||||
+ /** get type */
|
||||
+ str_ref = (CFStringRef)
|
||||
+ CFDictionaryGetValue(desc, kDADiskDescriptionMediaTypeKey);
|
||||
+ if (str_ref) {
|
||||
+ HRD_type = _get_type_value(CFStringGetCStringPtr(str_ref,
|
||||
+ sys_encoding));
|
||||
+ DEBUGMSGTL(("verbose:diskmgr:darwin", " type %s / %d\n",
|
||||
+ CFStringGetCStringPtr(str_ref, sys_encoding),
|
||||
+ HRD_type));
|
||||
+ }
|
||||
+ else {
|
||||
+ str_ref = (CFStringRef)
|
||||
+ CFDictionaryGetValue(desc, kDADiskDescriptionDeviceProtocolKey);
|
||||
+ if (str_ref) {
|
||||
+ HRD_type =
|
||||
+ _get_type_from_protocol(CFStringGetCStringPtr(str_ref,
|
||||
+ sys_encoding));
|
||||
+ DEBUGMSGTL(("verbose:diskmgr:darwin", " type %s / %d\n",
|
||||
+ CFStringGetCStringPtr(str_ref, sys_encoding),
|
||||
+ HRD_type));
|
||||
+ }
|
||||
+ else
|
||||
+ HRD_type = HRDISKSTORAGEMEDIA_UNKNOWN;
|
||||
+ }
|
||||
+
|
||||
+ /** model */
|
||||
+ str_ref = (CFStringRef)
|
||||
+ CFDictionaryGetValue(desc, kDADiskDescriptionDeviceModelKey);
|
||||
+ if (str_ref) {
|
||||
+ strncpy(HRD_model, CFStringGetCStringPtr(str_ref, sys_encoding),
|
||||
+ sizeof(HRD_model));
|
||||
+ HRD_savedModel[ sizeof(HRD_savedModel)-1 ] = 0;
|
||||
+ DEBUGMSGTL(("verbose:diskmgr:darwin", " model %s\n", HRD_model));
|
||||
+ }
|
||||
+ else
|
||||
+ HRD_model[0] = 0;
|
||||
+ CFRelease(disk);
|
||||
+ CFRelease(desc);
|
||||
+ CFRelease(sess_ref);
|
||||
+ result = 0;
|
||||
+#endif
|
||||
+
|
||||
return (result);
|
||||
}
|
||||
|
||||
@@ -918,6 +1150,11 @@
|
||||
return (2); /* read only */
|
||||
#endif
|
||||
|
||||
+#ifdef darwin
|
||||
+ if (!HRD_access)
|
||||
+ return (2);
|
||||
+#endif
|
||||
+
|
||||
return (1); /* read-write */
|
||||
}
|
||||
|
||||
@@ -990,6 +1227,9 @@
|
||||
}
|
||||
#endif
|
||||
|
||||
+#ifdef darwin
|
||||
+ return HRD_type;
|
||||
+#endif
|
||||
|
||||
return (2); /* Unknown */
|
||||
}
|
||||
@@ -1020,5 +1260,63 @@
|
||||
return (1); /* true */
|
||||
#endif
|
||||
|
||||
+#ifdef darwin
|
||||
+ if (HRD_removeble)
|
||||
+ return (1);
|
||||
+#endif
|
||||
+
|
||||
return (2); /* false */
|
||||
}
|
||||
+
|
||||
+#ifdef darwin
|
||||
+typedef struct type_value_map_s {
|
||||
+ const char *type;
|
||||
+ uint32_t value;
|
||||
+} type_value_map;
|
||||
+
|
||||
+static type_value_map media_type_map[] = {
|
||||
+ { "CD-ROM", HRDISKSTORAGEMEDIA_OPTICALDISKROM},
|
||||
+ { "DVD-R", HRDISKSTORAGEMEDIA_OPTICALDISKWORM},
|
||||
+ { "DVD+R", HRDISKSTORAGEMEDIA_OPTICALDISKWORM},
|
||||
+};
|
||||
+static int media_types = sizeof(media_type_map)/sizeof(media_type_map[0]);
|
||||
+
|
||||
+static int
|
||||
+_get_type_value( const char *str_type )
|
||||
+{
|
||||
+ int i, len;
|
||||
+
|
||||
+ if (NULL == str_type)
|
||||
+ return HRDISKSTORAGEMEDIA_UNKNOWN;
|
||||
+
|
||||
+ len = strlen(str_type);
|
||||
+ for(i=0; i < media_types; ++i) {
|
||||
+ if (0 == strcmp(media_type_map[i].type, str_type))
|
||||
+ return media_type_map[i].value;
|
||||
+ }
|
||||
+
|
||||
+ return HRDISKSTORAGEMEDIA_UNKNOWN;
|
||||
+}
|
||||
+
|
||||
+static type_value_map proto_map[] = {
|
||||
+ { "ATA", HRDISKSTORAGEMEDIA_HARDDISK},
|
||||
+ { "ATAPI", HRDISKSTORAGEMEDIA_OPTICALDISKROM}
|
||||
+};
|
||||
+static int proto_maps = sizeof(proto_map)/sizeof(proto_map[0]);
|
||||
+
|
||||
+static int _get_type_from_protocol( const char *prot )
|
||||
+{
|
||||
+ int i, len;
|
||||
+
|
||||
+ if (NULL == prot)
|
||||
+ return TV_FALSE;
|
||||
+
|
||||
+ len = strlen(prot);
|
||||
+ for(i=0; i < proto_maps; ++i) {
|
||||
+ if (0 == strcmp(proto_map[i].type, prot))
|
||||
+ return proto_map[i].value;
|
||||
+ }
|
||||
+
|
||||
+ return HRDISKSTORAGEMEDIA_UNKNOWN;
|
||||
+}
|
||||
+#endif
|
||||
@@ -0,0 +1,134 @@
|
||||
r16804 | magfr | 2008-02-14 02:37:48 +0300 (Чтв, 14 Фев 2008) | 2 lines
|
||||
|
||||
NEWS: snmplib: Change CONTAINER_INSERT to not do partial inserts in containers with multiple indices when one insert fails.
|
||||
|
||||
http://sourceforge.net/tracker/index.php?func=detail&aid=1733344&group_id=12694&atid=112694
|
||||
|
||||
http://bugs.gentoo.org/show_bug.cgi?id=203127
|
||||
|
||||
Index: snmplib/container.c
|
||||
===================================================================
|
||||
--- snmplib/container.c (revision 16803)
|
||||
+++ snmplib/container.c (revision 16804)
|
||||
@@ -282,31 +282,41 @@
|
||||
* These functions should EXACTLY match the inline version in
|
||||
* container.h. If you change one, change them both.
|
||||
*/
|
||||
-int CONTAINER_INSERT(netsnmp_container *x, const void *k)
|
||||
-{
|
||||
- int rc2, rc = 0;
|
||||
-
|
||||
- /** start at first container */
|
||||
- while(x->prev)
|
||||
- x = x->prev;
|
||||
- for(; x; x = x->next) {
|
||||
- if ((NULL != x->insert_filter) &&
|
||||
- (x->insert_filter(x,k) == 1))
|
||||
- continue;
|
||||
- rc2 = x->insert(x,k);
|
||||
- if (rc2) {
|
||||
+int CONTAINER_INSERT_HELPER(netsnmp_container* x, const void* k)
|
||||
+{
|
||||
+ while(x && x->insert_filter && x->insert_filter(x,k) == 1)
|
||||
+ x = x->next;
|
||||
+ if(x) {
|
||||
+ int rc = x->insert(x,k);
|
||||
+ if(rc)
|
||||
snmp_log(LOG_ERR,"error on subcontainer '%s' insert (%d)\n",
|
||||
- x->container_name ? x->container_name : "", rc2);
|
||||
- rc = rc2;
|
||||
+ x->container_name ? x->container_name : "", rc);
|
||||
+ else {
|
||||
+ rc = CONTAINER_INSERT_HELPER(x->next, k);
|
||||
+ if(rc)
|
||||
+ x->remove(x,k);
|
||||
}
|
||||
+ return rc;
|
||||
}
|
||||
- return rc;
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
* These functions should EXACTLY match the inline version in
|
||||
* container.h. If you change one, change them both.
|
||||
*/
|
||||
+int CONTAINER_INSERT(netsnmp_container* x, const void* k)
|
||||
+{
|
||||
+ /** start at first container */
|
||||
+ while(x->prev)
|
||||
+ x = x->prev;
|
||||
+ return CONTAINER_INSERT_HELPER(x, k);
|
||||
+}
|
||||
+
|
||||
+/*------------------------------------------------------------------
|
||||
+ * These functions should EXACTLY match the inline version in
|
||||
+ * container.h. If you change one, change them both.
|
||||
+ */
|
||||
int CONTAINER_REMOVE(netsnmp_container *x, const void *k)
|
||||
{
|
||||
int rc2, rc = 0;
|
||||
Index: include/net-snmp/library/container.h
|
||||
===================================================================
|
||||
--- include/net-snmp/library/container.h (revision 16803)
|
||||
+++ include/net-snmp/library/container.h (revision 16804)
|
||||
@@ -364,32 +364,43 @@
|
||||
* container.c. If you change one, change them both.
|
||||
*/
|
||||
NETSNMP_STATIC_INLINE /* gcc docs recommend static w/inline */
|
||||
- int CONTAINER_INSERT(netsnmp_container *x, const void *k)
|
||||
+ int CONTAINER_INSERT_HELPER(netsnmp_container* x, const void* k)
|
||||
{
|
||||
- int rc2, rc = 0;
|
||||
-
|
||||
- /** start at first container */
|
||||
- while(x->prev)
|
||||
- x = x->prev;
|
||||
- for(; x; x = x->next) {
|
||||
- if ((NULL != x->insert_filter) &&
|
||||
- (x->insert_filter(x,k) == 1))
|
||||
- continue;
|
||||
- rc2 = x->insert(x,k);
|
||||
- if (rc2) {
|
||||
+ while(x && x->insert_filter && x->insert_filter(x,k) == 1)
|
||||
+ x = x->next;
|
||||
+ if(x) {
|
||||
+ int rc = x->insert(x,k);
|
||||
+ if(rc)
|
||||
snmp_log(LOG_ERR,"error on subcontainer '%s' insert (%d)\n",
|
||||
- x->container_name ? x->container_name : "", rc2);
|
||||
- rc = rc2;
|
||||
+ x->container_name ? x->container_name : "", rc);
|
||||
+ else {
|
||||
+ rc = CONTAINER_INSERT_HELPER(x->next, k);
|
||||
+ if(rc)
|
||||
+ x->remove(x,k);
|
||||
}
|
||||
+ return rc;
|
||||
}
|
||||
- return rc;
|
||||
+ return 0;
|
||||
}
|
||||
-
|
||||
+
|
||||
/*------------------------------------------------------------------
|
||||
* These functions should EXACTLY match the function version in
|
||||
* container.c. If you change one, change them both.
|
||||
*/
|
||||
NETSNMP_STATIC_INLINE /* gcc docs recommend static w/inline */
|
||||
+ int CONTAINER_INSERT(netsnmp_container* x, const void* k)
|
||||
+ {
|
||||
+ /** start at first container */
|
||||
+ while(x->prev)
|
||||
+ x = x->prev;
|
||||
+ return CONTAINER_INSERT_HELPER(x, k);
|
||||
+ }
|
||||
+
|
||||
+ /*------------------------------------------------------------------
|
||||
+ * These functions should EXACTLY match the function version in
|
||||
+ * container.c. If you change one, change them both.
|
||||
+ */
|
||||
+ NETSNMP_STATIC_INLINE /* gcc docs recommend static w/inline */
|
||||
int CONTAINER_REMOVE(netsnmp_container *x, const void *k)
|
||||
{
|
||||
int rc2, rc = 0;
|
||||
@@ -0,0 +1,33 @@
|
||||
Index: net-snmp-5.4.1/configure.in
|
||||
===================================================================
|
||||
--- net-snmp-5.4.1.orig/configure.in
|
||||
+++ net-snmp-5.4.1/configure.in
|
||||
@@ -2,7 +2,7 @@
|
||||
# the Net-SNMP's COPYING file for more details and other copyrights
|
||||
# that may apply:
|
||||
#
|
||||
-# Portions Copyright <20> 2003 Sun Microsystems, Inc. All rights reserved.
|
||||
+# Portions Copyright © 2003 Sun Microsystems, Inc. All rights reserved.
|
||||
# Use is subject to license terms specified in the COPYING file
|
||||
# distributed with the Net-SNMP package.
|
||||
#
|
||||
@@ -3097,8 +3097,8 @@ fi
|
||||
|
||||
# check needed functions
|
||||
if test "x$embed_perl" != "xno" ; then
|
||||
- OLDLDFLAGS="$LDFLAGS"
|
||||
- LDFLAGS="$LDFLAGS $netsnmp_perlldopts"
|
||||
+ OLDLIBS="$LIBS"
|
||||
+ LIBS="$LIBS $netsnmp_perlldopts"
|
||||
|
||||
# newer perl vs older perl call functions
|
||||
AC_CHECK_FUNCS(eval_pv)
|
||||
@@ -3109,7 +3109,7 @@ if test "x$embed_perl" != "xno" ; then
|
||||
AC_CHECK_FUNC(perl_eval_pv, AC_DEFINE(HAVE_PERL_EVAL_PV_LC))
|
||||
AC_CHECK_FUNC(Perl_eval_pv, AC_DEFINE(HAVE_PERL_EVAL_PV_UC))
|
||||
|
||||
- LDFLAGS="$OLDLDFLAGS"
|
||||
+ LIBS="$OLDLIBS"
|
||||
|
||||
|
||||
if test "x$ac_cv_func_perl_eval_pv" != "xyes" -a "x$ac_cv_func_Perl_eval_pv" != "xyes" -a "x$ac_cv_func_eval_pv" != "xyes" ; then
|
||||
@@ -0,0 +1,52 @@
|
||||
r16705 | tanders | 2007-09-21 01:55:49 +0400 (Птн, 21 Сен 2007) | 3 lines
|
||||
|
||||
CHANGES: snmpd: PATCH: 1746831: from cunnijd: fix process checking race
|
||||
condition under Linux and platform #ifdefs
|
||||
|
||||
--- agent/mibgroup/ucd-snmp/proc.c (revision 16704)
|
||||
+++ agent/mibgroup/ucd-snmp/proc.c (revision 16705)
|
||||
@@ -427,7 +427,7 @@
|
||||
return count;
|
||||
}
|
||||
|
||||
-#elif OSTYPE == NETSNMP_LINUXID
|
||||
+#elif NETSNMP_OSTYPE == NETSNMP_LINUXID
|
||||
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
@@ -452,7 +452,7 @@
|
||||
#ifdef USE_PROC_CMDLINE /* old method */
|
||||
/* read /proc/XX/cmdline */
|
||||
sprintf(cmdline,"/proc/%s/cmdline",ent->d_name);
|
||||
- if((fd = open(cmdline, O_RDONLY)) < 0) break;
|
||||
+ if((fd = open(cmdline, O_RDONLY)) < 0) continue;
|
||||
len = read(fd,cmdline,sizeof(cmdline) - 1);
|
||||
close(fd);
|
||||
if(len <= 0) continue;
|
||||
@@ -464,7 +464,7 @@
|
||||
/* read /proc/XX/status */
|
||||
sprintf(cmdline,"/proc/%s/status",ent->d_name);
|
||||
if ((status = fopen(cmdline, "r")) == NULL)
|
||||
- break;
|
||||
+ continue;
|
||||
if (fgets(cmdline, sizeof(cmdline), status) == NULL) {
|
||||
fclose(status);
|
||||
break;
|
||||
@@ -507,7 +507,7 @@
|
||||
return total;
|
||||
}
|
||||
|
||||
-#elif OSTYPE == NETSNMP_ULTRIXID
|
||||
+#elif NETSNMP_OSTYPE == NETSNMP_ULTRIXID
|
||||
|
||||
#define NPROCS 32 /* number of proces to read at once */
|
||||
|
||||
@@ -688,7 +688,7 @@
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
-#elif OSTYPE == NETSNMP_SOLARISID
|
||||
+#elif NETSNMP_OSTYPE == NETSNMP_SOLARISID
|
||||
|
||||
#ifdef _SLASH_PROC_METHOD_
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
NEWS: agent: suppress annoying "registration != duplicate" warning for root oids
|
||||
(otherwise, you'll get this message on almost every startup)
|
||||
|
||||
http://net-snmp.svn.sourceforge.net/viewvc/net-snmp?view=rev&revision=16669
|
||||
|
||||
--- branches/V5-4-patches/net-snmp/agent/agent_registry.c 2007/08/20 08:06:42 16668
|
||||
+++ branches/V5-4-patches/net-snmp/agent/agent_registry.c 2007/08/22 21:56:23 16669
|
||||
@@ -532,7 +532,8 @@
|
||||
|
||||
if (next && (next->namelen == new_sub->namelen) &&
|
||||
(next->priority == new_sub->priority)) {
|
||||
- netsnmp_assert(!"registration != duplicate"); /* always false */
|
||||
+ if (new_sub->namelen != 1) /* ignore root OID dups */
|
||||
+ netsnmp_assert(!"registration != duplicate"); /* always false */
|
||||
return MIB_DUPLICATE_REGISTRATION;
|
||||
}
|
||||
|
||||
59
net-analyzer/net-snmp/files/net-snmp-5.4.1.1-rpm5-1.patch
Normal file
59
net-analyzer/net-snmp/files/net-snmp-5.4.1.1-rpm5-1.patch
Normal file
@@ -0,0 +1,59 @@
|
||||
Submitted By: Mario Fetka (mario dot fetka at gmail dot com)
|
||||
Date: 2008-11-04
|
||||
Initial Package Version: 5.4.1.1
|
||||
Origin: http://wraptastic.org/pub/jbj/rpm514-netsnmp-5.4.1.1.patch
|
||||
Upstream Status: unknown
|
||||
Description: hack to compile against rpm 5.1
|
||||
|
||||
diff -Naur net-snmp-5.4.1.1.orig/agent/mibgroup/host/hr_swinst.c net-snmp-5.4.1.1/agent/mibgroup/host/hr_swinst.c
|
||||
--- net-snmp-5.4.1.1.orig/agent/mibgroup/host/hr_swinst.c 2006-12-12 23:55:46.000000000 +0000
|
||||
+++ net-snmp-5.4.1.1/agent/mibgroup/host/hr_swinst.c 2008-11-03 23:19:29.305010591 +0000
|
||||
@@ -41,8 +41,10 @@
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBRPM
|
||||
+#include <stdio.h>
|
||||
+#include <stdint.h>
|
||||
#include <rpm/rpmlib.h>
|
||||
-#include <rpm/header.h>
|
||||
+#include <rpm/rpm4compat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef HAVE_RPMGETPATH
|
||||
@@ -465,6 +467,7 @@
|
||||
if ( headerGetEntry(swi->swi_h, RPMTAG_INSTALLTIME, NULL, (void **) &rpm_data, NULL) ) {
|
||||
time_t installTime = *rpm_data;
|
||||
ret = date_n_time(&installTime, var_len);
|
||||
+ free((void *)rpm_data);
|
||||
} else {
|
||||
ret = date_n_time(0, var_len);
|
||||
}
|
||||
@@ -661,6 +664,9 @@
|
||||
NULL);
|
||||
snprintf(swi->swi_name, sizeof(swi->swi_name), "%s-%s-%s", n, v, r);
|
||||
swi->swi_name[ sizeof(swi->swi_name)-1 ] = 0;
|
||||
+ free((void *)n);
|
||||
+ free((void *)v);
|
||||
+ free((void *)r);
|
||||
}
|
||||
#else
|
||||
snprintf(swi->swi_name, sizeof(swi->swi_name), swi->swi_dep->d_name);
|
||||
diff -Naur net-snmp-5.4.1.1.orig/configure.in net-snmp-5.4.1.1/configure.in
|
||||
--- net-snmp-5.4.1.1.orig/configure.in 2008-05-14 00:49:57.000000000 +0000
|
||||
+++ net-snmp-5.4.1.1/configure.in 2008-11-03 23:22:44.126003483 +0000
|
||||
@@ -2760,12 +2760,12 @@
|
||||
fi
|
||||
])
|
||||
|
||||
-AC_CHECK_HEADERS(rpm/rpmlib.h rpm/header.h)
|
||||
+AC_CHECK_HEADERS(rpm/rpmlib.h rpm/rpmtag.h)
|
||||
|
||||
AC_CHECK_HEADER(rpm/rpmlib.h,rpmlib_h=yes,rpmlib_h=no)
|
||||
-AC_CHECK_HEADER(rpm/header.h,rpmheader_h=yes,rpmheader_h=no)
|
||||
+AC_CHECK_HEADER(rpm/rpmtag.h,rpmtag_h=yes,rpmtag_h=no)
|
||||
|
||||
-if test "x$rpmheader_h" = "xno" -o "x$rpmlib_h" = "xno" ; then
|
||||
+if test "x$rpmtag_h" = "xno" -o "x$rpmlib_h" = "xno" ; then
|
||||
if test "x$with_rpm" = "xyes" ; then
|
||||
AC_MSG_ERROR([Could not find either the RPM header files needed and was specifically asked to use RPM support])
|
||||
else
|
||||
475
net-analyzer/net-snmp/files/net-snmp-lm_sensors.patch
Normal file
475
net-analyzer/net-snmp/files/net-snmp-lm_sensors.patch
Normal file
@@ -0,0 +1,475 @@
|
||||
diff -Naur net-snmp-5.1.1.old/agent/mibgroup/host/hr_sensor.c net-snmp-5.1.1/agent/mibgroup/host/hr_sensor.c
|
||||
--- net-snmp-5.1.1.old/agent/mibgroup/host/hr_sensor.c 1970-01-01 02:00:00.000000000 +0200
|
||||
+++ net-snmp-5.1.1/agent/mibgroup/host/hr_sensor.c 2003-10-21 12:49:57.000000000 +0300
|
||||
@@ -0,0 +1,322 @@
|
||||
+/* This file was generated by mib2c and is intended for use as a mib module
|
||||
+ for the ucd-snmp snmpd agent. */
|
||||
+
|
||||
+#include <net-snmp/net-snmp-config.h>
|
||||
+
|
||||
+#include <stdio.h>
|
||||
+#if HAVE_STDLIB_H
|
||||
+#include <stdlib.h>
|
||||
+#endif
|
||||
+#if HAVE_STRING_H
|
||||
+#include <string.h>
|
||||
+#else
|
||||
+#include <strings.h>
|
||||
+#endif
|
||||
+
|
||||
+#include <getopt.h>
|
||||
+#include <errno.h>
|
||||
+#include <dlfcn.h>
|
||||
+
|
||||
+#include "sensors/sensors.h"
|
||||
+#include "sensors/error.h"
|
||||
+
|
||||
+#include "host_res.h"
|
||||
+#include "hr_sensor.h"
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * hr_sensor_variables_oid:
|
||||
+ * this is the top level oid that we want to register under. This
|
||||
+ * is essentially a prefix, with the suffix appearing in the
|
||||
+ * variable below.
|
||||
+ */
|
||||
+
|
||||
+
|
||||
+oid hr_sensor_variables_oid[] = { 1,3,6,1,2,1,25,8 };
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * variable2 hr_sensor_variables:
|
||||
+ * this variable defines function callbacks and type return information
|
||||
+ * for the hr_sensor mib section
|
||||
+ */
|
||||
+
|
||||
+
|
||||
+struct variable2 hr_sensor_variables[] = {
|
||||
+ /* magic number , variable type , ro/rw , callback fn , L, oidsuffix */
|
||||
+#define HRSENSORMAPPING 2
|
||||
+ { HRSENSORMAPPING, ASN_INTEGER , RONLY , var_hr_sensor, 2, { 1,1 } },
|
||||
+#define HRSENSORNUMBER 3
|
||||
+ { HRSENSORNUMBER, ASN_INTEGER , RONLY , var_hr_sensor, 2, { 1,2 } },
|
||||
+#define HRSENSORNAME 4
|
||||
+ { HRSENSORNAME , ASN_OCTET_STR , RONLY , var_hr_sensor, 2, { 1,3 } },
|
||||
+#define HRSENSORLABEL 5
|
||||
+ { HRSENSORLABEL , ASN_OCTET_STR , RONLY , var_hr_sensor, 2, { 1,4 } },
|
||||
+#define HRSENSORVALUE 6
|
||||
+ { HRSENSORVALUE , ASN_OCTET_STR , RONLY , var_hr_sensor, 2, { 1,5 } },
|
||||
+
|
||||
+};
|
||||
+/* (L = length of the oidsuffix) */
|
||||
+
|
||||
+
|
||||
+#define DEFAULT_CONFIG_FILE_NAME "sensors.conf"
|
||||
+
|
||||
+static char *config_file_name;
|
||||
+FILE *config_file;
|
||||
+static const char *config_file_path[] =
|
||||
+{ "/etc", "/usr/lib/sensors", "/usr/local/lib/sensors", "/usr/lib",
|
||||
+ "/usr/local/lib", ".", 0 };
|
||||
+
|
||||
+static void open_config_file(void);
|
||||
+static int open_this_config_file(char *filename);
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * functions that are dynamically loaded if the lm_sensors library is
|
||||
+ * installed.
|
||||
+ */
|
||||
+static int (*sensors_get_label_dl)(sensors_chip_name name, int feature,
|
||||
+ char **result);
|
||||
+static int (*sensors_init_dl)(FILE *input);
|
||||
+static int (*sensors_get_feature_dl)(sensors_chip_name name, int feature,
|
||||
+ double *result);
|
||||
+static const sensors_feature_data *(*sensors_get_all_features_dl)
|
||||
+ (sensors_chip_name name, int *nr1,int *nr2);
|
||||
+static const sensors_chip_name *(*sensors_get_detected_chips_dl)(int *nr);
|
||||
+
|
||||
+#define CHIPS_MAX 20
|
||||
+static sensors_chip_name chips[CHIPS_MAX];
|
||||
+static int chips_count=0;
|
||||
+static int do_sets;
|
||||
+
|
||||
+/* This examines global var config_file, and leaves the name there too.
|
||||
+ It also opens config_file. */
|
||||
+static void open_config_file(void)
|
||||
+{
|
||||
+#define MAX_FILENAME_LEN 1024
|
||||
+ char *filename;
|
||||
+ char buffer[MAX_FILENAME_LEN];
|
||||
+ int res,i;
|
||||
+
|
||||
+ if (config_file_name && !strcmp(config_file_name,"-")) {
|
||||
+ config_file = stdin;
|
||||
+ return;
|
||||
+ } else if (config_file_name && index(config_file_name,'/')) {
|
||||
+ if ((res = open_this_config_file(config_file_name))) {
|
||||
+ fprintf(stderr,"Could not locate or open config file\n");
|
||||
+ fprintf(stderr,"%s: %s\n",config_file_name,strerror(res));
|
||||
+ exit(1);
|
||||
+ }
|
||||
+ }
|
||||
+ else {
|
||||
+ if (config_file_name)
|
||||
+ filename = config_file_name;
|
||||
+ else
|
||||
+ filename = strdup(DEFAULT_CONFIG_FILE_NAME);
|
||||
+ for (i = 0; config_file_path[i]; i++) {
|
||||
+ if ((snprintf(buffer,MAX_FILENAME_LEN,
|
||||
+ "%s/%s",config_file_path[i],filename)) < 1) {
|
||||
+ fprintf(stderr,
|
||||
+ "open_config_file: ridiculous long config file name!\n");
|
||||
+ exit(1);
|
||||
+ }
|
||||
+ if (!open_this_config_file(buffer)) {
|
||||
+ free(config_file_name);
|
||||
+ config_file_name = strdup(buffer);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ fprintf(stderr,"Could not locate or open config file!\n");
|
||||
+ exit(1);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int open_this_config_file(char *filename)
|
||||
+{
|
||||
+ config_file = fopen(filename,"r");
|
||||
+ if (! config_file)
|
||||
+ return -errno;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static long *sensor_tbl = 0;
|
||||
+sensors_chip_name *chip_tbl = 0;
|
||||
+static int sensor_maxnum = 0;
|
||||
+
|
||||
+static void do_register(sensors_chip_name name)
|
||||
+{
|
||||
+ const char *algo,*adap;
|
||||
+
|
||||
+ {
|
||||
+ const sensors_feature_data *sensor;
|
||||
+ const char *map=0;
|
||||
+ int index0 = 0, index1 = 0;
|
||||
+
|
||||
+ printf("%s\n", name);
|
||||
+
|
||||
+ while ((sensor = sensors_get_all_features_dl (name, &index0, &index1))
|
||||
+ != NULL) {
|
||||
+ if(sensor_tbl = realloc(sensor_tbl, sizeof(long) * (sensor_maxnum+2)))
|
||||
+ sensor_tbl[sensor_maxnum] = sensor->number;
|
||||
+ if (chip_tbl = realloc(chip_tbl, sizeof(sensors_chip_name) * (sensor_maxnum+2)))
|
||||
+ chip_tbl[sensor_maxnum] = name;
|
||||
+ sensor_maxnum++;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * init_hr_sensor():
|
||||
+ * Initialization routine. This is called when the agent starts up.
|
||||
+ * At a minimum, registration of your variables should take place here.
|
||||
+ */
|
||||
+void init_hr_sensor(void) {
|
||||
+
|
||||
+ const sensors_chip_name *chip;
|
||||
+ int chip_nr,i;
|
||||
+ int c,res;
|
||||
+ void *sensors_library;
|
||||
+
|
||||
+ /* This could probably due with a bit more error reporting. */
|
||||
+ sensors_library=dlopen("libsensors.so",RTLD_LAZY);
|
||||
+ if(sensors_library==NULL)
|
||||
+ return; // return before anything is registered
|
||||
+
|
||||
+ sensors_get_label_dl=dlsym(sensors_library,"sensors_get_label");
|
||||
+ sensors_init_dl=dlsym(sensors_library,"sensors_init");
|
||||
+ sensors_get_feature_dl=dlsym(sensors_library,"sensors_get_feature");
|
||||
+ sensors_get_all_features_dl=dlsym(sensors_library,
|
||||
+ "sensors_get_all_features");
|
||||
+ sensors_get_detected_chips_dl=dlsym(sensors_library,
|
||||
+ "sensors_get_detected_chips");
|
||||
+ if(sensors_get_label_dl==NULL || sensors_init_dl==NULL ||
|
||||
+ sensors_get_feature_dl==NULL || sensors_get_all_features_dl==NULL ||
|
||||
+ sensors_get_detected_chips_dl==NULL)
|
||||
+ return; // return before anything is registered
|
||||
+
|
||||
+ /* register ourselves with the agent to handle our mib tree */
|
||||
+ REGISTER_MIB("hr_sensor", hr_sensor_variables, variable2,
|
||||
+ hr_sensor_variables_oid);
|
||||
+
|
||||
+
|
||||
+ /* place any other initialization junk you need here */
|
||||
+
|
||||
+
|
||||
+ chips[0].prefix = SENSORS_CHIP_NAME_PREFIX_ANY;
|
||||
+ chips[0].bus = SENSORS_CHIP_NAME_BUS_ANY;
|
||||
+ chips[0].addr = SENSORS_CHIP_NAME_ADDR_ANY;
|
||||
+ chips_count = 1;
|
||||
+
|
||||
+ open_config_file();
|
||||
+
|
||||
+ if ((res = sensors_init_dl(config_file))) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ for (chip_nr = 0; (chip = sensors_get_detected_chips_dl(&chip_nr));)
|
||||
+ do_register (*chip);
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/*
|
||||
+ * var_hr_sensor():
|
||||
+ * This function is called every time the agent gets a request for
|
||||
+ * a scalar variable that might be found within your mib section
|
||||
+ * registered above. It is up to you to do the right thing and
|
||||
+ * return the correct value.
|
||||
+ * You should also correct the value of "var_len" if necessary.
|
||||
+ *
|
||||
+ * Please see the documentation for more information about writing
|
||||
+ * module extensions, and check out the examples in the examples
|
||||
+ * and mibII directories.
|
||||
+ */
|
||||
+unsigned char *
|
||||
+var_hr_sensor(struct variable *vp,
|
||||
+ oid *name,
|
||||
+ size_t *length,
|
||||
+ int exact,
|
||||
+ size_t *var_len,
|
||||
+ WriteMethod **write_method)
|
||||
+{
|
||||
+ /* variables we may use later */
|
||||
+ static long long_ret;
|
||||
+ static char *string = 0;
|
||||
+ static oid objid[MAX_OID_LEN];
|
||||
+ static struct counter64 c64;
|
||||
+
|
||||
+ const sensors_feature_data *sensor;
|
||||
+ const char *map=0;
|
||||
+ int index0 = 0, index1 = 0;
|
||||
+ int sensor_idx = 0, sensor_num = 0;
|
||||
+ sensors_chip_name chip_name;
|
||||
+ double value;
|
||||
+
|
||||
+
|
||||
+ if (header_simple_table(vp,name,length,exact,var_len,write_method,sensor_maxnum)
|
||||
+ == MATCH_FAILED )
|
||||
+ return NULL;
|
||||
+
|
||||
+ sensor_idx = name[*length - 1] - 1;
|
||||
+ sensor_num = sensor_tbl[sensor_idx];
|
||||
+ chip_name = chip_tbl[sensor_idx];
|
||||
+
|
||||
+ while ((sensor = sensors_get_all_features_dl (chip_name, &index0, &index1))
|
||||
+ != NULL) {
|
||||
+ if(sensor_num == sensor->number) {
|
||||
+ /*
|
||||
+ * this is where we do the value assignments for the mib results.
|
||||
+ */
|
||||
+ switch(vp->magic) {
|
||||
+
|
||||
+
|
||||
+ case HRSENSORMAPPING:
|
||||
+
|
||||
+ long_ret = sensor->mapping;
|
||||
+ return (unsigned char *) &long_ret;
|
||||
+
|
||||
+ case HRSENSORNUMBER:
|
||||
+
|
||||
+ long_ret = sensor_num;
|
||||
+ return (unsigned char *) &long_ret;
|
||||
+
|
||||
+ case HRSENSORNAME:
|
||||
+
|
||||
+ string = malloc(SPRINT_MAX_LEN);
|
||||
+ strncpy(string, sensor->name, SPRINT_MAX_LEN);
|
||||
+ *var_len = strlen(string);
|
||||
+ return (unsigned char *) string;
|
||||
+
|
||||
+ case HRSENSORLABEL:
|
||||
+
|
||||
+ string = malloc(SPRINT_MAX_LEN);
|
||||
+
|
||||
+ if (sensors_get_label_dl (chip_name, sensor->number, &string)) {
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ *var_len = strlen(string);
|
||||
+ return (unsigned char *) string;
|
||||
+
|
||||
+ case HRSENSORVALUE:
|
||||
+
|
||||
+ if (!(sensor->mode & SENSORS_MODE_R)) {
|
||||
+ return 0;
|
||||
+ } else if (!(sensor->mode & SENSORS_MODE_R)) {
|
||||
+ return 0;
|
||||
+ } else if (sensors_get_feature_dl (chip_name, sensor->number, &value)){
|
||||
+ return 0;
|
||||
+ }
|
||||
+ string = malloc(SPRINT_MAX_LEN);
|
||||
+ snprintf(string, SPRINT_MAX_LEN, "%f", value);
|
||||
+ *var_len = strlen(string);
|
||||
+ return (unsigned char *) string;
|
||||
+
|
||||
+ default:
|
||||
+ ERROR_MSG("");
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
diff -Naur net-snmp-5.1.1.old/agent/mibgroup/host/hr_sensor.h net-snmp-5.1.1/agent/mibgroup/host/hr_sensor.h
|
||||
--- net-snmp-5.1.1.old/agent/mibgroup/host/hr_sensor.h 1970-01-01 02:00:00.000000000 +0200
|
||||
+++ net-snmp-5.1.1/agent/mibgroup/host/hr_sensor.h 2003-10-21 12:47:04.000000000 +0300
|
||||
@@ -0,0 +1,24 @@
|
||||
+/* This file was generated by mib2c and is intended for use as a mib module
|
||||
+ for the ucd-snmp snmpd agent. */
|
||||
+
|
||||
+
|
||||
+#ifndef _MIBGROUP_HRSENSOR_H
|
||||
+#define _MIBGROUP_HRSENSOR_H
|
||||
+
|
||||
+
|
||||
+/* we may use header_generic and header_simple_table from the util_funcs module */
|
||||
+
|
||||
+
|
||||
+config_require(util_funcs)
|
||||
+
|
||||
+
|
||||
+/* function prototypes */
|
||||
+
|
||||
+
|
||||
+extern void init_hr_sensor(void);
|
||||
+extern FindVarMethod var_hr_sensor;
|
||||
+
|
||||
+
|
||||
+
|
||||
+
|
||||
+#endif /* _MIBGROUP_HRSENSOR_H */
|
||||
diff -Naur net-snmp-5.1.1.old/agent/mibgroup/host.h net-snmp-5.1.1/agent/mibgroup/host.h
|
||||
--- net-snmp-5.1.1.old/agent/mibgroup/host.h 2002-04-20 10:30:00.000000000 +0300
|
||||
+++ net-snmp-5.1.1/agent/mibgroup/host.h 2003-10-21 12:47:04.000000000 +0300
|
||||
@@ -15,6 +15,7 @@
|
||||
config_require(host/hr_filesys)
|
||||
config_require(host/hr_swrun)
|
||||
config_require(host/hr_swinst)
|
||||
+ config_require(host/hr_sensor)
|
||||
|
||||
/* add the host resources mib to the default mibs to load */
|
||||
config_add_mib(HOST-RESOURCES-MIB)
|
||||
diff -Naur net-snmp-5.1.1.old/mibs/HOST-RESOURCES-MIB.txt net-snmp-5.1.1/mibs/HOST-RESOURCES-MIB.txt
|
||||
--- net-snmp-5.1.1.old/mibs/HOST-RESOURCES-MIB.txt 2002-04-20 10:30:15.000000000 +0300
|
||||
+++ net-snmp-5.1.1/mibs/HOST-RESOURCES-MIB.txt 2003-10-21 12:47:04.000000000 +0300
|
||||
@@ -106,6 +106,7 @@
|
||||
hrSWRunPerf OBJECT IDENTIFIER ::= { host 5 }
|
||||
hrSWInstalled OBJECT IDENTIFIER ::= { host 6 }
|
||||
hrMIBAdminInfo OBJECT IDENTIFIER ::= { host 7 }
|
||||
+hrSensor OBJECT IDENTIFIER ::= { host 8 }
|
||||
|
||||
-- textual conventions
|
||||
|
||||
@@ -1390,6 +1391,66 @@
|
||||
(hex)'00 00 01 01 00 00 00 00'."
|
||||
::= { hrSWInstalledEntry 5 }
|
||||
|
||||
+
|
||||
+hrSensorEntry OBJECT-TYPE
|
||||
+ SYNTAX hrSensorEntry
|
||||
+ MAX-ACCESS not-accessible
|
||||
+ STATUS current
|
||||
+ DESCRIPTION
|
||||
+ "The CPU temperature sensor settings."
|
||||
+ INDEX { hrSensor }
|
||||
+ ::= { hrSensor 1 }
|
||||
+
|
||||
+hrSensorEntry ::= SEQUENCE {
|
||||
+ hrSensorNumber Integer32,
|
||||
+ hrSensorMapping Integer32,
|
||||
+ hrSensorName DisplayString,
|
||||
+ hrSensorLabel DisplayString,
|
||||
+ hrSensorValue DisplayString
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+
|
||||
+hrSensorMapping OBJECT-TYPE
|
||||
+ SYNTAX Integer32 (1..2147483647)
|
||||
+ MAX-ACCESS read-only
|
||||
+ STATUS current
|
||||
+ DESCRIPTION
|
||||
+ "The mapping"
|
||||
+ ::= { hrSensorEntry 1 }
|
||||
+
|
||||
+hrSensorNumber OBJECT-TYPE
|
||||
+ SYNTAX Integer32 (1..2147483647)
|
||||
+ MAX-ACCESS read-only
|
||||
+ STATUS current
|
||||
+ DESCRIPTION
|
||||
+ "The Number"
|
||||
+ ::= { hrSensorEntry 2 }
|
||||
+
|
||||
+hrSensorName OBJECT-TYPE
|
||||
+ SYNTAX DisplayString
|
||||
+ MAX-ACCESS read-only
|
||||
+ STATUS current
|
||||
+ DESCRIPTION
|
||||
+ "The name of the sensor."
|
||||
+ ::= { hrSensorEntry 3 }
|
||||
+
|
||||
+hrSensorLabel OBJECT-TYPE
|
||||
+ SYNTAX DisplayString
|
||||
+ MAX-ACCESS read-only
|
||||
+ STATUS current
|
||||
+ DESCRIPTION
|
||||
+ "The label of the sensor."
|
||||
+ ::= { hrSensorEntry 4 }
|
||||
+
|
||||
+hrSensorValue OBJECT-TYPE
|
||||
+ SYNTAX DisplayString
|
||||
+ MAX-ACCESS read-only
|
||||
+ STATUS current
|
||||
+ DESCRIPTION
|
||||
+ "The value of the sensor"
|
||||
+ ::= { hrSensorEntry 5 }
|
||||
+
|
||||
-- Conformance information
|
||||
|
||||
hrMIBCompliances OBJECT IDENTIFIER ::= { hrMIBAdminInfo 2 }
|
||||
@@ -1456,6 +1517,13 @@
|
||||
"The Installed Software Group.
|
||||
Implementation of this group is at the discretion
|
||||
of the implementor."
|
||||
+
|
||||
+ GROUP hrSensorGroup
|
||||
+ DESCRIPTION
|
||||
+ "The Sensors Group.
|
||||
+ Implementation of this group is at the discretion
|
||||
+ of the implementor."
|
||||
+
|
||||
::= { hrMIBCompliances 1 }
|
||||
|
||||
hrSystemGroup OBJECT-GROUP
|
||||
@@ -1537,4 +1605,17 @@
|
||||
"The Host Resources Installed Software Group."
|
||||
::= { hrMIBGroups 6 }
|
||||
|
||||
+ hrSensorGroup OBJECT-GROUP
|
||||
+ OBJECTS {
|
||||
+ hrSensorEntry,
|
||||
+ hrSensorNumber,
|
||||
+ hrSensorMapping,
|
||||
+ hrSensorName,
|
||||
+ hrSensorLabel,
|
||||
+ hrSensorValue
|
||||
+ }
|
||||
+ STATUS current
|
||||
+ DESCRIPTION
|
||||
+ "The Sensor Resources Group."
|
||||
+ ::= { hrMIBGroups 7 }
|
||||
END
|
||||
17
net-analyzer/net-snmp/files/snmpd.conf
Normal file
17
net-analyzer/net-snmp/files/snmpd.conf
Normal file
@@ -0,0 +1,17 @@
|
||||
# Copyright 1999-2004 Gentoo Foundation
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
# $Header: /var/cvsroot/gentoo-x86/net-analyzer/net-snmp/files/snmpd.conf,v 1.8 2006/11/26 21:37:22 cedk Exp $
|
||||
|
||||
# Initial (empty) options.
|
||||
SNMPD_FLAGS=""
|
||||
|
||||
# Enable connection logging.
|
||||
#SNMPD_FLAGS="${SNMPD_FLAGS} -a"
|
||||
|
||||
# Enable syslog and disable file log.
|
||||
#SNMPD_FLAGS="${SNMPD_FLAGS} -Lsd -Lf /dev/null"
|
||||
|
||||
# Enable agentx socket as /var/agentx/master
|
||||
# *NOTE* Before uncommenting this, make sure
|
||||
# the /var/agentx directory exists.
|
||||
#SNMPD_FLAGS="${SNMPD_FLAGS} -x /var/agentx/master"
|
||||
30
net-analyzer/net-snmp/files/snmpd.rc7
Normal file
30
net-analyzer/net-snmp/files/snmpd.rc7
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/sbin/runscript
|
||||
# Copyright 1999-2004 Gentoo Foundation
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
# $Header: /var/cvsroot/gentoo-x86/net-analyzer/net-snmp/files/snmpd.rc7,v 1.1 2006/11/26 21:37:22 cedk Exp $
|
||||
|
||||
depend() {
|
||||
use logger
|
||||
need net
|
||||
}
|
||||
|
||||
checkconfig() {
|
||||
if [ ! -e /etc/snmp/snmpd.conf ] ; then
|
||||
eerror "You need an /etc/snmp/snmpd.conf config file to run snmpd"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
start() {
|
||||
checkconfig || return 1
|
||||
ebegin "Starting net-snmpd"
|
||||
start-stop-daemon --start --quiet --exec /usr/sbin/snmpd \
|
||||
-- -p /var/run/snmpd.pid ${SNMPD_FLAGS}
|
||||
eend $?
|
||||
}
|
||||
|
||||
stop() {
|
||||
ebegin "Stopping net-snmpd"
|
||||
start-stop-daemon --stop --quiet --pidfile /var/run/snmpd.pid
|
||||
eend $?
|
||||
}
|
||||
16
net-analyzer/net-snmp/files/snmptrapd.conf
Normal file
16
net-analyzer/net-snmp/files/snmptrapd.conf
Normal file
@@ -0,0 +1,16 @@
|
||||
# Copyright 1999-2005 Gentoo Foundation
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
# $Header: /var/cvsroot/gentoo-x86/net-analyzer/net-snmp/files/snmptrapd.conf,v 1.1 2005/01/28 11:19:25 ka0ttic Exp $
|
||||
|
||||
# extra flags to pass to snmptrapd
|
||||
SNMPTRAPD_FLAGS=""
|
||||
|
||||
# ignore authentication failure traps
|
||||
#SNMPTRAPD_FLAGS="${SNMPTRAPD_FLAGS} -a"
|
||||
|
||||
# log messages to specified file
|
||||
#SNMPTRAPD_FLAGS="${SNMPTRAPD_FLAGS} -Lf /var/log/snmptrapd.log"
|
||||
|
||||
# log messages to syslog with the specified facility
|
||||
# where facility is: 'd' = LOG_DAEMON, 'u' = LOG_USER, [0-7] = LOG_LOCAL[0-7]
|
||||
#SNMPTRAPD_FLAGS="${SNMPTRAPD_FLAGS} -Ls d"
|
||||
22
net-analyzer/net-snmp/files/snmptrapd.rc7
Normal file
22
net-analyzer/net-snmp/files/snmptrapd.rc7
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/sbin/runscript
|
||||
# Copyright 1999-2004 Gentoo Foundation
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
# $Header: /var/cvsroot/gentoo-x86/net-analyzer/net-snmp/files/snmptrapd.rc7,v 1.1 2006/11/26 21:37:22 cedk Exp $
|
||||
|
||||
depend() {
|
||||
use logger
|
||||
need net
|
||||
}
|
||||
|
||||
start() {
|
||||
ebegin "Starting snmptrapd"
|
||||
start-stop-daemon --start --quiet --exec /usr/sbin/snmptrapd \
|
||||
-- -p /var/run/snmptrapd.pid ${SNMPTRAPD_FLAGS}
|
||||
eend $?
|
||||
}
|
||||
|
||||
stop() {
|
||||
ebegin "Stopping snmptrapd"
|
||||
start-stop-daemon --stop --quiet --pidfile /var/run/snmptrapd.pid
|
||||
eend $?
|
||||
}
|
||||
Reference in New Issue
Block a user