# Diagnostic commands

Bunch of useful commands for checking your system.


# Megaraid

# Get raid data

MegaCli -CfgDsply -aAll; MegaCli -LDInfo -LAll -aAll; MegaCli -PdList -aALL | egrep "Slot|Device Id|Inquiry Data"

# Smartctl

Smartctl commands for checking the health of disks

# Install smartctl

apt-get install -y smartmontools

# Using sda/sdb/sdc

Regular disks with the sda/sdb/sdc naming convention

for i in /dev/sd?; do echo "$i"; smartctl -a "$i"; echo; done

# Using Megaraid

Disks connected via a Megaraid controller

smartctl --scan | grep "megaraid," | awk '{ print $3 }' | sed -r 's/.*,([0-9]*)/\1/g' | while read x; do echo Device $x;smartctl -a -d megaraid,$x /dev/sda; done

# Using LSI Megaraid

Disk that require the storcli command. This assumes that the raid disk is being presented as /dev/sda

storcli /call /dall show | awk '{ print $5 }' | grep -E "[0-9]{1,2}" | while read x; do echo Device $x;smartctl -a -d sat+megaraid,$x /dev/sda; done

# Using NVMe

nvme list && echo && for i in /dev/nvme?n1; do echo "$i"; nvme smart-log "$i"; nvme smart-log-add "$i"; echo; done

# FIO

Testing disk iops

# Install fio first

apt-get install -y fio

# Write test

Fixed runtime of 120 seconds

fio --name=rand-write --ioengine=libaio --iodepth=32 --rw=randwrite --invalidate=1 --bsrange=4k:4k,4k:4k --size=512m --runtime=120 --time_based --do_verify=1 --direct=1 --group_reporting --numjobs=1

# Read test

Fixed runtime of 120 seconds

fio --name=rand-read --ioengine=libaio --iodepth=32 --rw=randread --invalidate=1 --bsrange=4k:4k,4k:4k --size=512m --runtime=120 --time_based --do_verify=1 --direct=1 --group_reporting --numjobs=1

# Read/Write test - 2 Mins

Fixed runtime of 120 seconds

fio --name=rand-rw --ioengine=libaio --iodepth=32 --rw=randrw --invalidate=1 --bsrange=4k:4k,4k:4k --size=512m --runtime=120 --time_based --do_verify=1 --direct=1 --group_reporting --numjobs=1

# Read/Write test - 4GB

Creates a 4GB file in the current directory to test with

fio --name=test --ioengine=libaio --iodepth=64 --rw=randrw --gtod_reduce=1 --filename=test --bs=4k  --size=4G --rwmixread=75 --randrepeat=1 --direct=1

# lm-sensors

Utility for checking the temperature sensors of your machine.

# Install lm-sensors

apt-get update
apt-get install -y lm-sensors

Run the following command (Answer Y to all prompts):

sensors-detect

Finally, run the following command:

sensors

# Process Tree

Useful for finding out what started a process on your system.

ps auxf

# List Network Ports

Alternative to netstat

ss -tulpn

-t - TCP
-u - UDP
-l - Listening
-p - Process
-n - Do not resolve hostnames

# NTP Stuff

# Force Check

CentOS6

service ntpd stop; ntpd -gq; service ntpd start

OS not in the stone age

systemctl stop ntpd; ntpd -gq; systemctl start ntpd

# Useful commands

Show sync status

ntpstat

Force a sync

ntpd -gq

-g ignore large time differences
-q exit ntpd after (otherwise it carries on running)

Show peers

ntpq -p

Query a server

ntpdate -q pool.ntp.org

# Yum

Issues with updating using Yum can be due to:

  • Time/Date setting
  • Out of date certificates

Example error:

Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again
sudo yum clean all
sudo yum --disablerepo="epel" update nss ca-certificates
sudo yum makecache
sudo yum update

# Delete dmraid Metadata

DEVICE=/dev/sda
dd if=/dev/zero of=$DEVICE bs=512 seek=$(( $(blockdev --getsz $DEVICE) - 1024 )) count=1024

# Curl Tricks

# Use different IP for domain

This is used instead of changing the host header.

curl -vI --resolve custom.domain.com:443:192.168.1.101 https://custom.domain.com
Last Updated: 2021/04/28 16:44+00:00