Linux下常用的日志收集命令(Redhat&SuSe)

   Linux下日志的采集和分析是一個非常重要的工作,一般廠商在你需要技術支持的時候,都需要你通過對應指令收集系統的信息,我這邊列舉下常用的兩個Linux廠商的收集命令(Redhat Linux以及SuSe Linux),便于收集后,對系統進行全面分析。

  sosreport是一個類型于supportconfig 的工具,sosreport是python編寫的一個工具,適用于centos(和redhat一樣,包名為sos)。supportconfig由于是shell 語言編寫的一個工具,對版本的依賴相對少些 ,但對一些工具的依賴相對多些(適用于SuSe Linux)。 

  在紅帽系列下,收取日志支持信息(sosreport)

[root@ip-172-31-22-8 ~]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.2 (Maipo)
[root@ip-172-31-22-8 ~]# yum -y install sos
[root@ip-172-31-22-8 ~]# sosreport 
sosreport (version 3.2)
This command will collect diagnostic and configuration information from
this Red Hat Enterprise Linux system and installed applications.
An archive containing the collected information will be generated in
/var/tmp/sos.HbPFQB and may be provided to a Red Hat support
representative.
Any information provided to Red Hat will be treated in accordance with
the published support policies at:
  https://access.redhat.com/support/
The generated archive may contain data considered sensitive and its
content should be reviewed by the originating organization before being
passed to any third party.
No changes will be made to system configuration.
Press ENTER to continue, or CTRL-C to quit.(1、默認情況下我們直接回車)
Please enter your first initial and last name [ip-172-31-22-8.us-west-2.compute.internal]: (2、保持默認)
Please enter the case id that you are generating this report for []: (3、保持默認)
 Setting up archive ...
 Setting up plugins ...
 Running plugins. Please wait ...
  Running 73/73: yum...                      
Creating compressed archive...
Your sosreport has been generated and saved in:
  /var/tmp/sosreport-ip-172-31-22-8.us-west-2.compute.internal-20160705094442.tar.xz(4、生成的文件所在的位置及文件名)
The checksum is: 6ff5127ef6e524cb68a2f60f06cd00d1
Please send this file to your support representative.
[root@ip-172-31-22-8 ~]# cd /var/tmp/
[root@ip-172-31-22-8 tmp]# tar xvJf sosreport-ip-172-31-22-8.us-west-2.compute.internal-20160705094442.tar.xz
[root@ip-172-31-22-8 tmp]# ls
sosreport-ip-172-31-22-8.us-west-2.compute.internal-20160705094442
sosreport-ip-172-31-22-8.us-west-2.compute.internal-20160705094442.tar.xz
sosreport-ip-172-31-22-8.us-west-2.compute.internal-20160705094442.tar.xz.md5
[root@ip-172-31-22-8 tmp]# cd sosreport-ip-172-31-22-8.us-west-2.compute.internal-20160705094442
[root@ip-172-31-22-8 sosreport-ip-172-31-22-8.us-west-2.compute.internal-20160705094442]# ls
boot       date  df         etc   hostname        ip_addr  last  lsmod  netstat  ps    route  sos_commands  sos_reports  uname   usr  version.txt
chkconfig  dev   dmidecode  free  installed-rpms  java     lib   mount  proc     root  run    sos_logs      sys          uptime  var
# 如上面命令可知,均是收集到的信息的信息
[root@ip-172-31-22-8 sosreport-ip-172-31-22-8.us-west-2.compute.internal-20160705094442]# cat route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.31.16.1     0.0.0.0         UG    100    0        0 eth0
172.31.16.0     0.0.0.0         255.255.240.0   U     100    0        0 eth0
[root@ip-172-31-22-8 sosreport-ip-172-31-22-8.us-west-2.compute.internal-20160705094442]# cat uptime
 09:44:47 up 13 days, 23:16,  1 user,  load average: 0.08, 0.04, 0.05

   在SuSe下收集日志信息

DYDMSQAAP01:~ # supportconfig -A
=============================================================================
                     Support Utilities - Supportconfig
                          Script Version: 2.25-197
                          Script Date: 2010 04 02
=============================================================================
Gathering system information
  Data Directory:    /var/log/nts_DYDMSQAAP01_160706_0851(生成的文件所在的目錄)
  Basic Server Health Check...                 Done
  RPM Database...                              Done
  Basic Environment...                         Done
  Basic Health Report...                       Done
  System Modules...                            Done
  Memory Details...                            Done
  Disk I/O...                                  Done
  System Logs...                               Done
  YaST Files...                                Done
  Auditing...                                  Done
  Crash Info...                                Done
  NTP...                                       Done
  PROC...                                      Done
  Boot Files...                                Done
  SLERT...                                     Skipped
  Updates...                                   Done
  SMT...                                       Skipped
  Novell eDirectory...                         Please Wait... Skipped
  Novell LUM...                                Skipped
  Novell NCP...                                Skipped
  Novell NSS...                                Skipped
  Novell DFS...                                Skipped
  Novell SMS...                                Skipped
  Novell NCS...                                Skipped
  Novell AFP...                                Skipped
  Novell CIFS...                               Skipped
  HA Cluster...                                Skipped
  OCFS2...                                     Skipped
  PAM...                                       Done
  LDAP...                                      Done
  CIMOM...                                     Done
  Open Files...                                Done
  Environment...                               Done
  ETC...                                       Done
  SYSCONFIG...                                 Done
  SYSFS...                                     Done
  System Daemons...                            Done
  CRON...                                      Done
  AT...                                        Done
  UDEV...                                      Done
  LVM...                                       Please Wait... Base Detail Done
  EVMS...                                      Skipped
  Software Raid...                             Done
  Multipathing...                              Done
  Networking...                                Done
  Web...                                       Done
  InfiniBand...                                Done
  DNS...                                       Done
  DHCP...                                      Done
  SLP...                                       Please Wait... Services Done
  SSH...                                       Done
  iSCSI...                                     Done
  Samba...                                     Done
  NFS...                                       Done
  AUTOFS...                                    Done
  SAR Files...                                 Skipped
  AppArmor...                                  Done
  Xen...                                       Skipped
  X...                                         Done
  Printing...                                  Done
  SMART Disks...                               Done
  Hardware...                                  Please Wait... Done
  File System List...                          Please Wait... Done
  Supportability Analysis...                   Please Wait... Done
Creating Tar Ball
==[ DONE ]===================================================================
  Log file tar ball: /var/log/nts_DYDMSQAAP01_160706_0851.tbz
  Log file size:     6.1M
  Log file md5sum:   795ead2be91d0caf956df417df47a3e8
  Please attach the log file tar ball to your open Service Request at the 
  following URL:
  https://secure-support.novell.com/eService_enu
  You can also upload the tar ball to ftp.novell.com/incoming, or just use
  supportconfig -ur <srnum>, to upload the tar ball automatically.
  If you cannot attach the tar ball to the SR, then email it to the engineer.
=============================================================================
DYDMSQAAP01:/var/log # file nts_DYDMSQAAP01_160706_0851.tbz
nts_DYDMSQAAP01_160706_0851.tbz: bzip2 compressed data, block size = 900k
DYDMSQAAP01:/var/log # bzip2 -d nts_DYDMSQAAP01_160706_0851.tbz
DYDMSQAAP01:/var/log # file nts_DYDMSQAAP01_160706_0851.tar
nts_DYDMSQAAP01_160706_0851.tar: POSIX tar archive (GNU)
DYDMSQAAP01:/var/log # tar -xf nts_DYDMSQAAP01_160706_0851.tar 
DYDMSQAAP01:/var/log # cd nts_DYDMSQAAP01_160706_0851/
DYDMSQAAP01:/var/log/nts_DYDMSQAAP01_160706_0851 # ls -l
total 96300
-rw------- 1 root root     1734 Jul  6 08:52 basic-environment.txt
-rw------- 1 root root    21527 Jul  6 08:51 basic-health-check.txt
-rw------- 1 root root     1347 Jul  6 08:52 basic-health-report.txt
-rw------- 1 root root   261427 Jul  6 08:54 boot.txt
-rw------- 1 root root    31110 Jul  6 08:55 chkconfig.txt
-rw------- 1 root root     9767 Jul  6 08:54 cimom.txt
-rw------- 1 root root    16498 Jul  6 08:52 crash.txt
-rw------- 1 root root    38903 Jul  6 08:55 cron.txt
-rw------- 1 root root     7815 Jul  6 08:55 dhcp.txt
-rw------- 1 root root    10417 Jul  6 08:55 dns.txt
-rw------- 1 root root   230829 Jul  6 08:54 env.txt
-rw------- 1 root root  1102736 Jul  6 08:54 etc.txt
-rw------- 1 root root       81 Jul  6 08:55 evms.txt
-rw------- 1 root root     4010 Jul  6 08:55 fs-autofs.txt
-rw------- 1 root root     4282 Jul  6 08:52 fs-diskio.txt
-rw------- 1 root root 32670989 Jul  6 08:56 fs-files.txt
-rw------- 1 root root    12013 Jul  6 08:55 fs-iscsi.txt
-rw------- 1 root root     7814 Jul  6 08:55 fs-smartmon.txt
-rw------- 1 root root      572 Jul  6 08:55 fs-softraid.txt
-rw------- 1 root root       86 Jul  6 08:54 ha.txt
-rw------- 1 root root   734341 Jul  6 08:55 hardware.txt
-rw------- 1 root root    15000 Jul  6 08:55 ib.txt
-rw------- 1 root root    22657 Jul  6 08:54 ldap.txt
-rw------- 1 root root   216738 Jul  6 08:55 lvm.txt
-rw------- 1 root root    23718 Jul  6 08:52 memory.txt
-rw------- 1 root root  4476203 Jul  6 08:52 messages.txt
-rw------- 1 root root   440234 Jul  6 09:08 modules.txt
-rw------- 1 root root    21196 Jul  6 08:55 mpio.txt
-rw------- 1 root root   107521 Jul  6 08:55 network.txt
-rw------- 1 root root     3120 Jul  6 08:55 nfs.txt
-rw------- 1 root root       91 Jul  6 08:54 novell-afp.txt
-rw------- 1 root root       88 Jul  6 08:54 novell-cifs.txt
-rw------- 1 root root       87 Jul  6 08:54 novell-dfs.txt
-rw------- 1 root root      175 Jul  6 08:54 novell-edir.txt
-rw------- 1 root root       87 Jul  6 08:54 novell-lum.txt
-rw------- 1 root root       91 Jul  6 08:54 novell-ncp.txt
-rw------- 1 root root      100 Jul  6 08:54 novell-ncs.txt
-rw------- 1 root root       87 Jul  6 08:54 novell-nss.txt
-rw------- 1 root root       87 Jul  6 08:54 novell-sms.txt
-rw------- 1 root root   345825 Jul  6 08:52 ntp.txt
-rw------- 1 root root       88 Jul  6 08:54 ocfs2.txt
-rw------- 1 root root   919369 Jul  6 08:54 open-files.txt
-rw------- 1 root root    48449 Jul  6 08:54 pam.txt
-rw------- 1 root root    37464 Jul  6 08:55 print.txt
-rw------- 1 root root   123950 Jul  6 08:52 proc.txt
-rw------- 1 root root   347020 Jul  6 08:52 rpm.txt
-rw------- 1 root root 11372907 Jul  6 09:08 sam.html
-rw------- 1 root root 20565977 Jul  6 09:08 sam.txt
-rw------- 1 root root    20861 Jul  6 08:55 samba.txt
-rw------- 1 root root      115 Jul  6 08:55 sar.txt
-rw------- 1 root root   328932 Jul  6 08:55 security-apparmor.txt
-rw------- 1 root root   319217 Jul  6 08:52 security-audit.txt
-rw------- 1 root root       86 Jul  6 08:54 slert.txt
-rw------- 1 root root    19265 Jul  6 08:55 slp.txt
-rw------- 1 root root       80 Jul  6 08:54 smt.txt
-rw------- 1 root root     7749 Jul  6 08:55 ssh.txt
-rw------- 1 root root    13105 Jul  6 09:08 supportconfig.txt
-rw------- 1 root root  1350213 Jul  6 08:54 sysconfig.txt
-rw------- 1 root root  1054696 Jul  6 08:54 sysfs.txt
-rw------- 1 root root   204323 Jul  6 08:55 udev.txt
-rw------- 1 root root  6626599 Jul  6 08:54 updates.txt
-rw------- 1 root root    51104 Jul  6 08:55 web.txt
-rw------- 1 root root    62111 Jul  6 08:55 x.txt
-rw------- 1 root root       86 Jul  6 08:55 xen.txt
-rw------- 1 root root 14045856 Jul  6 08:52 y2log.txt
我們可以看出,相關的文件全部是txt文件,而且日志信息也是非常詳細的。

注意事項:supportconfig -A,收集日志起來沒有sosreport那么快,有可能會出現卡住的狀態,耐心等待下,一般情況下,是沒有問題的。

原創文章,作者:Net21-冰凍vs西瓜,如若轉載,請注明出處:http://www.www58058.com/22468

(0)
Net21-冰凍vs西瓜Net21-冰凍vs西瓜
上一篇 2016-07-07
下一篇 2016-07-07

相關推薦

  • ntp時間服務器

    前言   ntp(Network Time protocol)是網絡時間協議,是用來使網絡中的各個計算機時間同步的一種協議。 ntp配置  1)ntp是由ntp軟件提供,如果沒有可以使用yum進行安裝  2)ntp配置文件介紹:/etc/ntp.conf   利用restrict來管理權限控制;語法格式:restric…

    Linux干貨 2015-06-24
  • keepalived +LVS DR 雙主互備模型實驗

    keepalived +LVS DR 雙主互備模型實驗  實驗環境介紹     操作系統:DR:centos 7.2 兩個節點,都安裝keepalived             &nbsp…

    Linux干貨 2016-03-09
  • GOPS 2016全球運維大會 上海站

    GOPS 2016全球運維大會 ? 上海站已經圓滿落幕,最新GOPS大會推薦:GOPS2017全球運維大會 ? 深圳站 基本信息: GOPS2017全球運維大會 ? 深圳站 時間:2017-04-21 08:00:00 至 2017-04-22 18:00:00結束 地點:深圳    會議規模:5000人 會議詳情:http://www.…

    系統運維 2016-09-07
  • 集群-基礎知識(2)

    負載均衡集群實現方法: 1、硬件方式 F5,CITRX,NETSCALER,A10(價格逐漸降低,由于為了防止調度器成為單點故障,所以要配置一臺備用設備,所以造價更高了) 2、軟件方式 四層:LVS(根據請求的ip和端口來分發),性能好,但對高級特性支持不好。 七層(反向代理):Nginx(http,smtp,pop3,imap),Haproxy(主要是ht…

    Linux干貨 2015-11-26
  • Hadoop簡介

    Hadoop的概要介紹 Hadoop,是一個分布式系統基礎架構,由Apache基金會開發。用戶可以在不了解分布式底層細節的情況下,開發分布式程序。充分利用集群的威力高速運算和存儲。 簡單地說來,Hadoop是一個可以更容易開發和運行處理大規模數據的軟件平臺。該平臺使用的是面向對象編程語言Java實現的,具有良好的可移植性。 Hadoop的發展歷史 &nbsp…

    Linux干貨 2015-04-13
  • Linux之任務計劃 crontab

    Linux之任務計劃    用過windows的同學應該都知道在控制面板中有一個“任務計劃”選項,我們可以通過向導設置讓計算機在某個時間點或者開機時運行某個腳本或者批處理等等,方便我們的日常管理監視工作;同樣在Linux系統中,如果我們想在開機時就運行某個操作,可以直接將命令寫入/etc/rc.local中,該操作就會在機器開機時運行;如…

    Linux干貨 2015-05-18
欧美性久久久久