autofs-skip-autofs-entries
HOST-MIB: Skip autofs entries Do not call statfs() for autofs entries. See also https://sourceforge.net/p/net-snmp/patches/1350/. See also https://sourceforge.net/p/net-snmp/bugs/2968/. [ bvanassche: Made several small edits ] Description: HOST-MIB: Skip autofs entries Author: Josef Ridky <jridky@redhat.com> Origin: upstream, https://github.com/net-snmp/net-snmp/commit/cf41e6e910 Applied-Upstream: v5.8.rc4-366-gcf41e6e91 (drop after v5.8.1.pre1) Bug: https://sourceforge.net/p/net-snmp/bugs/2968/ Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=935325 Bug-Ubuntu: https://bugs.launchpad.net/bugs/1835818 Reviewed-by: Rafael David Tinoco <rafaeldtinoco@ubuntu.com> Last-Update: 2019-12-16 Gbp-Pq: Name autofs-skip-autofs-entries.patch
This commit is contained in:
parent
f6da980015
commit
4c3eb1f675
|
@ -43,8 +43,9 @@ _fsys_type( int type)
|
||||||
|
|
||||||
case MNT_NFS:
|
case MNT_NFS:
|
||||||
case MNT_NFS3:
|
case MNT_NFS3:
|
||||||
case MNT_AUTOFS:
|
|
||||||
return NETSNMP_FS_TYPE_NFS;
|
return NETSNMP_FS_TYPE_NFS;
|
||||||
|
case MNT_AUTOFS:
|
||||||
|
return NETSNMP_FS_TYPE_AUTOFS;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The following code covers selected filesystems
|
* The following code covers selected filesystems
|
||||||
|
@ -155,12 +156,15 @@ netsnmp_fsys_arch_load( void )
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Optionally skip retrieving statistics for remote mounts
|
* Skip retrieving statistics for AUTOFS and optionally for remote
|
||||||
|
* mounts.
|
||||||
*/
|
*/
|
||||||
if ( (entry->flags & NETSNMP_FS_FLAG_REMOTE) &&
|
if ( (entry->flags & NETSNMP_FS_FLAG_REMOTE) &&
|
||||||
netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||||
NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES))
|
NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES))
|
||||||
continue;
|
continue;
|
||||||
|
if (entry->type == NETSNMP_FS_TYPE_AUTOFS)
|
||||||
|
continue;
|
||||||
|
|
||||||
if ( statfs( entry->path, &stat_buf ) < 0 ) {
|
if ( statfs( entry->path, &stat_buf ) < 0 ) {
|
||||||
snprintf( tmpbuf, sizeof(tmpbuf), "Cannot statfs %s", entry->path );
|
snprintf( tmpbuf, sizeof(tmpbuf), "Cannot statfs %s", entry->path );
|
||||||
|
|
|
@ -150,6 +150,13 @@ _fsys_type( char *typename )
|
||||||
!strcmp(typename, MNTTYPE_LOFS))
|
!strcmp(typename, MNTTYPE_LOFS))
|
||||||
return NETSNMP_FS_TYPE_OTHER;
|
return NETSNMP_FS_TYPE_OTHER;
|
||||||
|
|
||||||
|
/* Detection of AUTOFS.
|
||||||
|
* This file system will be ignored by default
|
||||||
|
*/
|
||||||
|
else if (!strcmp(typename, MNTTYPE_AUTOFS))
|
||||||
|
return NETSNMP_FS_TYPE_AUTOFS;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* All other types are silently skipped
|
* All other types are silently skipped
|
||||||
*/
|
*/
|
||||||
|
@ -239,6 +246,10 @@ netsnmp_fsys_arch_load( void )
|
||||||
NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES))
|
NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
/* Skip AUTOFS entries */
|
||||||
|
if (entry->type == NETSNMP_FS_TYPE_AUTOFS)
|
||||||
|
continue;
|
||||||
|
|
||||||
#ifdef irix6
|
#ifdef irix6
|
||||||
if ( NSFS_STATFS( entry->path, &stat_buf, sizeof(struct statfs), 0) < 0 )
|
if ( NSFS_STATFS( entry->path, &stat_buf, sizeof(struct statfs), 0) < 0 )
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -165,6 +165,9 @@
|
||||||
#ifndef MNTTYPE_APP
|
#ifndef MNTTYPE_APP
|
||||||
#define MNTTYPE_APP "app"
|
#define MNTTYPE_APP "app"
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef MNTTYPE_AUTOFS
|
||||||
|
#define MNTTYPE_AUTOFS "autofs"
|
||||||
|
#endif
|
||||||
#ifndef MNTTYPE_DEVPTS
|
#ifndef MNTTYPE_DEVPTS
|
||||||
#define MNTTYPE_DEVPTS "devpts"
|
#define MNTTYPE_DEVPTS "devpts"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -834,6 +834,27 @@ Check_HR_FileSys_NFS (void)
|
||||||
return 0; /* no NFS file system */
|
return 0; /* no NFS file system */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This function checks whether current file system is an AutoFs
|
||||||
|
* HRFS_entry must be valid prior to calling this function
|
||||||
|
* return 1 if AutoFs, 0 otherwise
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
Check_HR_FileSys_AutoFs(void)
|
||||||
|
{
|
||||||
|
#if HAVE_GETFSSTAT
|
||||||
|
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
|
||||||
|
)
|
||||||
|
#endif /* HAVE_GETFSSTAT */
|
||||||
|
return 1; /* AUTOFS */
|
||||||
|
|
||||||
|
return 0; /* no AUTOFS */
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
End_HR_FileSys(void)
|
End_HR_FileSys(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,6 +10,7 @@ extern void Init_HR_FileSys(void);
|
||||||
extern FindVarMethod var_hrfilesys;
|
extern FindVarMethod var_hrfilesys;
|
||||||
extern int Get_Next_HR_FileSys(void);
|
extern int Get_Next_HR_FileSys(void);
|
||||||
extern int Check_HR_FileSys_NFS(void);
|
extern int Check_HR_FileSys_NFS(void);
|
||||||
|
extern int Check_HR_FileSys_AutoFs(void);
|
||||||
|
|
||||||
extern int Get_FSIndex(char *);
|
extern int Get_FSIndex(char *);
|
||||||
extern long Get_FSSize(char *); /* Temporary */
|
extern long Get_FSSize(char *); /* Temporary */
|
||||||
|
|
|
@ -544,6 +544,8 @@ really_try_next:
|
||||||
NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) &&
|
NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) &&
|
||||||
Check_HR_FileSys_NFS())
|
Check_HR_FileSys_NFS())
|
||||||
return NULL; /* or goto try_next; */
|
return NULL; /* or goto try_next; */
|
||||||
|
if (Check_HR_FileSys_AutoFs())
|
||||||
|
return NULL;
|
||||||
if (HRFS_statfs(HRFS_entry->HRFS_mount, &stat_buf) < 0) {
|
if (HRFS_statfs(HRFS_entry->HRFS_mount, &stat_buf) < 0) {
|
||||||
snmp_log_perror(HRFS_entry->HRFS_mount);
|
snmp_log_perror(HRFS_entry->HRFS_mount);
|
||||||
goto try_next;
|
goto try_next;
|
||||||
|
@ -683,7 +685,8 @@ Get_Next_HR_Store(void)
|
||||||
if (HRS_index >= 0) {
|
if (HRS_index >= 0) {
|
||||||
if (!(netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
if (!(netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||||
NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) &&
|
NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) &&
|
||||||
Check_HR_FileSys_NFS())) {
|
Check_HR_FileSys_NFS()) &&
|
||||||
|
!Check_HR_FileSys_AutoFs()) {
|
||||||
return HRS_index + NETSNMP_MEM_TYPE_MAX;
|
return HRS_index + NETSNMP_MEM_TYPE_MAX;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -429,3 +429,9 @@ Check_HR_FileSys_NFS (void)
|
||||||
{
|
{
|
||||||
return (HRFS_entry->flags & NETSNMP_FS_FLAG_REMOTE) ? 1 : 0;
|
return (HRFS_entry->flags & NETSNMP_FS_FLAG_REMOTE) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Check_HR_FileSys_AutoFs (void)
|
||||||
|
{
|
||||||
|
return HRFS_entry->type == NETSNMP_FS_TYPE_AUTOFS;
|
||||||
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ extern void Init_HR_FileSys(void);
|
||||||
extern FindVarMethod var_hrhfilesys;
|
extern FindVarMethod var_hrhfilesys;
|
||||||
extern int Get_Next_HR_FileSys(void);
|
extern int Get_Next_HR_FileSys(void);
|
||||||
extern int Check_HR_FileSys_NFS(void);
|
extern int Check_HR_FileSys_NFS(void);
|
||||||
|
extern int Check_HR_FileSys_AutoFs(void);
|
||||||
|
|
||||||
extern int Get_FSIndex(char *);
|
extern int Get_FSIndex(char *);
|
||||||
extern long Get_FSSize(char *); /* Temporary */
|
extern long Get_FSSize(char *); /* Temporary */
|
||||||
|
|
|
@ -371,6 +371,8 @@ really_try_next:
|
||||||
NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) &&
|
NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) &&
|
||||||
Check_HR_FileSys_NFS())
|
Check_HR_FileSys_NFS())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
if (Check_HR_FileSys_AutoFs())
|
||||||
|
return NULL;
|
||||||
if (store_idx <= NETSNMP_MEM_TYPE_MAX ) {
|
if (store_idx <= NETSNMP_MEM_TYPE_MAX ) {
|
||||||
mem = (netsnmp_memory_info*)ptr;
|
mem = (netsnmp_memory_info*)ptr;
|
||||||
}
|
}
|
||||||
|
@ -508,7 +510,8 @@ Get_Next_HR_Store(void)
|
||||||
if (HRS_index >= 0) {
|
if (HRS_index >= 0) {
|
||||||
if (!(netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
if (!(netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
|
||||||
NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) &&
|
NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) &&
|
||||||
Check_HR_FileSys_NFS())) {
|
Check_HR_FileSys_NFS()) &&
|
||||||
|
!Check_HR_FileSys_AutoFs()) {
|
||||||
return HRS_index + NETSNMP_MEM_TYPE_MAX;
|
return HRS_index + NETSNMP_MEM_TYPE_MAX;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -41,6 +41,7 @@ typedef struct netsnmp_fsys_info_s netsnmp_fsys_info;
|
||||||
#define NETSNMP_FS_TYPE_SYSFS (4 | _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_TMPFS (5 | _NETSNMP_FS_TYPE_LOCAL)
|
||||||
#define NETSNMP_FS_TYPE_USBFS (6 | _NETSNMP_FS_TYPE_LOCAL)
|
#define NETSNMP_FS_TYPE_USBFS (6 | _NETSNMP_FS_TYPE_LOCAL)
|
||||||
|
#define NETSNMP_FS_TYPE_AUTOFS (7 | _NETSNMP_FS_TYPE_LOCAL | _NETSNMP_FS_TYPE_SKIP_BIT)
|
||||||
|
|
||||||
#define NETSNMP_FS_FLAG_ACTIVE 0x01
|
#define NETSNMP_FS_FLAG_ACTIVE 0x01
|
||||||
#define NETSNMP_FS_FLAG_REMOTE 0x02
|
#define NETSNMP_FS_FLAG_REMOTE 0x02
|
||||||
|
|
Loading…
Reference in New Issue