parent
772e0fd228
commit
50cbbbf506
@ -0,0 +1,48 @@
|
||||
From 7330e3e3e08d9baff23332e764f9a53561939fff Mon Sep 17 00:00:00 2001
|
||||
From: Bart Van Assche <bvanassche@acm.org>
|
||||
Date: Thu, 2 Sep 2021 21:06:54 -0700
|
||||
Subject: [PATCH] libsnmp: Log "Truncating integer value >32 bits" once
|
||||
|
||||
Log this message once instead of every time sysUpTime and/or
|
||||
hrSystemUptime are accessed after snmpd is running for more than 497 days.
|
||||
|
||||
Fixes: https://github.com/net-snmp/net-snmp/issues/144
|
||||
---
|
||||
snmplib/snmp_client.c | 9 ++++++---
|
||||
1 file changed, 6 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/snmplib/snmp_client.c b/snmplib/snmp_client.c
|
||||
index 0f539c63fe..b00670d973 100644
|
||||
--- a/snmplib/snmp_client.c
|
||||
+++ b/snmplib/snmp_client.c
|
||||
@@ -853,7 +853,8 @@ snmp_set_var_value(netsnmp_variable_list * vars,
|
||||
= (const u_long *) value;
|
||||
*(vars->val.integer) = *val_ulong;
|
||||
if (*(vars->val.integer) > 0xffffffff) {
|
||||
- snmp_log(LOG_ERR,"truncating integer value > 32 bits\n");
|
||||
+ NETSNMP_LOGONCE((LOG_INFO,
|
||||
+ "truncating integer value > 32 bits\n"));
|
||||
*(vars->val.integer) &= 0xffffffff;
|
||||
}
|
||||
}
|
||||
@@ -865,7 +866,8 @@ snmp_set_var_value(netsnmp_variable_list * vars,
|
||||
= (const unsigned long long *) value;
|
||||
*(vars->val.integer) = (long) *val_ullong;
|
||||
if (*(vars->val.integer) > 0xffffffff) {
|
||||
- snmp_log(LOG_ERR,"truncating integer value > 32 bits\n");
|
||||
+ NETSNMP_LOGONCE((LOG_INFO,
|
||||
+ "truncating integer value > 32 bits\n"));
|
||||
*(vars->val.integer) &= 0xffffffff;
|
||||
}
|
||||
}
|
||||
@@ -877,7 +879,8 @@ snmp_set_var_value(netsnmp_variable_list * vars,
|
||||
= (const uintmax_t *) value;
|
||||
*(vars->val.integer) = (long) *val_uintmax_t;
|
||||
if (*(vars->val.integer) > 0xffffffff) {
|
||||
- snmp_log(LOG_ERR,"truncating integer value > 32 bits\n");
|
||||
+ NETSNMP_LOGONCE((LOG_INFO,
|
||||
+ "truncating integer value > 32 bits\n"));
|
||||
*(vars->val.integer) &= 0xffffffff;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,42 @@
|
||||
diff -urNp a/agent/mibgroup/host/data_access/swinst_rpm.c b/agent/mibgroup/host/data_access/swinst_rpm.c
|
||||
--- a/agent/mibgroup/host/data_access/swinst_rpm.c 2023-10-23 16:59:37.392368620 +0200
|
||||
+++ b/agent/mibgroup/host/data_access/swinst_rpm.c 2023-10-23 17:01:59.760640169 +0200
|
||||
@@ -73,15 +73,21 @@ netsnmp_swinst_arch_init(void)
|
||||
#endif
|
||||
|
||||
snprintf( pkg_directory, SNMP_MAXPATH, "%s/Packages", dbpath );
|
||||
+ if (-1 == stat( pkg_directory, &stat_buf )) {
|
||||
+
|
||||
+ /* check for SQLite DB backend */
|
||||
+ snprintf( pkg_directory, SNMP_MAXPATH, "%s/rpmdb.sqlite", dbpath );
|
||||
+
|
||||
+ if (-1 == stat( pkg_directory, &stat_buf )) {
|
||||
+ snmp_log(LOG_ERR, "Can't find directory of RPM packages\n");
|
||||
+ pkg_directory[0] = '\0';
|
||||
+ }
|
||||
+ }
|
||||
SNMP_FREE(rpmdbpath);
|
||||
dbpath = NULL;
|
||||
#ifdef HAVE_RPMGETPATH
|
||||
rpmFreeRpmrc();
|
||||
#endif
|
||||
- if (-1 == stat( pkg_directory, &stat_buf )) {
|
||||
- snmp_log(LOG_ERR, "Can't find directory of RPM packages");
|
||||
- pkg_directory[0] = '\0';
|
||||
- }
|
||||
}
|
||||
|
||||
void
|
||||
diff -urNp a/agent/mibgroup/host/hr_swinst.c b/agent/mibgroup/host/hr_swinst.c
|
||||
--- a/agent/mibgroup/host/hr_swinst.c 2023-10-23 16:59:37.391368611 +0200
|
||||
+++ b/agent/mibgroup/host/hr_swinst.c 2023-10-23 17:02:47.159063503 +0200
|
||||
@@ -229,6 +229,9 @@ init_hr_swinst(void)
|
||||
snprintf(path, sizeof(path), "%s/Packages", swi->swi_dbpath);
|
||||
if (stat(path, &stat_buf) == -1)
|
||||
snprintf(path, sizeof(path), "%s/packages.rpm", swi->swi_dbpath);
|
||||
+ /* check for SQLite DB backend */
|
||||
+ if (stat(path, &stat_buf) == -1)
|
||||
+ snprintf(path, sizeof(path), "%s/rpmdb.sqlite", swi->swi_dbpath);
|
||||
path[ sizeof(path)-1 ] = 0;
|
||||
swi->swi_directory = strdup(path);
|
||||
#ifdef HAVE_RPMGETPATH
|
Loading…
Reference in new issue