Shakiba Moshiri
  • Shakiba Moshiri (شکیبا مشیری)
  • opt
    • high traffic site optimization
      • infrastructure check
      • infrastructure test
  • tools
    • Cryptsetup
      • Container encryption using cryptsetup
    • curly
      • ftp
      • ssl
      • http
      • dns
      • ip
      • email
    • SSH
      • ssh password-less login
        • Untitled
    • volumes and FS
      • installing Gluster fs on Ubuntu 18.04 server
      • Accessing Gluster FS from the client machine
  • CDN
    • How does a CDN work
  • Server Panel
  • DirectAdmin
    • DirectAdmin through a reverse proxy
  • Web Server
    • Nginx
      • Live Steaming with Nginx and FFMPEG
  • Security
  • Container
    • Docker Networking 101
      • why docker networking is important?
      • type of networking in docker
    • Docker
      • How to run gitlab-runner with docker
      • using vim inside any container without installing it
      • Cannot connect to the Docker daemon at unix:///var/run/docker.sock
      • moving docker images around using ssh and pipe
      • How can I make docker-compose pull images using a socks5 proxy?
  • Stack Overflow
  • Github
  • vmware
    • tools
      • how to install vmware CLI govc on Linux
  • Windows
    • How to Erase a Recovery Partition in Windows
Powered by GitBook
On this page
  • dmidecode
  • lshw
  • ethtool
  • lsblk
  • smartctl

Was this helpful?

  1. opt
  2. high traffic site optimization

infrastructure check

first checking the infrastructure that we have

dmidecode

dmidecode - DMI table decoder dmidecode is a tool for dumping a computer's DMI (some say SMBIOS) table contents in a human-readable format.

Usage dmidecode --type | -t Available options

bios
system
baseboard
chassis
processor
memory
cache
connector
slot

Three of them are more useful

sudo dmidecode --type system
sudo dmidecode --type processor
sudo dmidecode --type memory

Test on a dedicated server (sudo dmidecode --type system)

sudo dmidecode --type system
System Information
Manufacturer: HP
Product Name: ProLiant DL360 G7
Version: Not Specified
Serial Number: ...
...
Family: ProLiant

Test on a Virtual Server in Hetzner (sudo dmidecode --type system)

sudo dmidecode --type system
System Information
Manufacturer: Hetzner
Product Name: vServer
Version: ...
Serial Number: ...
...
Family: Hetzner_vServer

lshw

lshw - list hardware

First see all available options, sample output:

sudo lshw |& grep '\*-[a-z]\+'
  *-core
     *-cache:0
     *-cache:1
     *-cache:2
     *-cache:3
     *-cpu
     *-memory
        *-bank:0
        *-bank:1
        *-bank:2
        *-bank:3
     *-firmware
     *-pci
        *-display
        *-usb
           *-usbhost:0
              *-usb:0
              *-usb:1
           *-usbhost:1
        *-generic
        *-communication:0
        *-communication:1
        *-storage
        *-isa
        *-memory UNCLAIMED
        *-multimedia
        *-serial UNCLAIMED
        *-network
     *-scsi:0
        *-disk
           *-volume:0
           *-volume:1
           *-volume:2
              *-logicalvolume
           *-volume:3
     *-scsi:1
        *-cdrom
  *-power UNCLAIMED

Four useful ones are cpu, memory, disk, network which we can see using -class arguments

sudo lshw -class cpu
sudo lshw -class memory
sudo lshw -class network
sudo lshw -class disk

here we are more interested in network and disk, first for network find how many interfaced we have:

ip -br a
lo               UNKNOWN        127.0.0.1/8 ::1/128 
enp3s0f0         UP             <ip4>/24 <ip6>/64 
enp3s0f1         DOWN           
enp4s0f0         DOWN           
enp4s0f1         DOWN 

then check that one which is up.

sudo lshw -sanitize -class network
  *-network:0               
       description: Ethernet interface
       product: NetXtreme II BCM5709 Gigabit Ethernet
       vendor: Broadcom Inc. and subsidiaries
       physical id: 0
       bus info: pci@0000:03:00.0
       logical name: enp3s0f0     # the interface name which is UP
       version: 20
       serial: [REMOVED]
       size: 1Gbit/s              # this is what we looked for
       capacity: 1Gbit/s          # this is what we looked for
       width: 64 bits
       clock: 33MHz
       ...
       ...
  *-network:1
       description: Ethernet interface
       product: NetXtreme II BCM5709 Gigabit Ethernet
       vendor: Broadcom Inc. and subsidiaries
       ...
       ...

here -sanitize is for removing sensitive information like serial numbers, etc.

ethtool

ethtool - query or control network driver and hardware settings

It is more userful for network interface card check , an example of a home machine with home router

ethtool eth0
Settings for eth0:
	Supported ports: [ TP ]
	Supported link modes:   10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	                        1000baseT/Full 
	Supported pause frame use: No
	Supports auto-negotiation: Yes
	Supported FEC modes: Not reported
	Advertised link modes:  10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	                        1000baseT/Full 
	Advertised pause frame use: No
	Advertised auto-negotiation: Yes
	Advertised FEC modes: Not reported
	Speed: 100Mb/s
	Duplex: Full
	Port: Twisted Pair
	PHYAD: 1
	Transceiver: internal
	Auto-negotiation: on
	MDI-X: on (auto)
Cannot get wake-on-lan settings: Operation not permitted
	Current message level: 0x00000007 (7)
			       drv probe link
	Link detected: yes

and we are interested in Speed: 100Mb/s which shows the speed

on a clould server Speed: Unknown! , so it is not always available

first check the NIC name

ip -br a
lo               UNKNOWN        127.0.0.1/8 ::1/128 
eth0             UP             192.168.1.3/24 fe80::85b0:c2fb:fcba:9c0d/64

then check it by ethtool

ethtool eth0
Settings for eth0:
	Supported ports: [ ]
	Supported link modes:   Not reported
	Supported pause frame use: No
	Supports auto-negotiation: No
	Supported FEC modes: Not reported
	Advertised link modes:  Not reported
	Advertised pause frame use: No
	Advertised auto-negotiation: No
	Advertised FEC modes: Not reported
	Speed: Unknown!
	Duplex: Unknown! (255)
	Port: Other
	PHYAD: 0
	Transceiver: internal
	Auto-negotiation: off
	Link detected: yes

On a dedicated server

ethtool enp3s0f0
Settings for enp3s0f0:
	Supported ports: [ TP ]
	Supported link modes:   10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	                        1000baseT/Full 
	Supported pause frame use: No
	Supports auto-negotiation: Yes
	Supported FEC modes: Not reported
	Advertised link modes:  10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	                        1000baseT/Full 
	Advertised pause frame use: No
	Advertised auto-negotiation: Yes
	Advertised FEC modes: Not reported
	Speed: 1000Mb/s
	Duplex: Full
	Port: Twisted Pair
	PHYAD: 1
	Transceiver: internal
	Auto-negotiation: on
	MDI-X: off
	Supports Wake-on: g
	Wake-on: g
	Link detected: yes
	
	# or just check the speed
	enp3s0f0 | grep -i speed
	Speed: 1000Mb/s

What if we could not install ethtool or it did not show the port speed?

We can look at /sys/class/net/{nic-name}/speed which can show in the speed

# see the NIC names
ls  /sys/class/net
eth0  lo

# then we use eth0
cat /sys/class/net/eth0/speed 
100

# with ethtool
sudo ethtool eth0 | grep -i speed
[sudo] password for shu: 
	Speed: 100Mb/s

lsblk

lsblk - list block devices

lsblk lists information about all available or the specified block devices. The lsblk command reads the sysfs filesystem and udev db to gather information.

If this command was not installed by default , install it

# debian based
sudo apt install util-linux

# red hat based
sudo yum install util-linux

# arch
sudo pacman -S util-linux

Simple example

# on a virutal sever
lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   50G  0 disk
└─sda1   8:1    0   50G  0 part /
sr0     11:0    1 1024M  0 rom

Check for type disk , if it is HDD or SSD with lsblk is simple

lsblk -o name,rota
NAME    ROTA
sda        1
├─sda1     1
├─sda14    1
└─sda15    1
sr0        1

# or 
lsblk -o NAME,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,SCHED,RQ-SIZE,RA,WSAME
NAME   ALIGNMENT MIN-IO OPT-IO PHY-SEC LOG-SEC ROTA SCHED RQ-SIZE  RA WSAME
sda            0    512      0     512     512    1 cfq       128 128    0B
└─sda1         0    512      0     512     512    1 cfq       128 128    0B
sr0            0    512      0     512     512    1 cfq       128 128    0B

# which can be replaced with -t
lsblk -t
NAME   ALIGNMENT MIN-IO OPT-IO PHY-SEC LOG-SEC ROTA SCHED RQ-SIZE  RA WSAME
sda            0    512      0     512     512    1 cfq       128 128    0B
└─sda1         0    512      0     512     512    1 cfq       128 128    0B
sr0            0    512      0     512     512    1 cfq       128 128    0B

even if the disk is SSD or NVMe the result seems to be HDD which is misleading and the reason is because it is a VM and it depends of bus type which has been chosen for the VM.

Also we can check th disk type by checking sys file

cat /sys/block/sda/queue/rotational
1

smartctl

smartctl - Control and Monitor Utility for SMART Disks

smartctl controls the Self-Monitoring, Analysis and Reporting Technology (SMART) system built into most ATA/SATA and SCSI/SAS hard drives and solid-state drives.

if it was not installed, you can install it

sudo pacman -S install smartmontools

On Debian, Ubuntu:

sudo apt install smartmontools

On RHEL, CentOS:

sudo yum install smartmontools

On openSUSE:

sudo zypper install smartmontools
Previoushigh traffic site optimizationNextinfrastructure test

Last updated 4 years ago

Was this helpful?