linux下osreport命令实战

  • linux下osreport命令实战已关闭评论
  • 115 views
  • A+
所属分类:未分类

Sosreport:一个可扩展,可移植的支持数据收集工具。它是一个从类Unix操作系统中收集系统配置详细信息和诊断信息的工具

安装

1:Red Hat或者centos下,你可以使用Yum或DNF包管理器安装它,如下所示。

$ sudo yum install sos

或者,

$ sudo dnf install sos

2:在Debian,Ubuntu和Linux Mint上运行:

$ sudo apt install sosreport

用法

安装后,直接运行sosreport,如下:

[root@xubo ~]# sosreport

sosreport (version 3.6)

This command will collect diagnostic and configuration information from
this CentOS Linux system and installed applications.

An archive containing the collected information will be generated in
/var/tmp/sos.QhxRej and may be provided to a CentOS support
representative.

Any information provided to CentOS will be treated in accordance with
the published support policies at:

https://wiki.centos.org/

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.

按 ENTER 键继续,或者 CTRL-C 组合键退出。

Please enter the case id that you are generating this report for []:

Setting up archive ...
Setting up plugins ...
Running plugins. Please wait ...
Starting 1/77 alternatives [Running: alternatives] 
Starting 3/77 anacron [Running: alternatives anacron] 
Starting 2/77 anaconda [Running: alternatives anacron anaconda] 
Starting 4/77 auditd [Running: alternatives anacron anaconda auditd] 
Starting 5/77 block [Running: alternatives anaconda auditd block] 
Starting 6/77 boot [Running: auditd block boot] 
Starting 7/77 btrfs [Running: block boot btrfs] 
Starting 8/77 cgroups [Running: block boot btrfs cgroups] 
Starting 9/77 cron [Running: block boot cgroups cron] 
Starting 10/77 crypto [Running: block boot cgroups crypto] 
Starting 11/77 date [Running: block boot cgroups date] 
Starting 12/77 dbus [Running: boot cgroups date dbus] 
Starting 13/77 devicemapper [Running: boot date devicemapper] 
Starting 14/77 devices [Running: boot date devicemapper devices]
Starting 15/77 dracut [Running: boot date devices dracut] 
Starting 16/77 filesys [Running: boot date dracut filesys] 
Starting 17/77 firewalld [Running: date dracut filesys firewalld] 
Starting 18/77 grub2 [Running: date dracut firewalld grub2]
...
Finishing plugins [Running: host systemd] 
Starting 76/77 xfs [Running: host systemd xfs] 
Starting 77/77 yum [Running: host systemd xfs yum] 
Finishing plugins [Running: host systemd yum] 
Finishing plugins [Running: systemd yum] 
Finishing plugins [Running: yum] 
Finished running plugins


生成压缩归档......

Your sosreport has been generated and saved in:
 /var/tmp/sosreport-xubo-2019-04-15-bwffcfg.tar.xz

The checksum is: 9eb3940088b093a1d0ce0ddfae5c1988

Please send this file to your support representative.

中间,会让你输入一些系统信息等。你可以直接默认不写回车就行。

如果你不希望系统提示你输入此类详细信息,请如下使用批处理模式,命令如下:

sosreport --batch

执行完成后,会产生两个文件,如下:

[root@xubo tmp]# pwd
/var/tmp
[root@xubo tmp]# ls
sosreport-xubo-2019-04-15-bwffcfg.tar.xz sosreport-xubo-2019-04-15-bwffcfg.tar.xz.md5

查看结果

执行命令后会生成一个问题,如上面/var/tmp/sosreport-xubo-2019-04-15-bwffcfg.tar.xz,解压文件

进入到/var/tmp目录下,解压,命令如下:

tar -Jxf sosreport-xubo-2019-04-15-bwffcfg.tar.xz

然后接入到解压目录就可以查看了,如下:

[root@xubo sosreport-xubo-2019-04-15-bwffcfg]# pwd
/var/tmp/sosreport-xubo-2019-04-15-bwffcfg
[root@xubo sosreport-xubo-2019-04-15-bwffcfg]# ls
boot df free ip_addr lib lsof netstat pstree run sos_reports uname var
chkconfig dmidecode hostname java lsb-release lspci proc root sos_commands sos_strings uptime version.txt
date etc installed-rpms last lsmod mount ps route sos_logs sys usr vgdisplay

比如,我们要看看系统启动的时间,如下:

[root@xubo sosreport-xubo-2019-04-15-bwffcfg]# more uptime 
 19:56:36 up 1 min, 1 user, load average: 0.64, 0.25, 0.09

参数详解

实例一

列出所有插件

如下:

[root@xubo sosreport-xubo-2019-04-15-bwffcfg]# sosreport -l
sosreport (version 3.6)
目前已启用了以下插件:
alternatives System alternatives
 anaconda Anaconda installer
 anacron Anacron job scheduling service
 auditd Audit daemon information
 block Block device information
 boot Bootloader information
 btrfs Btrfs filesystem
 cgroups Control groups subsystem
 cron Cron job scheduler
 crypto System crypto services information
 date Basic system time information
 dbus D-Bus message bus
 devicemapper device-mapper framework
 devices devices specific commands
 dracut Dracut initramfs generator
 filesys Local file systems
 firewalld Firewall daemon
 grub2 GRUB2 bootloader
 hardware General hardware information
 host Host information
 hts Red Hat Hardware Test Suite
 i18n Internationalization
 jars Collect information about available Java archives.
 java Java runtime
 kdump Kdump crash dumps
 kernel Linux kernel
 krb5 Kerberos authentication
 last login information
 ldap LDAP configuration
 libraries Dynamic shared libraries
 libvirt libvirt virtualization API
 logrotate LogRotate service
 logs System logs
 lvm2 LVM2 volume manager
 md MD RAID subsystem
 megacli LSI MegaRAID devices
 memory Memory configuration and use
 mpt LSI Message Passing Technology
 mrggrid MRG GRID engine
 mrgmessg MRG Messaging subsystem
 multipath Device-mapper multipath tools
 networking network and device configuration
 networkmanager NetworkManager service configuration
 nis Network information service
 nss Network Security Services configuration
 ntb Linux PCI-Express Non-Transparent Bridge
 openhpi Open Hardware Platform Interface
 openshift Openshift 2.x node and broker
 openssl openssl related information
 pam Pluggable Authentication Modules
 pci PCI devices
 perl Perl runtime
 postfix Postfix smtp server
 ppp Point-to-point protocol
 process process information
 processor CPU information
 python Python runtime
 release Linux release information
 rpm RPM Package Manager
 scsi SCSI devices
 selinux SELinux access control
 services System services
 soundcard Sound devices
 ssh Secure shell service
 system core system information
 systemd System management daemon
 sysvipc SysV IPC
 teamd Network interface teaming
 tuned Tuned system tuning daemon
 udev udev dynamic device management
 unpackaged Collects a list of files that are not handled by the package
 manager
 usb USB devices
 vhostmd vhostmd virtualization metrics collection
 x11 X windowing system
 xen Xen virtualization
 xfs XFS filesystem
 yum yum information

目前禁用了以下插件:

abrt inactive Automatic Bug Reporting Tool
 acpid inactive ACPI daemon information
 activemq inactive ActiveMQ message broker
 ansible inactive Ansible configuration management
 apache inactive Apache http daemon
 ata inactive ATA and IDE information
 atomichost inactive Atomic Host
 autofs inactive Autofs on-demand automounter
 azure inactive Microsoft Azure client
 boom inactive Configuration data for the boom boot manager.
 buildah inactive Buildah container and image builder
 ceph inactive CEPH distributed storage
 ceph_ansible inactive CEPH distributed storage - Ansible installer
 chrony inactive Chrony clock (for Network time protocol)
 clear_containers inactive Intel(R) Clear Containers configuration
 cman inactive cman based Red Hat Cluster High Availability
 cobbler inactive Cobbler installation server
 collectd inactive Collectd config collector
 conntrackd inactive conntrackd - netfilter connection tracking user-space daemon
 corosync inactive Corosync cluster engine
 crio inactive CRI-O containers
 cs inactive Certificate System and Dogtag
 ctdb inactive Samba Clustered TDB
 cups inactive CUPS IPP print service
 dhcp inactive DHCP daemon
 distupgrade inactive Distribution upgrade data
 dlm inactive DLM (Distributed lock manager)
 dmraid inactive dmraid software RAID
 dnf inactive dnf package manager
 docker inactive Docker containers
 docker_distribution inactive Docker Distribution
 dovecot inactive dovecot server related information
 ds inactive Directory Server
 elastic inactive ElasticSearch service
 etcd inactive etcd plugin
 fcoe inactive Fibre Channel over Ethernet
 fibrechannel inactive Collects information on fibrechannel devices, if present
 foreman inactive Foreman/Satellite 6 systems management
 gdm inactive GNOME display manager
 gfs2 inactive GFS2 (Global Filesystem 2)
 gluster inactive GlusterFS storage
 gluster_block inactive Gluster Block
 gnocchi inactive Gnocchi - Metric as a service
 grafana inactive Fetch Grafana configuration, logs and CLI output
 grub inactive GRUB bootloader
 haproxy inactive HAProxy load balancer
 hpasm inactive HP Advanced Server Management
 infiniband inactive Infiniband data
 insights inactive Collect config and log for Red Hat Insights
 ipa inactive Identity, policy, audit
 ipmitool inactive IpmiTool hardware information.
 iprconfig inactive IBM Power RAID storage adapter configuration information
 ipsec inactive Internet protocol security
 ipvs inactive Linux IP virtual server
 iscsi inactive iSCSI initiator
 iscsitarget inactive iSCSI target
 kata_containers inactive Kata Containers configuration
 keepalived inactive Keepalived routing server
 kernelrt inactive Realtime kernel variant
 keyutils inactive Kernel key ring
 kimchi inactive kimchi-related information
 kpatch inactive Kpatch information
 kubernetes inactive Kubernetes plugin
 kvm inactive Kernel virtual machine
 lightdm inactive Light Display Manager
 lilo inactive Lilo bootloader
 lstopo inactive lstopo / machine topology/numa node information
 lustre inactive Lustre filesystem
 manageiq inactive ManageIQ/CloudForms related information
 memcached inactive memcached distributed memory caching system
 mongodb inactive MongoDB document database
 monit inactive Monit monitoring daemon
 mssql inactive Microsoft SQL Server on Linux
 mysql inactive MySQL and MariaDB RDBMS
 named inactive BIND named server
 navicli inactive EMC Navicli
 nfs inactive Network file system information
 nfsganesha inactive NFS-Ganesha file server information
 nfsserver inactive NFS server information
 nodejs inactive Get runtime version of NodeJS
 npm inactive Get info about available npm modules
 nscd inactive Name service caching daemon
 ntp inactive Network time protocol
 numa inactive NUMA state and configuration
 nvme inactive Collect config and system information about NVMe devices
 oddjob inactive OddJob task scheduler
 omnipath_client inactive OmniPath Tools and Fast Fabric Client
 omnipath_manager inactive OmniPath Fabric Manager
 omsa inactive Dell OpenManage Server Administrator (OMSA)
 opencl inactive OpenCL
 opendaylight inactive OpenDaylight network manager
 opengl inactive OpenGL
 openstack_ansible inactive OpenStack-Ansible sos plugin.
 openstack_aodh inactive OpenStack Alarm service
 openstack_ceilometer inactive Openstack Ceilometer
 openstack_cinder inactive OpenStack cinder
 openstack_glance inactive OpenStack Glance
 openstack_heat inactive OpenStack Heat
 openstack_horizon inactive OpenStack Horizon
 openstack_instack inactive OpenStack Instack
 openstack_ironic inactive OpenStack Ironic
 openstack_keystone inactive OpenStack Keystone
 openstack_manila inactive OpenStackManila related information for Red Hat distributions.
 openstack_neutron inactive OpenStack Networking
 openstack_nova inactive OpenStack Nova
 openstack_octavia inactive Openstack Octavia
 openstack_sahara inactive OpenStack sahara related information for Red Hat distributions.
 openstack_swift inactive OpenStack Swift
 openstack_trove inactive OpenStack Trove
 openswan inactive Openswan IPsec
 openvswitch inactive OpenVSwitch networking
 origin inactive OpenShift Enterprise / OpenShift Container Platform
 os_net_config inactive OpenStack Net Config
 ovirt inactive oVirt Engine
 ovirt_hosted_engine inactive oVirt Hosted Engine
 ovirt_imageio inactive oVirt Image I/O Daemon / Proxy
 ovirt_node inactive oVirt Node specific information
 ovirt_provider_ovn inactive oVirt OVN Provider
 ovn_central inactive OVN Northd
 ovn_host inactive OVN Controller
 pacemaker inactive Pacemaker high-availability cluster resource manager
 pcp inactive Performance Co-Pilot data
 podman inactive Podman containers
 postgresql inactive PostgreSQL RDBMS
 powerpath inactive EMC PowerPath
 powerpc inactive IBM Power systems
 psacct inactive Process accounting information
 ptp inactive Precision time protocol
 puppet inactive Puppet service
 pxe inactive PXE service
 qpid inactive Qpid messaging
 qpid_dispatch inactive Qpid dispatch router
 quagga inactive Quagga routing service
 rabbitmq inactive RabbitMQ messaging service
 radius inactive RADIUS service information
 rear inactive Relax and Recover
 redis inactive Redis, in-memory data structure store
 rhcos inactive Red Hat CoreOS
 rhui inactive Red Hat Update Infrastructure
 RhvLogCollectorAnalyzer inactive RHV Log Collector Analyzer
 rpmostree inactive rpm-ostree image/package system
 runc inactive runC container runtime
 s390 inactive IBM S/390
 salt inactive Salt
 saltmaster inactive Salt Master
 samba inactive Samba Windows interoperability
 sanlock inactive SANlock daemon
 saphana inactive SAP HANA
 sapnw inactive SAP NetWeaver
 sar inactive System Activity Reporter
 sas3ircu inactive SAS-3 Integrated RAID adapter information
 satellite inactive RHN Satellite and Spacewalk
 sendmail inactive sendmail service
 skydive inactive Skydive, a network topology and protocols analyzer
 smartcard inactive PKCS#11 smart cards
 snappy inactive Snap packages
 snmp inactive Simple network management protocol
 squid inactive Squid caching proxy
 ssmtp inactive sSMTP information
 sssd inactive System security service daemon
 storageconsole inactive Red Hat Storage Console
 subscription_manager inactive subscription-manager information
 sunrpc inactive Sun RPC service
 symcli inactive EMC Symcli
 systemtap inactive SystemTap dynamic instrumentation
 targetcli inactive TargetCLI TCM/LIO configuration
 tftpserver inactive TFTP server
 tomcat inactive Apache Tomcat server
 upstart inactive Upstart init system
 vdo inactive Virtual Data Optimizer
 veritas inactive Veritas software
 virsh inactive client for libvirt virtualization API
 virtwho inactive Virt-Who agent
 vmware inactive VMWare client information
 vsftpd inactive Vsftpd server
 vulkan inactive Vulkan
 watchdog inactive Watchdog information.
 wireless inactive Wireless
 xinetd inactive xinetd information
 zfs inactive ZFS filesystem

以下插件选项可用:

boot.all-images off collect lsinitrd for all images
 filesys.lsof off gathers information on all open files
 filesys.dumpe2fs off dump filesystem information
 filesys.frag off filesystem fragmentation status
 jars.append_locations colon-separated list of additional JAR paths
 jars.all_known_locations off scan all known paths
 kernel.with-timer off gather /proc/timer* statistics
 libraries.ldconfigv off collect verbose ldconfig output
 logs.log_days 3 the number of days logs to collect
 lvm2.lvmdump off collect an lvmdump tarball
 lvm2.lvmdump-am off attempt to collect an lvmdump with advanced options and raw metadata collection
 networking.traceroute off collect a traceroute to www.example.com
 openshift.broker off Gathers broker specific files
 openshift.node off Gathers node specific files
 process.lsof on gathers information on all open files
 process.lsof-threads off gathers threads' open file info if supported
 rpm.rpmq on queries for package information via rpm -q
 rpm.rpmva off runs a verify on all packages
 rpm.rpmdb off collect /var/lib/rpm
 selinux.fixfiles off Print incorrect file context labels
 services.servicestatus off get a status of all running services
 yum.yumlist off list repositories and packages
 yum.yumdebug off gather yum debugging data
 yum.yum-history-info off gather yum history info

Profiles: boot, container, debug, desktop, hardware, identity, java, 
 kernel, mail, memory, mrg, network, openshift, 
 packagemanager, performance, perl, sap, security, services, 
 storage, sysmgmt, system, virt, webserver

24 profiles, 77 plugins

 

实例二

禁用内存和samba插件,关闭rpm -Va集合,命令如下:

sosreport -n memory,samba -k rpm.rpmva = off

如上,则不会收集这些了

实例三

指定结果报告压缩格式,如下:

sosreport -z gzip

则生成的结果如:/var/tmp/sosreport-xubo-2019-04-15-cjowpmi.tar.gz

实例四

启用插件扫描

sosreport -e tftpserver

或者

sosreport --enable-plugins tftpserver

这样就对tftpserver也进行扫描了

实例五

对结果文件进行加密

sosreport --encrypt-pass 123456

这样就生成文件如:/var/tmp/secured-sosreport-xubo-2019-04-15-aboimzc.tar.xz.gpg

实例六

配置文件

sosreport的配置文件是/etc/sos.conf ,默认内容如下:

[plugins]
#disable = rpm, selinux, dovecot
[tunables]
#rpm.rpmva = off
#general.syslogsize = 15

官方文档中多了个如下:

[general]
#verbose = 3
#verify = yes
#batch = yes
#log-size = 15

[plugins]
#disable = rpm, selinux, dovecot

[tunables]
#rpm.rpmva = off

这个就不多说了,可以将参数中的内容直接配进去

  • 安卓客户端下载
  • 微信扫一扫
  • weinxin
  • 微信公众号
  • 微信公众号扫一扫
  • weinxin
avatar