Friday, June 12, 2026

.::: Script check IP NAS Mounting in fstab for trouble shooting :::.

 


1. check df -h 
 

2. cek simple 


[root@teguhth8 cekfstab]# more cek_mounting_simple.sh
for ip in $(grep -v '^#' /etc/fstab | awk '$3=="nfs"{print $1}' | cut -d: -f1 | sort -u)
do
    ping -c 1 -W 1 $ip >/dev/null
    if [ $? -ne 0 ]; then
        echo "DOWN: $ip"
    fi
done
[root@teguhth8 cekfstab]#
 

3. check all ip 

[root@teguhth8 cekfstab]# cat cek_mounting_allip.sh
#!/bin/bash

for ip in $(grep -v '^#' /etc/fstab | awk '$3=="nfs"{print $1}' | cut -d: -f1 | sort -u)
do
    if ping -c 1 -W 1 $ip >/dev/null 2>&1
    then
        echo "UP   : $ip"
    else
        echo "DOWN : $ip"
    fi
done
[root@teguhth8 cekfstab]#
 

4. check all ip v2 

[root@teguhth8 cekfstab]# cat cek_mounting_allipv2.sh
#!/bin/bash

echo "===== NFS Server Connectivity Check ====="
echo "Time: $(date)"
echo

for ip in $(grep -v '^#' /etc/fstab | awk '$3=="nfs"{print $1}' | cut -d: -f1 | sort -u)
do
    if ping -c 1 -W 1 $ip >/dev/null 2>&1
    then
        echo "Ping [OK]     $ip"
    else
        echo "Ping [FAILED] $ip"
    fi
done
[root@teguhth8 cekfstab]#
 


5. check ip mounting complete with directory 

[root@teguhth8 cekfstab]# sh /data/cekfstab/cek_mounting_complete.sh
UP    10.10.10.90     /mnt
DOWN  10.10.10.8      /mountest
[root@teguhth8 cekfstab]#

 


6. check ip mounting complete with directory complete 

[root@teguhth8 cekfstab]# sh cek_mounting_complete_all.sh
UP  10.10.10.90:/home/mounting /mnt nfs defaults 0 0
DOWN  10.10.10.8:/home/cen7 /mountest nfs defaults 0 0
[root@teguhth8 cekfstab]#
 
[root@teguhth8 cekfstab]# cat cek_mounting_complete_all.sh
#!/bin/bash

grep -v '^#' /etc/fstab | awk '$3=="nfs"' | while read src mountpoint fstype opts dump pass
do
    ip=$(echo "$src" | cut -d: -f1)

    if ping -c 1 -W 1 "$ip" >/dev/null 2>&1
    then
        status="UP"
    else
        status="DOWN"
    fi

    echo "$status  $src $mountpoint $fstype $opts $dump $pass"
done
[root@teguhth8 cekfstab]#
 
 
 


7. check ip mounting complete with directory complete rapi 

[root@teguhth8 cekfstab]# cat cek_mounting_complete_all_rapi.sh
#!/bin/bash

printf "%-6s %-35s %-15s %-6s %-15s\n" \
"STATUS" "SOURCE" "MOUNTPOINT" "TYPE" "OPTIONS"

printf "%-6s %-35s %-15s %-6s %-15s\n" \
"------" "-----------------------------------" "---------------" "------" "---------------"

grep -v '^#' /etc/fstab | awk '$3=="nfs"' | while read src mountpoint fstype opts dump pass
do
    ip=${src%%:*}

    if ping -c 1 -W 1 "$ip" >/dev/null 2>&1
    then
        status="UP"
    else
        status="DOWN"
    fi

    printf "%-6s %-35s %-15s %-6s %-15s\n" \
    "$status" "$src" "$mountpoint" "$fstype" "$opts"
done
[root@teguhth8 cekfstab]#
 

8. check ip mounting complete with directory complete rapi adjust 

[root@teguhth8 cekfstab]# cat /data/cekfstab/cek_mounting_complete_all_rapi_adjust.sh
#!/bin/bash

{
    echo -e "STATUS\tSOURCE\tMOUNTPOINT\tTYPE\tOPTIONS"
    echo -e "------\t------\t----------\t----\t-------"

    grep -v '^#' /etc/fstab | awk '$3=="nfs"' | while read src mountpoint fstype opts dump pass
    do
        ip=${src%%:*}

        if ping -c 1 -W 1 "$ip" >/dev/null 2>&1
        then
            status="UP"
        else
            status="DOWN"
        fi

        echo -e "$status\t$src\t$mountpoint\t$fstype\t$opts"
    done
} | column -t
[root@teguhth8 cekfstab]#
 

 

No comments:

Post a Comment

Popular Posts