Saturday, June 29, 2013

Getting system information from Linux


 Some tips on how to extract system information on a Linux server:


Which version of Linux?

To learn which Linux OS you're running, type this command:
$ cat /proc/version
Linux version 2.6.18-164.el5 (mockbuild@x86-003.build.bos.redhat.com) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)) #1 SMP Tue Aug 18 15:51:48 EDT 2009

This will give some clues, but can be misleading. For instance, from this output you can see that “Red Hat 4.1” is mentioned, but the string “el5” clearly identifies that this is a Red Hat 5 distribution.

In a Red Hat distribution, the easiest way is to check the redhat-release file:
$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.4 (Tikanga)

So, this way there’s no doubt: this is a RHEL 5.4.


Which OS architecture type: 32-bit or 64-bit?

To find out if you have a 32-bit or 64-bit OS, use this command:
$ uname -i
x86_64

This will give the answer on-the-fly. But you can check more details:
$ uname -a
Linux vkdsso04.telecom.pt 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux

With these outputs, you’ll be able to identify which OS architecture you have:
  • x86_64 = 64-bit
  • ia64 = 64-bit
  • i386 = 32-bit


Which hardware?

The fastest way to check the server hardware is to use the examples below.

For CPU info, check the contents of cpuinfo file:
$ cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 15
model name      : Intel(R) Xeon(R) CPU           X5660  @ 2.80GHz
stepping        : 1
cpu MHz         : 2793.000
cache size      : 12288 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 11
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss syscall nx lm constant_tsc up ida nonstop_tsc pni cx16 lahf_lm
bogomips        : 5586.00
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management: [8]

For RAM info, check the contents of meminfo file:
$ cat /proc/meminfo
MemTotal:      3866476 kB
MemFree:        394056 kB
Buffers:        222236 kB
Cached:        1146980 kB
SwapCached:     202056 kB
Active:        2897996 kB
Inactive:       334572 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:      3866476 kB
LowFree:        394056 kB
SwapTotal:     2064376 kB
SwapFree:      1747252 kB
Dirty:              80 kB
Writeback:           0 kB
AnonPages:     1848948 kB
Mapped:          22968 kB
Slab:           211028 kB
PageTables:      10652 kB
NFS_Unstable:        0 kB
Bounce:              0 kB
CommitLimit:   3997612 kB
Committed_AS:  2449840 kB
VmallocTotal: 34359738367 kB
VmallocUsed:      2164 kB
VmallocChunk: 34359735687 kB
HugePages_Total:     0
HugePages_Free:      0
HugePages_Rsvd:      0
Hugepagesize:     2048 kB

For swap info, check the contents of swaps file:
$ cat swaps
Filename                                Type            Size    Used    Priority
/dev/mapper/VolGroup00-LogVol01         partition       2064376 317124  -1

For filesystems info, use the df command:
$ df -h
Filesystem                    Size  Used  Avail  Use%  Mounted on
/dev/mapper/vg_base-lv_root   28G   4.8G    22G   19%  /
tmpfs                        814M   176K   814M    1%  /dev/shm
/dev/sda1                    485M   120M   340M   27%  /boot


If you’re still not satisfied with the information provide, you can also use additional commands.

The top command:
$ top
top - 19:54:00 up 164 days,  7:53,  1 user,  load average: 0.00, 0.00, 0.00
Tasks:  87 total,   2 running,  85 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.0%us,  0.0%sy,  0.0%ni, 99.7%id,  0.0%wa,  0.0%hi,  0.3%si,  0.0%st
Mem:   3866476k total,  3482464k used,   384012k free,   222236k buffers
Swap:  2064376k total,   317124k used,  1747252k free,  1147024k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
    1 root      15   0 10348  260  204 S  0.0  0.0   0:10.36 init
    2 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 migration/0
    3 root      34  19     0    0    0 S  0.0  0.0   0:00.22 ksoftirqd/0
    4 root      10  -5     0    0    0 S  0.0  0.0  18:49.94 events/0
    5 root      13  -5     0    0    0 S  0.0  0.0   0:00.00 khelper
   36 root      11  -5     0    0    0 S  0.0  0.0   0:00.00 kthread
   40 root      10  -5     0    0    0 S  0.0  0.0   0:01.53 kblockd/0
   41 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 kacpid
  100 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 cqueue/0


The free command (-m flag for megabytes):
$ free -m
             total       used       free     shared    buffers     cached
Mem:          3775       3400        375          0        217       1120
-/+ buffers/cache:       2063       1712
Swap:         2015        309       1706

No comments:

Post a Comment