Menu

#1350 Skip autofs entries by default

backport-needed
closed
nobody
None
5
2019-09-17
2017-11-01
Josef Ridky
No

snmpwalk command got a connection timeout after polling hrStorage MIB. And, it cannot query anything for a while.

snmpwalk -v 2c -c public test.example.com sysName

SNMPv2-MIB::sysName.0 = STRING: ae1dwnaugdbs

snmpwalk -v 2c -c public test.example.com hrStorage

HOST-RESOURCES-MIB::hrMemorySize.0 = INTEGER: 12139840 KBytes
HOST-RESOURCES-MIB::hrStorageIndex.1 = INTEGER: 1
HOST-RESOURCES-MIB::hrStorageIndex.3 = INTEGER: 3
HOST-RESOURCES-MIB::hrStorageIndex.6 = INTEGER: 6
HOST-RESOURCES-MIB::hrStorageIndex.7 = INTEGER: 7
HOST-RESOURCES-MIB::hrStorageIndex.8 = INTEGER: 8
HOST-RESOURCES-MIB::hrStorageIndex.10 = INTEGER: 10
Timeout: No Response from test.example.com

snmpwalk -v 2c -c public test.example.com sysName

Timeout: No Response from test.example.com

==> after query with hrStorage, any query failed with timeout for a while.

I saw the following errors about statfs() with many autofs mount points on the snmpd server while the problem happens.

1621 11:28:59.875371 write(3, "Cannot statfs /informatics/data/sdd\n: Interrupted system call\n", 62) = 62 <0.000006>
1621 11:29:00.775544 write(3, "Cannot statfs /informatics/data/pubchem\n: No such file or directory\n", 68) = 68 <0.000005>
1621 11:29:01.507282 write(3, "Cannot statfs /.bixdbs/genbank\n: No such file or directory\n", 59) = 59 <0.000005>
1621 11:29:02.279816 write(3, "Cannot statfs /informatics/tools\n: No such file or directory\n", 61) = 61 <0.000005>
1621 11:29:03.655527 write(3, "Cannot statfs /sg/win_lsb_groups\n: No such file or directory\n", 61) = 61 <0.000005>
1621 11:29:04.394058 write(3, "Cannot statfs /informatics/data/apps\n: No such file or directory\n", 65) = 65 <0.000005>
1621 11:29:04.613188 write(3, "Cannot statfs /software/prod\n: No such file or directory\n", 57) = 57 <0.000060>

This machine has many autofs entries in /etc/mtab and, it took much time to finish statfs() for those autofs ones. While it's doing statfs(), it could not respond any query from clients.
I think, that best option for this is skip statfs() for autofs by default.

skipNFSInHostResources didn't resolve this problem because autofs is not recognized as a remote file system in _fsys_remote().

Attached patch should skip autofs entries by default. (Functionality confirmed by several testers).

Do you think, this behaviour should be part of net-snmp?

Thanks for your opinions.

1 Attachments

Discussion

  • Bart Van Assche

    Bart Van Assche - 2019-07-24

    Thanks for the patch! A modified version of this patch has been applied. Please retest.

     
  • Ioanna Alifieraki

    As mentioned in https://sourceforge.net/p/net-snmp/bugs/2968/ we're facing a similar issue in Ubuntu pacakges.
    Could you please point out the commit id of modified version of this patch so I can retest?
    Thanks!

     
  • Bart Van Assche

    Bart Van Assche - 2019-07-24

    The commit ID is as follows: cf41e6e91015 ("HOST-MIB: Skip autofs entries").

     
  • Ioanna Alifieraki

    Thanks very much for this. I retested and confirmed that the modified patch resolves the issue.

     
  • Lukasz Wasikowski

    I think it introduced regression.

    snmpd 5.7.3+dfsg-1ubuntu4.2 on Ubuntu 16.04.06 LTS (before this patch) worked like this:

    # snmpwalk -c putpasswordhere -v2c -On host 1.3.6.1.2.1.25.2.3.1.3
    .1.3.6.1.2.1.25.2.3.1.3.1 = STRING: Physical memory
    .1.3.6.1.2.1.25.2.3.1.3.3 = STRING: Virtual memory
    .1.3.6.1.2.1.25.2.3.1.3.6 = STRING: Memory buffers
    .1.3.6.1.2.1.25.2.3.1.3.7 = STRING: Cached memory
    .1.3.6.1.2.1.25.2.3.1.3.8 = STRING: Shared memory
    .1.3.6.1.2.1.25.2.3.1.3.10 = STRING: Swap space
    .1.3.6.1.2.1.25.2.3.1.3.31 = STRING: /
    .1.3.6.1.2.1.25.2.3.1.3.37 = STRING: /run
    .1.3.6.1.2.1.25.2.3.1.3.39 = STRING: /dev/shm
    .1.3.6.1.2.1.25.2.3.1.3.40 = STRING: /run/lock
    .1.3.6.1.2.1.25.2.3.1.3.41 = STRING: /sys/fs/cgroup
    .1.3.6.1.2.1.25.2.3.1.3.59 = STRING: /boot
    .1.3.6.1.2.1.25.2.3.1.3.60 = STRING: /run/user/1002
    

    snmp 5.7.3+dfsg-1ubuntu4.3 on Ubuntu 16.04.06 LTS (with this patch) works like this:

    # snmpwalk -c putpasswordhere -v2c -On host 1.3.6.1.2.1.25.2.3.1.3
    .1.3.6.1.2.1.25.2.3.1.3.1 = STRING: Physical memory
    .1.3.6.1.2.1.25.2.3.1.3.3 = STRING: Virtual memory
    .1.3.6.1.2.1.25.2.3.1.3.6 = STRING: Memory buffers
    .1.3.6.1.2.1.25.2.3.1.3.7 = STRING: Cached memory
    .1.3.6.1.2.1.25.2.3.1.3.8 = STRING: Shared memory
    .1.3.6.1.2.1.25.2.3.1.3.10 = STRING: Swap space
    

    I miss / and /boot entries ;) Both are ext filesystems, mounted via /etc/fstab, no autofs mounts.

     

    Last edit: Lukasz Wasikowski 2019-09-06
  • Julian Gilbert

    Julian Gilbert - 2019-09-06

    We see the same regression where all file sytems are missing from the above snmpwalk with:

    snmp 5.7.3+dfsg-1ubuntu4.3 on Ubuntu 16.04.06 LTS
    snmp 5.7.3+dfsg-1.8ubuntu3.2 on Ubuntu 18.04.3 LTS

     
  • Eric

    Eric - 2019-09-06

    $ git show a0df31c18
    commit a0df31c18c513a0d79f4d526b1af7fad48748e57
    Author: Bart Van Assche bvanassche@acm.org
    Date: Fri Jul 26 21:40:12 2019 -0700

    HOST-MIB: Fix a recently introduced bug
    
    Fixes: cf41e6e91015 ("HOST-MIB: Skip autofs entries")
    
    Note: this bug was not introduced by Josef but by me.
    

    diff --git a/agent/mibgroup/host/hrh_storage.c b/agent/mibgroup/host/hrh_storage.c
    index 6f8ff6c53..c7c53922a 100644
    --- a/agent/mibgroup/host/hrh_storage.c
    +++ b/agent/mibgroup/host/hrh_storage.c
    @@ -371,7 +371,7 @@ really_try_next:
    NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) &&
    Check_HR_FileSys_NFS())
    return NULL;
    - if (Check_HR_FileSys_AutoFs())
    + if (HRFS_entry && Check_HR_FileSys_AutoFs())
    return NULL;
    if (store_idx <= NETSNMP_MEM_TYPE_MAX ) {
    mem = (netsnmp_memory_info*)ptr;

     
  • Eric

    Eric - 2019-09-06

    Disregard, the fix above is already found in Ubuntu net-snmp:

    agent/mibgroup/host/hrh_storage.c

    375 if (HRFS_entry && Check_HR_FileSys_AutoFs())
    376 return NULL;

     
  • Eric

    Eric - 2019-09-06

    I'll investigate further more and do some code inspection. Will keep you posted if I find anything.

     
  • Eric

    Eric - 2019-09-06

    getfsstat doesn't seems to be in Linux
    https://www.freebsd.org/cgi/man.cgi?query=getfsstat&sektion=2
    https://ubuntuforums.org/showthread.php?t=1227025

    Look like another method of checking the fs needs to be added for linux.

    842 /* This function checks whether current file system is an AutoFs
    843  * HRFS_entry must be valid prior to calling this function
    844  * return 1 if AutoFs, 0 otherwise
    845  */
    846 int
    847 Check_HR_FileSys_AutoFs(void)
    848 {
    849 #if HAVE_GETFSSTAT
    850     if (HRFS_entry->HRFS_type != NULL &&
    851 #if defined(MNTTYPE_AUTOFS)
    852         !strcmp(HRFS_entry->HRFS_type, MNTTYPE_AUTOFS)
    853 #else
    854         !strcmp(HRFS_entry->HRFS_type, "autofs")
    855 #endif
    856         )
    857 #endif /* HAVE_GETFSSTAT */
    858         return 1;  /* AUTOFS */
    859 
    860     return 0; /* no AUTOFS */
    861 }
    
     
  • Eric

    Eric - 2019-09-06

    and shouldn't return 1; be inside the if block ?

    857 #endif /* HAVE_GETFSSTAT */
    858         return 1;  /* AUTOFS */
    859 
    860     return 0; /* no AUTOFS */
    861 }
    
     
  • Eric

    Eric - 2019-09-06

    I haven't test (minus using gcc -E) but that should do the trick:

         if (HRFS_entry->HRFS_type != NULL &&
     #if defined(MNTTYPE_AUTOFS)
             !strcmp(HRFS_entry->HRFS_type, MNTTYPE_AUTOFS)
    -#else
    -        !strcmp(HRFS_entry->HRFS_type, "autofs")
     #endif
    +#else /* HAVE_GETFSSTAT */
    +        !strcmp(HRFS_entry->HRFS_type, "autofs")
             )
     #endif /* HAVE_GETFSSTAT */
             return 1;  /* AUTOFS */
    

    The #else instruction never get caught otherwise:

    # gcc -E #actual code
    int
    Check_HR_FileSys_AutoFs(void)
    {
    # 13 "/tmp/autofs_ORIG.c"
            return 1;
    
        return 0;
    }
    
    # gcc -E #with my current proposal
    int
    Check_HR_FileSys_AutoFs(void)
    {
    
    
    
    
    
    
            !strcmp(HRFS_entry->HRFS_type, "autofs")
            )
    
            return 1;
    
        return 0;
    }
    
     
  • Eric

    Eric - 2019-09-06

    The #endif IMHO is wrongly placed, so that the #else isn't doing what it is suppose to do.
    Instead of being a else for HAVE_GETFSSTAT it is an ELSE for MNTTYPE_AUTOFS.

    So the case where GETFSSTAT is not supported never get triggered on Linux operating system where getfsstat doesn't exist.

     

    Last edit: Eric 2019-09-06
  • Eric

    Eric - 2019-09-06

    If one is willing to try that test package:

    sudo add-apt-repository ppa:slashd/lp1843036
    sudo apt-get update

    and let me know the outcome, it will be appreciated.

     
  • Eric

    Eric - 2019-09-06

    after re-consideration even better :

    int
    Check_HR_FileSys_AutoFs(void)
    {
        if (HRFS_entry->HRFS_type != NULL &&
    #if defined(MNTTYPE_AUTOFS)
            !strcmp(HRFS_entry->HRFS_type, MNTTYPE_AUTOFS)
    #else
            !strcmp(HRFS_entry->HRFS_type, "autofs")
    #endif
            )
            return 1;  /* AUTOFS */
    
        return 0; /* no AUTOFS */
    }
    

    We simply drop the HAVE_GETFSSTAT definition, anyway, it's good for both (GETFSSTAT system and not GETFSSTAT system) scenarios to look if the pointer is not NULL anyway.

     
  • Eric

    Eric - 2019-09-06

    package to test: 5.7.3+dfsg-1.8ubuntu3.2+testpkg20190906b2

     
  • Joe Gooch

    Joe Gooch - 2019-09-06

    Current ubuntu build now doesn't show ANY physical mounts.
    https://bugs.launchpad.net/ubuntu/+source/net-snmp/+bug/1842924

    Due to a comparison:
    ~~~
    / Skip AUTOFS entries /
    if (entry->type == NETSNMP_FS_TYPE_AUTOFS)
    continue;

    Looks really innocuous until you run it through gcc -E:
    
        if (entry->type == 7 | 0x1000 | 0x2000)
            continue;
    

    ~~~

    At which point you realize the | is going to make this if TRUE all the time.

    The attached patch puts () around the #defines.

     
  • Joe Gooch

    Joe Gooch - 2019-09-06

    When I tested the above, I had also independently made the same change to Check_HR_FileSys_AutoFs - so that tested out fine on Ubuntu.

    I can test a PPA for you if you want to roll the above patch in too.

     
  • Eric

    Eric - 2019-09-06

    It's already there upstream:

    $ git show 71e487212b
    commit 71e487212bd65839e7454df9701524d08cf0d74f
    Author: Niels Baggesen <nba@users.sourceforge.net>
    Date:   Thu Jul 21 21:45:26 2016 +0200
    
        fsys.h: put paranthesis around macros which are expressions
    
    diff --git a/include/net-snmp/agent/hardware/fsys.h b/include/net-snmp/agent/hardware/fsys.h
    index cd7880ce7..b540a53d4 100644
    --- a/include/net-snmp/agent/hardware/fsys.h
    +++ b/include/net-snmp/agent/hardware/fsys.h
    @@ -33,14 +33,14 @@ typedef struct netsnmp_fsys_info_s netsnmp_fsys_info;
        /*
         * Additional enumerationis - not listed in that MIB
         */
    -#define NETSNMP_FS_TYPE_IGNORE    1 | _NETSNMP_FS_TYPE_LOCAL | _NETSNMP_FS_TYPE_SKIP_BIT
    +#define NETSNMP_FS_TYPE_IGNORE    (1 | _NETSNMP_FS_TYPE_LOCAL | _NETSNMP_FS_TYPE_SKIP_BIT)
    
    -#define NETSNMP_FS_TYPE_PROC      2 | _NETSNMP_FS_TYPE_LOCAL | _NETSNMP_FS_TYPE_SKIP_BIT
    +#define NETSNMP_FS_TYPE_PROC      (2 | _NETSNMP_FS_TYPE_LOCAL | _NETSNMP_FS_TYPE_SKIP_BIT)
    
    -#define NETSNMP_FS_TYPE_DEVPTS    3 | _NETSNMP_FS_TYPE_LOCAL | _NETSNMP_FS_TYPE_SKIP_BIT
    -#define NETSNMP_FS_TYPE_SYSFS     4 | _NETSNMP_FS_TYPE_LOCAL | _NETSNMP_FS_TYPE_SKIP_BIT
    -#define NETSNMP_FS_TYPE_TMPFS     5 | _NETSNMP_FS_TYPE_LOCAL
    -#define NETSNMP_FS_TYPE_USBFS     6 | _NETSNMP_FS_TYPE_LOCAL
    +#define NETSNMP_FS_TYPE_DEVPTS    (3 | _NETSNMP_FS_TYPE_LOCAL | _NETSNMP_FS_TYPE_SKIP_BIT)
    +#define NETSNMP_FS_TYPE_SYSFS     (4 | _NETSNMP_FS_TYPE_LOCAL | _NETSNMP_FS_TYPE_SKIP_BIT)
    +#define NETSNMP_FS_TYPE_TMPFS     (5 | _NETSNMP_FS_TYPE_LOCAL)
    +#define NETSNMP_FS_TYPE_USBFS     (6 | _NETSNMP_FS_TYPE_LOCAL)
    
     #define NETSNMP_FS_FLAG_ACTIVE   0x01
     #define NETSNMP_FS_FLAG_REMOTE   0x02
    
    $ git describe --contains 71e487212bd65839e7454df9701524d08cf0d74f
    v5.8.pre1~7^2~14^2~15^2~22
    

    Only thing missing upstream would be to remove the HAVE_GETFSSTAT preprocessing directive then.

     

    Last edit: Eric 2019-09-06
  • Bart Van Assche

    Bart Van Assche - 2019-09-07

    A candidate fix has been applied on the v5.8 and master branches ([bcb1a6b8afc4]). Please retest.

     
  • Eric

    Eric - 2019-09-07

    Thanks Bart Van Assche !

     
  • Eric

    Eric - 2019-09-07

    The Ubuntu src pkg of 'net'snmp' is in progress to be updated to include the following commit: 71e487212bd65839e7454df9701524d08cf0d74f, which fixes the problem.

    To follow the progress, please follow : https://bugs.launchpad.net/ubuntu/+source/net-snmp/+bug/1843036

    Thanks everyone !

     
  • Bart Van Assche

    Bart Van Assche - 2019-09-17
    • status: open --> closed
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.