Instruktaż/Tutorial Który proces lub usługa wzbudza dysk twardy z uśpienia

Status
Brak możliwości dodawania odpowiedzi.

Silas Mariusz

rm -rf /
Help us, GOD!
5 Kwiecień 2008
10 213
31
2 316
153
39
Nowy Sącz
forum.qnap.net.pl
QNAP
TS-x77
Ethernet
1 GbE
Przed przystąpieniem do zdiagnozowania, który z procesów lub usług wzbudza dyski twarde zainstalowane w serwerze z uśpienia (Spin-Down), pobierz i zainstaluj program PuTTY lub inny klient SSH:
PuTTY Download Page
  1. Uruchom program PuTTY, wprowadź adres IP serwera NAS oraz port SSH. Połącz się z serwerem logując się przy użyciu konta administratora (admin).
  2. Wykonaj poniższe polecenia, aby pobrać i uruchomić plik do monitorowania aktywności interfejsu odczytu i zapisu danych wejsciowych i wyjściowych (I/O) na dyskach twardych:
    Bash:
    cd /root
    wget http://pool.qnapclub.pl/projects/tools/blkdevMonitor/blkdevMonitor.sh
    chmod +x blkdevMonitor.sh
    sh blkdevMonitor.sh
  3. Uruchomiony program rozpocznie monitorowanie operacji odczytu i zapisu uruchomionych procesów na serwerze.
FYI (zawartość skryptu blkdevMonitor.sh)
Bash:
#!/bin/sh
#================================================================
# Copyright (C) 2008 QNAP Systems, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#----------------------------------------------------------------
#
# blkdevMonitor_v2.sh
#
#   Abstract:
#       A program of testing purpose on monitor block device
#
#   HISTORY:
#       2013/05/15  -   Created - Kent
#
#================================================================
/sbin/daemon_mgr klogd.sh stop "/etc/init.d/klogd.sh start"
/usr/bin/killall dd 2>/dev/null 1>/dev/null

MD_DEVIVES="md9 md13 md0 md1 md2"
SD_DEVIVES="sda sdb sdc sdd sde sdf sdg sdh"
Do_Log=0
MAXRUN=100
FORCE_STANDBY=0
BLKDEV_LOG=/root/blkdevMonitor_v2.log

analyse_kmsg()
{
    _klog=/.klog
    /bin/touch $_klog
    _standby=1

    # read /proc/kmsg
    while [ 1 ]; do
        /bin/dd if=/proc/kmsg of=$_klog bs=1 count=10240 2>/dev/null 1>/dev/null
        for i in $MD_DEVIVES; do
            /bin/cat $_klog | /bin/grep $i | /bin/grep "dirtied inode"
            if [ $? = 0 ]; then
                /bin/cat $_klog | /bin/grep $i | /bin/grep "dirtied inode" >> $BLKDEV_LOG
                _standby=0
            fi
            /bin/cat $_klog | /bin/grep $i | /bin/grep "block"
            if [ $? = 0 ]; then
                /bin/cat $_klog | /bin/grep $i | /bin/grep "block" >> $BLKDEV_LOG
                _standby=0
            fi
        done
        for i in $SD_DEVIVES; do
            /bin/cat $_klog | /bin/grep $i | /bin/grep "dirtied inode"
            if [ $? = 0 ]; then
                /bin/cat $_klog | /bin/grep $i | /bin/grep "dirtied inode" >> $BLKDEV_LOG
                _standby=0
            fi
            /bin/cat $_klog | /bin/grep $i | /bin/grep "block"
            if [ $? = 0 ]; then
                /bin/cat $_klog | /bin/grep $i | /bin/grep "block" >> $BLKDEV_LOG
                _standby=0
            fi
        done
        if [ $_standby = 0 ]; then
            return 1
        fi
    done
}

_countdown()
{
    /bin/sync;/bin/sync
    /bin/echo -n "Countdown: "
    cntdown=$1
    while [ ${cntdown} -gt 0 ]; do
        /bin/sleep 1
        /bin/echo -n "${cntdown} "
        cntdown=$[$cntdown-1]
    done
    echo
}

_check_standby()
{
    for i in $SD_DEVIVES; do
        /sbin/hdparm -C /dev/${i} 2>>/dev/null | /bin/grep active
        if [ $? -eq 0 ]; then
            echo /dev/${i}
            echo "Some process was waked up HDD..."
            return 1    # HDD is active
        fi
    done
    return 0
}

/bin/echo "===== Welcome to use blkdevMonitor_v2 on `/bin/date` ====="
case "$1" in
    -h)
    /bin/echo "Usage:"
    /bin/echo "  $0 [N]"
    /bin/echo "  N means that monitor block devices N times and generate N log files.(Default N = 100)"
    exit 0
    ;;
esac

/bin/echo "Turn off/on VM block_dump & Clean dmesg"
/bin/echo 0 > /proc/sys/vm/block_dump
/bin/dmesg -c 2>/dev/null 1>/dev/null
/bin/dmesg -c 2>/dev/null 1>/dev/null
/bin/dmesg -c 2>/dev/null 1>/dev/null

_cnt=20
while [ ${_cnt} -gt 0 ]; do
    /bin/sync
    /bin/dmesg -c 2>/dev/null 1>/dev/null
    _cnt=$[$_cnt-1]
done
/bin/echo 1 > /proc/sys/vm/block_dump
/bin/date > /dev/null
_countdown 3
# ignore 10240 bytes
/bin/dd if=/proc/kmsg of=/dev/null bs=1 count=10240 2>/dev/null 1>/dev/null

/bin/echo "Start..."

[ "x$1" != "x" ] && MAXRUN=$1
_cnt=0

# remove log
/bin/rm -f $BLKDEV_LOG

while [ ${_cnt} -lt ${MAXRUN} ]; do
    echo "============= $_cnt/$MAXRUN test, `/bin/date` ==============="
    echo "============= $_cnt/$MAXRUN test, `/bin/date` ===============" >> $BLKDEV_LOG
    if [ $FORCE_STANDBY = 1 ]; then
        _check_standby
        if [ $? != 0 ]; then
            for i in $SD_DEVIVES; do
                # force standby
                /sbin/hdparm -y /dev/${i} 2>/dev/null 1>/dev/null
                if [ $? = 0 ]; then
                    echo "Issuing standby command in /dev/${i}"
                else
                    echo "/dev/${i} not found"
                fi
            done
        fi
        /bin/sleep 20
    fi
    analyse_kmsg
    _cnt=$[$_cnt+1]
    echo
    echo >> $BLKDEV_LOG
done

/bin/echo "Turn off block_dump"
/bin/echo 0 > /proc/sys/vm/block_dump
 
Status
Brak możliwości dodawania odpowiedzi.

Mogą Cię zainteresować

U
  • Zamknięte
  • Pytanie
Przy piwie PiHole stats
Odpowiedzi
0
Wyświetleń
410
Kontenery Docker i LXD
Usunięty użytkownik pigers
U
U
Przy piwie PiHole stats
Odpowiedzi
0
Wyświetleń
519
Kosz
Usunięty użytkownik pigers
U

Użytkownicy znaleźli tą stronę używając tych słów:

  1. blkdevMonitor
  2. proces