Showing posts with label Unix. Show all posts
Showing posts with label Unix. Show all posts

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

Getting system information from Solaris

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


Which version of Solaris?

To learn which Solaris OS you're running, type this command:

$ cat /etc/release
                       Solaris 8 2/02 s28s_u7wos_08a SPARC
           Copyright 2002 Sun Microsystems, Inc.  All Rights Reserved.
                           Assembled 18 December 2001

So, this way there’s no doubt: this is a Solaris 8.
The uname command can give the same information, but with a different format:
$ uname -a
SunOS hostanme 5.8 Generic_117350-41 sun4u sparc SUNW,Ultra-60

To “translate” this, you need to know that SunOS is the kernel and that Solaris is the whole operating system.

In the examples above, you can see that Solaris 8 is built on top of SunOS 5.8 kernel.



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:
$ isainfo -kv
64-bit sparcv9 kernel modules



Which hardware?

The prtdiag command will give almost all the hardware information you need for a quick overview:
$ prtdiag -v
System Configuration:  Sun Microsystems  sun4u Sun Enterprise 220R (UltraSPARC-II 450MHz)
System clock frequency: 113 MHz
Memory size: 2048 Megabytes

========================= CPUs =========================

                    Run   Ecache   CPU    CPU
Brd  CPU   Module   MHz     MB    Impl.   Mask
---  ---  -------  -----  ------  ------  ----
 0     0     0      450     4.0   US-II    10.0


========================= IO Cards =========================

     Bus   Freq
Brd  Type  MHz   Slot        Name                          Model
---  ----  ----  ----------  ----------------------------  --------------------
 0   PCI    33     On-Board  network-SUNW,hme
 0   PCI    33     On-Board  scsi-glm/disk (block)         Symbios,53C875
 0   PCI    33     On-Board  scsi-glm/disk (block)         Symbios,53C875

No failures found in System
===========================

========================= HW Revisions =========================

ASIC Revisions:
---------------
PCI: pci Rev 4
PCI: pci Rev 4
Cheerio: ebus Rev 1

System PROM revisions:
----------------------
  OBP 3.23.1 1999/07/16 12:08   POST 2.0.2 1998/10/19 10:46



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 filesystems info, use the df command:
$ df -k
Filesystem            kbytes    used   avail capacity  Mounted on
/dev/md/dsk/d10      3096423 2663020  371475    88%    /
/proc                      0       0       0     0%    /proc
mnttab                     0       0       0     0%    /etc/mnttab
fd                         0       0       0     0%    /dev/fd
/dev/md/dsk/d30      5040814 3294088 1696318    67%    /var
swap                 1273528      32 1273496     1%    /var/run
swap                 1298976   25480 1273496     2%    /tmp
/dev/md/dsk/d40      8065025 7240047  744328    91%    /opt
/dev/md/dsk/d50      16735338 14392111 2175874    87%    /export


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


The top command:
$ top
load averages:  1.52,  1.25,  1.23                                                                                   11:57:32
94 processes:  92 sleeping, 1 running, 1 on cpu
CPU states:  0.0% idle, 99.4% user,  0.6% kernel,  0.0% iowait,  0.0% swap
Memory: 2048M real, 819M free, 2271M swap in use, 1245M swap free

   PID USERNAME LWP PRI NICE  SIZE   RES STATE    TIME    CPU COMMAND
 10611 wlvision 208   0   10  622M  169M run    3136.7 76.15% java
 27502 root      17  58    0   29M   11M sleep   28:18  0.80% opcmona
 27458 root      13  59    0   13M 6752K sleep   22:17  0.77% ovbbccb
 27461 root      11  59    0   45M   10M sleep   22:02  0.48% coda
 28966 wlintra   58  28   10  209M   68M sleep   39.5H  0.21% java
 16985 webservd   1  48    0 1864K 1160K cpu      0:00  0.19% top
  3774 root      24  52    0   98M   18M sleep  102.5H  0.13% java
  9112 wlintra  112  29   10  435M  149M sleep   38.9H  0.13% java
 29804 root      12  50    0 8600K 6040K sleep  127:03  0.07% nscd
  7004 wlvision  22  28   10   61M   10M sleep  183:56  0.05% rmid
 15748 webservd   1  58    0 6776K 2320K sleep    0:00  0.05% sshd
  7003 wlvision  15  28   10   61M 8216K sleep  126:31  0.05% rmiregistry
 27462 root      13  59    0   22M 8552K sleep    4:42  0.03% opcmsga
 12877 wluser    55  28   10  192M   56M sleep  856:25  0.00% java
 10366 wlvision  69  28   10  306M  117M sleep  622:01  0.00% java