Dedicated Servers: Testing New Machines
When you start using a new server, it’s a good idea to make sure you got what you paid for. Unfortunately, a lot of new users have a hard time retrieving server information that can only be accessed with console commands.
In this article, we’ll look at how information on Linux servers can be pulled up from the console.
General System Information
System information can be displayed using the uname command, which prints out the name of the active operating system. Entering one of the options below will give you more specific information:
# uname -a Linux srv1 3.8.0-35-generic #50-Ubuntu SMP Tue Dec 3 01:24:59 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
Here we have the name of the operating system and the kernel build date, version, and bit count: Tue Dec 3 01:24:59 UTC 2013, 3.8.0-35-generic, i386 — 32 bit, x86_84 — 64 bit.
- -a displays all available information;
- -i displays information on the kernel identifier;
- -m displays the present hardware platform;
- -n displays the name of the system;
- -p displays the server’s processor type;
- -r displays information on the operating system release date;
- -s displays the name of the operating system;
- -v displays information on the version of the operating system.
Information on the active operating system can be displayed using the cat /etc/issue command:
# cat /etc/issue Ubuntu 13.04 \n \l
There is an alternative way to display information on the distro:
# lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 13.04 Release: 13.04 Codename: raring
Hardware Information
lshw
The lshw tool prints out a complete list of system hardware components and their configuration. lshw is included by default in a lot of later Linux distributions; if it is not included, it can be installed using the standard package manager:
# apt-get install lshw
To view hardware information, enter the following command:
# lshw
A condensed version of this information can be displayed with the -short option:
# lshw -short
With lshw, we can also get information on individual system components. This is done with the -C key, after which we indicate the device we want information about:
— processor:
# lshw -C сpu
— memory:
# lshw -C memory
— disk subsystem:
# lshw -C disk
lspci
Using the lspci utility, we can view information on all of our PCI buses and the components connected to them. This is a part of the pciutils package, which is included in most modern Linux distros. If for some reason it isn’t, it can be installed from the standard package manager.
By default, lspci displays a concise device list; more detailed information can be retrieved using various options.
The -t option displays an information tree on buses and their attached devices. Only the hardware’s numerical identifiers are displayed:
# lspci -t -[0000:00]-+-00.0 +-01.0-[01]--+-00.0 | \-00.1 +-03.0-[02]--+-00.0 | \-00.1 +-07.0-[04]-- +-09.0-[05]-- +-14.0 +-14.1 +-1c.0-[03]----00.0 +-1d.0 +-1e.0-[06]----03.0 +-1f.0
The hardware’s numerical codes can be given with the -n option:
# lspci -n 01:00.1 0200: 14e4:1639 (rev 20) 02:00.0 0200: 14e4:1639 (rev 20) 02:00.1 0200: 14e4:1639 (rev 20) 03:00.0 0104: 1000:0079 (rev 05) 06:03.0 0300: 102b:0532 (rev 0a)
Each line starts with device’s code in “:.” format and then the code in “:” format.
To include the corresponding device names in the list, we use the -nn option:
# lspci -nn 01:00.0 Ethernet controller [0200]: Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet [14e4:1639] (rev 20) 03:00.0 RAID bus controller [0104]: LSI Logic / Symbios Logic MegaRAID SAS 2108 [Liberator] [1000:0079] (rev 05) 06:03.0 VGA compatible controller [0300]: Matrox Electronics Systems Ltd. MGA G200eW WPCM450 [102b:0532] (rev 0a)
Using the -s option, we can determine the hardware’s name based on the “:.” code:
# lspci -s 03:00.0 03:00.0 RAID bus controller: LSI Logic / Symbios Logic MegaRAID SAS 2108 [Liberator] (rev 05)
To determine the hardware using the “:” code, we use the -d option:
# lspci -d 1000:0079 03:00.0 RAID bus controller: LSI Logic / Symbios Logic MegaRAID SAS 2108 [Liberator] (rev 05)
After the -d key, we can include either the vendor or device ID; for example:
# lspci -d 8086: # lspci -d :0532
In this case, a list of all the devices that correspond to that code will be displayed.
To view information on the kernel’s drivers for a particular device, we use the -k option:
# lspci -k 00:1f.2 IDE interface: Intel Corporation 82801IB (ICH9) 2 port SATA Controller [IDE mode] (rev 02) Subsystem: Dell PowerEdge R610 SATA IDE Controller Kernel driver in use: ata_piix Kernel modules: ata_generic, pata_acpi, ata_piix 02:00.0 Ethernet controller: Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet (rev 20) Subsystem: Dell PowerEdge R610 BCM5709 Gigabit Ethernet Kernel driver in use: bnx2 Kernel modules: bnx2 03:00.0 RAID bus controller: LSI Logic / Symbios Logic MegaRAID SAS 2108 [Liberator] (rev 05) Subsystem: Dell PERC H700 Integrated Kernel driver in use: megaraid_sas Kernel modules: megaraid_sas
Pseudo-File System /proc
Linux systems save information on hardware components in the so-called pseudo-file system /proc. It’s called a “pseudo-file system” because it’s virtual and doesn’t take up any storage space. The majority of pseudo files saved in /proc in human-readable format. Many programs use the /proc tree to display system information.
Processor
Processor information is saved in the /proc/cpuinfo pseudo file. To view its contents, we enter the following command:
# cat /proc/cpuinfo
This command’s printout contains a lot of different information: processor model, number of cores, virtualization technology support, etc.
The most complicated section of this output is, of course, flags. They’re also present in the lshw output.
Let’s look at some of the most important flags:
- ht (HyperThreading) — simultaneous multithreading technology support; present in Intel Xeon, Pentium 4, Atom, Core i3, Core i5, Core i7 series processors;
- lm (long mode) — shows if the processor is 64 bit;
- vmx (for Intel), svd (for AMD) — hardware virtualization support; indicates the availability of instructions for providing direct access to processor resources from guest systems;
- aes — AES system extension support;
- hypervisor — shows if the OS was launched under a hypervisor;
- smx — TXT (TPM) technology support.
Detailed information on all flags can be found here.
Memory
We can view information on free and used memory, including swap space, using the command free. The command’s output looks like this:
# free -m total used free shared buffers cached Memory: 3627 3216 410 0 107 1157 -/+ buffers/cached: 1950 1676 Swap: 3762 31 3731
The -m option displays the amount of free and used space in terms of megabytes. To display the size in gigabytes, use the -g key; this is useful for servers with a lot of RAM (in the tens to hundreds of gigabytes).
Even more detailed information is saved in the proc/meminfo pseudo file.
The output from the cat /proc/meminfo command includes the following basic parameters:
- MemTotal — total amount of physical RAM;
- MemFree — the present amount of RAM available for dedicated processes;
- Buffers — area of memory where data is stored before being written to a disk;
- Cached — amount of physical RAM used as cache memory;
- SwapCached — amount of memory transferred to swap and then returned to physical RAM;
- Active — amount of memory occupied by the most frequently visited pages;
- Inactive — amount of memory occupied by pages presently not in use;
- Swap {total, free} — total amount of swap space available;
- Dirty — so called “dirty” pages (i.e. data stored in physical RAM, but still not written to the disk);
- Writeback — pages currently being written to the disk;
- AnonPages — anonymous pages (i.e. data used by programs but not associated with any files);
- Mapped — total amount of RAM transferred to virtual address space processes using mmap;
- Committed_AS — amount of memory allotted to all processes (even if not all used).
Disk Subsystem
To check partitions and the number of disks, we use the command:
# fdisk -l
The amount of free and occupied disk space in all monitored file systems can be found using the df command. The command takes the following options:
- -a prints information on all file systems;
- -h displays information in a user-friendly format;
- -T displays the kind of file system;
- -t displays information only on the specified file system types.
Let’s look at an example of a df -h output:
# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg0-vg0root 50G 15G 32G 32% / tmpfs 5.9G 0 5.9G 0% /dev/shm /dev/sda1 1008M 62M 895M 7% /boot /dev/mapper/vg0-var 2.7T 839G 1.7T 33% /var
Information on the actual amount of free space is displayed in the Available section. If you add up the numbers in the Available and Used sections, the sum won’t equal the amount indicated in the Size section. This is because a portion of disk space is set aside for system files and metadata.
Using smartctl, which is included in the official repository of most modern Linux distributions, we can get detailed information regarding a hard disk’s status. For complete information, we use the following command:
# smartctl -a /dev/sda
Information on how to interpret the output from this command can be found in this article.
To view information on physical volumes, we use the pvdisplay, pvs, and pvscan commands.
The pvscan command checks all of a system’s block devices for physical volumes.
# pvscan PV /dev/md0 VG vg0 lvm2 [462.96 GiB / 205.22 GiB free] Total: 1 [462.96 GiB] / in use: 1 [462.96 GiB] / in no VG: 0 [0 ]
Using the pvdisplay command, we can view detailed multi-line outputs for each physical volume:
# pvdisplay --- Physical volume --- PV Name /dev/md0 VG Name vg0 PV Size 462.96 GiB / not usable 1.87 MiB Allocatable yes PE Size 4.00 MiB Total PE 118517 Free PE 52536 Allocated PE 65981 PV UUID Idm6eZ-5vS0-IJCo-RDQq-WZNk-nJ22-eb7aDd
With the pvs command, we can configure how data is displayed (one volume per line). This could come in handy when writing scripts.
To view information on logical hard disk volumes, we use the lvs, lvscan, and lvsdiplay utilities, which are included in the lvm2 package. Lvm2 is installed from the standard package manager:
# apt-get install lvm2
The command lvscan prints out a list of all existing logical volumes (below is a fragment of the output listing):
# lvscan ACTIVE '/dev/vg0/root' [18.62 GiB] inherit ACTIVE '/dev/vg0/www' [200.00 GiB] inherit
Using lvdisplay, we can print out a list of logical volume attributes (name, size, markup). To view information on the attributes of a particular logical volume, we use the -v option and enter the name (below is a fragment of the output listing):
# lvdisplay --- Logical volume --- LV Name /dev/vg0/root VG Name vg0 LV UUID yPtVFt-BON5-agWC-jXSr-cU4x-Tcu9-NRiwMF LV Write Access read/write LV Status available # open 1 LV Size 18.62 GiB Current LE 4768 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 --- Logical volume --- LV Name /dev/vg0/www VG Name vg0 LV UUID reCzuE-5dgN-A4eB-LubM-VtUA-Lclq-MUt5v6 LV Write Access read/write LV Status available # open 1 LV Size 200.00 GiB Current LE 51200 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:2
The lvs command looks similar to the pvs command above: the data format can be configured and one line can be printed out for each volume.
# lvs LV VG Attr LSize Origin Snap% Move Log Copy% Convert root vg0 -wi-ao 18.62g www vg0 -wi-ao 200.00g
Information on RAID md states is saved to the /proc/mdstat pseudo file. Its contents can be viewed using the cat /proc/mdstat command:
# cat /proc/mdstat Personalities : [raid1] read_ahead 1024 sectors md1 : active raid1 hda3[0] hdc3[1] 522048 blocks [2/2] [UU] md0 : active raid1 hda2[0] hdc2[1] 4192896 blocks [2/2] [UU] md2 : active raid1 hda1[0] hdc1[1] 128384 blocks [2/2] [UU]
Looking at this example, we see the system contains three arrays. There is a separate section in the pseudo file /proc/mdstat for each of them, which contains the following information:
- RAID array name;
- RAID array status;
- array level;
- name of the array’s physical components;
- number of devices configured and working in the array;
- status of each working device (U means the device is up, _ means it’s down, sync means synchronization is in progress).
We can see if a server uses a hardware RAID by using our old friend lspci:
# lspci -nn | grep RAID
If a RAID is used, the console displays the following kind of response:
02:00.0 RAID bus controller [0104]: LSI Logic / Symbios Logic MegaRAID SAS 2108 [Liberator] [1000:0079] (rev 04)
It’s impossible to get information on the state of a hardware RAID without using special utilities: MegaCLI for LSI controllers and Adaptec Storage Manager (asm) for adaptec. These aren’t included in official Linux repositories. MegaCLI can be downloaded here and ASM from the Adaptec site.
Network Interfaces
Information on all the network interfaces connected to the system is contained in the /proc/net/dev pseudo file. After entering the cat /proc/net/dev command into the console, a list of all active and inactive network interfaces will be printed out.
The status of all the present network interfaces can be viewed using the ip link show up command. The ip address command prints information about all of the network interfaces:
# ip address 1: lo: mtu 16436 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:30:48:f2:7a:a0 brd ff:ff:ff:ff:ff:ff inet 5.178.83.252/29 brd 5.178.83.255 scope global eth0 inet6 fe80::230:48ff:fef2:7aa0/64 scope link valid_lft forever preferred_lft forever 3: eth1: mtu 1500 qdisc noop state DOWN qlen 1000 link/ether 00:30:48:f2:7a:a1 brd ff:ff:ff:ff:ff:ff
UP indicates that the interface is working; NO CARRIER means there is no cable or transceiver in the network port. The ip route command (ip r for short) prints a routing table in the console:
# ip r default via 88.93.16.185 dev br0 50.178.87.0/24 via 192.16.122.1 dev br0 10.0.0.0/8 via 192.16.122.1 dev br0 1.131.251.0/24 via 192.16.122.1 dev br0 192.16.122.0/24 dev br0 proto kernel scope link src 192.16.122.2 88.93.16.184/29 dev br0 proto kernel scope link src 88.93.16.186
Conclusion
This article is the first in a series of publications dedicated to problems configuring and administering web services. We plan on publishing articles about the particulars of installing and optimizing server software, diagnosing bugs, etc. in the near future.
We’d be happy to hear your requests and suggestions for future topics in the comments below.