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.178linux.com/22468

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

相关推荐

  • 正则表达式简述

    正则表达式简述 什么是正则表达式: 正则表达式,又称正规表示法、常规表示法(英语:Regular Expression,在代码中常简写为regex、regexp或RE),计算机科学的一个概念。正则表达式使用单个字符串来描述、匹配一系列符合某个句法规则的字符串。在很多文本编辑器里,正则表达式通常被用来检索、替换那些符合某个模式的文本。 正则表达式分类: 标准正…

    Linux干货 2016-04-05
  • 基于rsync+inotify实现数据实时同步传输

    前言 与传统的cp、tar备份方式相比,rsync具有安全性高、备份迅速、支持增量备份等优点,通过rsync可以解决对实时性要求不高的数据备份需求,但随着文件数量的增大和实时同步的要求,rsync已不能满足需求,随之rsync+inotify便应运而生。本文将讲解rsync的基础知识和如何基于rsync+inotify实现数据实时同步传输。 rsync相关介…

    Linux干货 2015-04-27
  • 6个变态的C语言Hello World程序

    下面的六个程序片段主要完成这些事情: 输出Hello, World 混乱C语言的源代码 下面的所有程序都可以在GCC下编译通过,只有最后一个需要动用C++的编译器g++才能编程通过。 hello1.c  #define _________ }     #define ______…

    Linux干货 2016-05-08
  • centos6,7分区,格式,挂载

     内核及文件系统的组成部分  文件系统驱动:   centos6如果使用xfs系统    yum -y install xfsprogs  文件系统管理工具   mkfs创建文件系统 mkfs.ext3   创建:mkfs.文件类型(ext2,ext3,xfs..)  …

    Linux干货 2016-08-26
  • Linux系统程序包管理工具-RPM

    一、rpm是什么 RPM 是RPM Package Manager(RPM软件包管理器)的缩写,这一文件格式名称虽然打上了RedHat的标志,但是其原始设计理念是开放式的。RPM包管理器(RPM)是一个强大的命令行驱动的包管理系统能够安装、卸载、验证、查询和更新计算机软件包。每个软件包包括存档的文件连同包和它的版本信息,描述等。还有一个库API,允…

    Linux干货 2015-11-19
  • UML图中类之间的关系:依赖,泛化,关联,聚合,组合,实现

    类与类图 1) 类(Class)封装了数据和行为,是面向对象的重要组成部分,它是具有相同属性、操作、关系的对象集合的总称。 2) 在系统中,每个类具有一定的职责,职责指的是类所担任的任务,即类要完成什么样的功能,要承担什么样的义务。一个类可以有多种职责,设计得好的类一般只有一种职责,在定义类的时候,将类的职责分解成为类的属性和操作(即方法)。 3) 类的属性…

    Linux干货 2015-04-07