Benutzer-Werkzeuge

Webseiten-Werkzeuge


nvme

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Nächste Überarbeitung
Vorhergehende Überarbeitung
nvme [2022-05-23 00:46:08] – angelegt manfrednvme [2022-05-23 18:12:26] (aktuell) – [FreeBSD] manfred
Zeile 7: Zeile 7:
  
   > cd /usr/ports/sysutils/nvme-cli/ && make install   > cd /usr/ports/sysutils/nvme-cli/ && make install
 +  
 +  > nvmecontrol devlist
 +  
   > nvmecontrol identify nvme0   > nvmecontrol identify nvme0
   > nvmecontrol identify -n 0 nvd0   > nvmecontrol identify -n 0 nvd0
 +  > nvmecontrol nsid nvme0
 +  > nvmecontrol nsid nvd0
 +  > nvmecontrol ns active nvme0
 +  
 +  > nvmecontrol logpage -p 1 nvme0
 +  
 +  > nvmecontrol power -l nvme0
 +  > nvmecontrol power nvme0
 +  
 +  > nvmecontrol ns controllers nvme0
 +  > nvmecontrol ns controllers nvd0
 +
 +
 +==== temp_hdd.sh ====
 +
 +{{ :bilder:temp_hdd.png |}}
 +Für die roten Festplatten werden Kernel-Meldungen mit Fehlern ausgegeben.
 +Das heißt, dass man sie schnellst möglich austauschen sollte.
 +
 +<file bash ~/bin/temp_hdd.sh>
 +#!/bin/sh
 +#
 +# https://github.com/cytopia/freebsd-tools/blob/master/hdd-temp.sh
 +#
 +# ----------------------------------------------------------------------------
 +# "THE BEER-WARE LICENSE" (Revision 42):
 +# <cytopia@everythingcli.org> wrote this file. As long as you retain this notice you
 +# can do whatever you want with this stuff. If we meet some day, and you think
 +# this stuff is worth it, you can buy me a beer in return cytopia
 +# ----------------------------------------------------------------------------
 +
 +#VERSION="v2018040800"          # aus dem Internet kopiert
 +VERSION="v2022051100"           # modifiziert; jetzt auch mit Seriennummer
 +
 +DEFEKTE_HDDS="$(dmesg | grep -Fi error | awk -F: '{sub("[(]",""); print $1}' | sort | uniq)"
 +
 +### Grenzwerte
 +#
 +#ROT="40"       # Originalwert
 +ROT="45"        # meine Erfahrung
 +#
 +#GELB="30"      # Originalwert
 +GELB="42"       # meine Erfahrung
 +
 +# ---------------------------------- Global Variables --------------------------------- #
 +# Colors
 +GREEN="\033[32m"
 +YELLOW="\033[33m"
 +RED="\033[31m"
 +OFF="\033[0m"
 +
 +# ---------------------------------- Misc Function ---------------------------------- #
 +
 +#
 +# Prequisites,
 +#  * check if this script is run by root
 +#  * check if smartctl is installed
 +#
 +check_requirements()
 +{
 +        # Check if we are root
 +        if [ "$(id -u)" != "0" ]; then
 +                echo "This script must be run as root" 1>&2
 +                exit 1
 +        fi
 +
 +        # Check if smartctl exists on the system
 +        command -v smartctl >/dev/null  || { echo "smartctl not found. (install sysutils/smartmontools)"; exit 1; }
 +}
 +
 +
 +#
 +# Colorize output of temperature (all platforms)
 +#
 +colorize_temperature()
 +{
 +        TEMP="${1}"
 +
 +        case "${TEMP}" in
 +                # no temperature obtained
 +                ''|*[!0-9]*)
 +                        TEMP="n.a."
 +                        ;;
 +                # temperature is obtained
 +                *)
 +                        if [ "${TEMP}" -gt "${ROT}" ]; then
 +                                TEMP="${RED}${TEMP}° C${OFF}"
 +                        elif [ "${TEMP}" -gt "${GELB}" ]; then
 +                                TEMP="${YELLOW}${TEMP}° C${OFF}"
 +                        else
 +                                TEMP="${GREEN}${TEMP}° C${OFF}"
 +                        fi
 +                        ;;
 +        esac
 +
 +        echo "${TEMP}"
 +}
 +
 +# ---------------------------------- Generic Disk Function ---------------------------------- #
 +
 +#
 +# Get all devices that are attached to the system
 +#
 +get_attached_devices()
 +{
 +        DEVS="$(sysctl kern.disks | awk '{$1=""; ;print $0}' | awk 'gsub(" ", "\n")' | tail -n500 -r | sed '/^cd[0-9]/d')"
 +        echo "${DEVS}"
 +}
 +
 +get_disk_bus()
 +{
 +        DEV="${1}"
 +        BUS="$(cat /var/run/dmesg.boot | grep -F "${DEV} at" | grep -F target | awk '{print $3}' | tail -n1)"
 +        echo "${BUS}"
 +}
 +
 +get_disk_size()
 +{
 +        DEV="${1}"
 +        SIZE="$(diskinfo -v /dev/${DEV} | grep -F bytes | awk '{printf "%8.2f\n",($1/(1024*1024*1024))}')"
 +        echo "${SIZE}"
 +}
 +
 +get_disk_speed()
 +{
 +        DEV="${1}"
 +        SPEED="$(cat /var/run/dmesg.boot | grep -F ${DEV}: | grep -F transfers | awk '{print $2};' | tail -n1)"
 +        echo "${SPEED}"
 +}
 +
 +get_disk_number()
 +{
 +        DEV="${1}"
 +        DISK_NUM="$(echo "${DEV}" | sed 's/[^0-9]*//g')"
 +        echo "${DISK_NUM}"
 +}
 +
 +
 +# ---------------------------------- ATA-Device Functions ---------------------------------- #
 +
 +get_ata_disk_name()
 +{
 +        DEV="${1}"
 +        NAME="$(cat /var/run/dmesg.boot | grep -F "${DEV}:" | grep -E '[<>]' | awk -F '[<>]' '{print $2}' | tail -n1)"
 +        echo "${NAME}"
 +}
 +
 +get_ata_disk_temp()
 +{
 +        DEV="${1}"
 +        TEMP="$(smartctl -d atacam -A "/dev/${DEV}" | grep -F Temperature_Celsius | awk '{print $10}')"
 +        echo "${TEMP}"
 +}
 +
 +# ---------------------------------- CISS-Device Functions ---------------------------------- #
 +
 +get_ciss_disk_name()
 +{
 +        SMART_CTL="${1}"
 +        NAME="$(echo "${SMART_CTL}" | grep -F "Device Model" | awk '{$1=$2=""} {sub(/^[ \t]+/, ""); print;}')"
 +        FIRM="$(echo "${SMART_CTL}" | grep -F "Firmware" | awk ' {$1=$2=""} {sub(/^[ \t]+/, ""); print;}')"
 +        echo "${NAME} ${FIRM}"
 +}
 +
 +get_ciss_disk_temp()
 +{
 +        SMART_CTL="${1}"
 +        TEMP="$(echo "${SMART_CTL}" | grep -F Temperature_Celsius | awk '{print $10}')"
 +        echo "${TEMP}"
 +}
 +
 +# ---------------------------------- Main Entry Point ---------------------------------- #
 +
 +# Check if script can be run
 +check_requirements
 +
 +
 +# Loop through all attached devices
 +for DEV in $(get_attached_devices)
 +do
 +        SIZE="$(get_disk_size ${DEV})"
 +        NVME="$(echo "${DEV}" | grep -F nvd | sed 's/^[a-z]*//g')"
 +        if [ "x${NVME}" = x ] ; then
 +                BUS="$(get_disk_bus ${DEV})"
 +                SPEED="$(get_disk_speed ${DEV})"
 +                SERIENNR="$(smartctl -i /dev/${DEV} | awk '/^Serial Number:[ ]*/{print $NF}' 2> /dev/null)"
 +
 +                # check for HP Smart Array controllers
 +                if [ "${BUS}" == "ciss*" ]; then
 +                        DEVNUM="$(get_disk_number ${DEV})"
 +                        SMARTCTL="$(smartctl -a -T permissive -d cciss,${DEVNUM} /dev/${BUS} 2> /dev/null)"
 +                        NAME="$(get_ciss_disk_name "${SMARTCTL}")"      # preserve newlines by using "
 +                        TEMP="$(get_ciss_disk_temp "${SMARTCTL}")"
 +                        echo "smartctl -a -T permissive -d cciss,${DEVNUM} /dev/${BUS} 2> /dev/null"    # debug
 +                else
 +                        NAME="$(get_ata_disk_name ${DEV})"
 +                        TEMP="$(get_ata_disk_temp ${DEV})"
 +                fi
 +
 +        else
 +                SMART_NVME="$(smartctl -a /dev/nvme${NVME} | grep -E '^Model Number:|^Serial Number:|^Namespace 1 Size/Capacity:|^Temperature:')"
 +                TEMP="$(echo "${SMART_NVME}" | grep -F 'Temperature:' | awk -F':' '{print $2}' | awk '{print $1}')"
 +                BUS="_______"
 +                SPEED="_______"
 +                SERIENNR="$(echo "${SMART_NVME}" | grep -F 'Serial Number:' | awk -F':' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//')"
 +                NAME="$(echo "${SMART_NVME}" | grep -F 'Model Number:' | awk -F':' '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//')"
 +        fi
 +
 +        TEMP="$(colorize_temperature ${TEMP})"
 +
 +        KAPUTT="$(echo "${DEFEKTE_HDDS}" | grep -E "^${DEV}$")"
 +        if [ "x${KAPUTT}" = x ] ; then
 +                echo -e "${TEMP}, ${BUS}:${DEV}\t${SPEED}\t${SERIENNR}\t${SIZE} GB, ${NAME}"
 +        else
 +                echo -e "${TEMP}, ${BUS}:${RED}${DEV}${OFF}\t${SPEED}\t${RED}${SERIENNR}${OFF}\t${RED}${SIZE} GB${OFF}, ${RED}${NAME}${OFF}"
 +        fi
 +done
 +
 +
 +# smartctl -i /dev/ada10 | awk '/^Device Model:[ ]*|^Serial Number:[ ]*|^User Capacity:[ ]*/{print $0}'
 +# smartctl -i /dev/ada10 | grep -E '^Device Model:|^Serial Number:|^User Capacity:' | awk '/^Device Model:[ ]*|^Serial Number:[ ]*|^User Capacity:[ ]*/{gsub(".*[:][ ]*",""); print $0}'
 +# smartctl -a /dev/nvme0 | grep -E '^Model Number:|^Serial Number:|^Namespace 1 Size/Capacity:|^Temperature:'
 +</file>
  
  
Zeile 17: Zeile 243:
  
   > apt install nvme-cli   > apt install nvme-cli
 +  
 +  > nvme list
 +  > nvme smart-log /dev/nvme0
 +  > nvme sanitize-log /dev/nvme0
 +  > nvme sanitize /dev/nvme0
  
  
/home/http/wiki/data/attic/nvme.1653266768.txt · Zuletzt geändert: von manfred