[PATCH / request for votes] Cannot statfs net:[********]#***: No such file or directory logged twice per every 10 minutes

Josef Ridky <[email protected]>
Newsgroups gmane.network.net-snmp.devel
Message-ID <[email protected]>
Error log is written twice when processing /proc/mtab and calling statfs() for each line in it. It stumbles upon this line:

proc net:[4026532288] proc rw,nosuid,nodev,noexec,relatime 0 0

Looking into the code, "Cannot statfs %s" is logged with "error" level. snmpd should log the error only once. 

See https://sourceforge.net/p/net-snmp/bugs/2870/
---
diff -urNp old/agent/mibgroup/hardware/fsys/fsys_mntctl.c new/agent/mibgroup/hardware/fsys/fsys_mntctl.c
--- old/agent/mibgroup/hardware/fsys/fsys_mntctl.c	2017-10-11 14:54:48.111065174 +0200
+++ new/agent/mibgroup/hardware/fsys/fsys_mntctl.c	2017-10-11 15:11:16.996918197 +0200
@@ -88,7 +88,6 @@ netsnmp_fsys_arch_load( void )
     char          *path;
     struct statfs  stat_buf;
     netsnmp_fsys_info *entry;
-    char               tmpbuf[1024];
 
     /*
      * Retrieve information about the currently mounted filesystems...
@@ -160,8 +159,7 @@ netsnmp_fsys_arch_load( void )
             continue;
 
         if ( statfs( entry->path, &stat_buf ) < 0 ) {
-            snprintf( tmpbuf, sizeof(tmpbuf), "Cannot statfs %s\n", entry->path );
-            snmp_log_perror( tmpbuf );
+            NETSNMP_LOGONCE(( LOG_ERROR, "Cannot statfs %s\n", entry->path ));
             continue;
         }
         entry->units =  stat_buf.f_bsize;
---

Josef Ridky
Associate Software Engineer
Core Services Team
Red Hat Czech, s.r.o.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.