Stale nfs mounts on aix leads to timeout of the agent

We modified the agent actually, but this is not update save.

  1. The internal df knows the parameter ‘-T local’
    The code is now the following:
section_df() {
    echo '<<<df>>>'
    if [ -x /usr/opt/freeware/bin/df_unused ]; then
        excludefs="-x smbfs -x cifs -x iso9660 -x udf -x nfsv4 -x nfs -x mvfs -x zfs -x cdrfs"
        # shellcheck disable=SC2086
        /usr/opt/freeware/bin/df -PTlk ${excludefs} | sed 1d

        # df inodes information
        echo '<<<df>>>'
        echo '[df_inodes_start]'
        # shellcheck disable=SC2086
        /usr/opt/freeware/bin/df -PTli ${excludefs} | sed 1d
        echo '[df_inodes_end]'
    else
        df -kP -T local | sed 's/ / - /' | grep -v ^/proc | grep -v ^Filesystem | grep -v :
    fi
}

The ‘_unused’ modification prevents the agent to use the /opt/freeware/bin/df which is some kind of ‘unteachable’ in this way, so the ‘else’ is used instead.
The ‘-T local’ is exactly what we need at this place. The ‘grep -v :’ at the end is most probably way of unnecessary.

  1. The nfs section i modified this way:
section_nfs_mounts() {
    # Check for hanging NFS mounts. This needs a GNU stat installed in the PATH
    json_templ() {
        echo '{"mountpoint": "'"${1}"'", "source": "'"${2}"'", "state": "ok", "mount_seems_okay": "true"}'
    }
    json_templ_empty() {
        echo '{"mountpoint": "'"${1}"'", "source": "'"${2}"'", "state": "hanging", "mount_seems_okay": "false"}'
    }
    if inpath stat; then
        echo '<<<nfsmounts_v2:sep(0)>>>'
        mount | grep ' nfs' | grep -v -e rubrik -e unwanted_2 -e unwanted_3 -e etc_etc_etc | while read -r HN MD MP _; do
            waitmax 2 stat -f -c "'$(json_templ "${MP}" "${HN}:${MD}")'" "${MP}" || json_templ_empty "${MP}" "${HN}:${MD}"
        done
        echo '<<<cifsmounts>>>'
        mount | grep ' cifs' | while read -r _ _ MP _; do
            if [ ! -r "${MP}" ]; then
                echo "${MP} Permission denied"
            else
                waitmax 2 stat -f -c '"'"${MP}"' ok - - - -"' "${MP}" ||
                    echo "${MP} hanging 0 0 0 0"
            fi
        done
    fi
}

As you can see i have simply inserted a ‘| grep -v -e unwanted_mountpoint’ statement

These two modification should be enough, but - again - this is not update save.
I wish there would be an option to configure sections run asyncronously in the background instead of disabling them in /etc/check_mk/exclude_sections.cfg or modifying the agent every time a new one is created by the cmk devs.

Perhaps this find a way to a further version of cmk :wink:

br
christian

1 Like