Collect diagnostic information from Linux VMs

Collect diagnostic archives from Compute Engine Linux virtual machine (VM) instances to help Cloud Customer Care investigate operating system (OS) issues. Use the sosreport tool on most Linux distributions, or use the supportconfig tool on SUSE Linux.

For Container-Optimized OS VMs, see Collecting debugging information using sosreport. For Windows Server VMs, see Collecting diagnostic information.

Before you begin

  • Make sure that you have sudo privileges on the Linux VM and can connect to it by using SSH. For more information, see Connect to Linux VMs.
  • If you haven't already, set up authentication. Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:

    Select the tab for how you plan to use the samples on this page:

    Console

    When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.

    gcloud

    1. Install the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:

      gcloud init

      If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

    2. Set a default region and zone.

Why Customer Care needs diagnostic information

When Customer Care troubleshoots complex VM issues, engineers often need to inspect the internal state of the guest OS. Common examples include performance bottlenecks, networking problems, OS registration failures, and errors during package installation or system updates.

To identify the root cause of these issues, support engineers analyze system logs and configuration files from the VM. A single log or configuration file rarely provides enough context to resolve the issue, so engineers need a comprehensive set of system files.

About the sosreport tool

The sosreport tool, also known as sos, is an open-source, extensible utility for collecting support data on Linux distributions and other Unix-like operating systems. You can view the source code and learn more in the sosreport GitHub repository.

Technical support teams use sosreport to automatically gather logs and system information for troubleshooting OS issues. Instead of requiring you to manually run dozens of commands and copy log files individually, sosreport creates a standardized, compressed archive containing this data.

The tool uses plugins to run system commands and collect relevant files to capture the state of the machine. Examples of collected information include the following:

  • Running processes: the state of active tasks on the system from commands such as ps, pstree, and lsof.
  • Resource usage: memory usage from the free command, disk space from commands such as df, and system load from uptime.
  • Configuration files for the OS and services: system and service configuration files, including the contents of directories such as /etc that store local service configurations.
  • Hardware and kernel details: hardware diagnostics, the running kernel version, and loaded kernel modules.
  • Installed software: a list of installed packages from the package manager, such as the output of dpkg -l or rpm -qa.

Install the sosreport tool

The package name and installation command depend on the Linux distribution on your VM. After you connect to your VM, select one of the following options:

AlmaLinux, Rocky Linux, Oracle Linux

  1. Check whether the sos package is installed:

    dnf list installed sos
  2. If the package isn't installed, install sos:

    sudo dnf install -y sos

Red Hat Enterprise Linux (RHEL)

  1. Check whether the sos package is installed:

    dnf list installed "*sos*"
  2. If the package isn't installed, install sos and its required packages:

    sudo dnf install -y sos python3-packaging python3-setuptools
    

Ubuntu 26.04+, Debian 13+

On Ubuntu 26.04 LTS and later, or Debian 13 and later, complete the following steps:

  1. Check whether the sos package is installed:

    apt list --installed sos
  2. If the package isn't installed, install sos:

    sudo apt install sos

Ubuntu 18.04-24.04, Debian 12

On Ubuntu 18.04 LTS to 24.04 LTS, or Debian 12, complete the following steps:

  1. Check whether the sosreport package is installed:

    apt list --installed sosreport
    
  2. If the package isn't installed, install sosreport:

    sudo apt install sosreport

For Container-Optimized OS, see Collecting debugging information using sosreport. For SUSE Linux, skip this section and see Collect diagnostic information on SUSE Linux.

Generate a sosreport archive

Complete the following steps on AlmaLinux, Debian, Oracle Linux, RHEL, Rocky Linux, and Ubuntu VMs. For Container-Optimized OS, see Collecting the sosreport data.

  1. Optional: Estimate the disk space required for the archive:

    sudo sos report --batch --alloptions --all-logs --estimate-only
    

    The --estimate-only flag was introduced in sos 4.3 on GitHub and isn't available in earlier versions, such as the version on Debian 12.

    Verify that the target partition has enough free disk space. By default, sosreport saves the archive in /var/tmp/ on most distributions, except on Debian and Ubuntu 24.04 LTS and earlier, where it uses /tmp/. If free space is limited, use the --tmp-dir flag to write the archive to a partition with more free space.

  2. Generate the diagnostic archive:

    sudo sos report --batch --alloptions --all-logs
    

    When the command finishes, sosreport prints the path to the generated compressed archive, which has a filename similar to sosreport-hostname-YYYY-MM-DD-abcdef.tar.xz.

  3. To avoid permission errors when you retrieve the archive, make your user the owner of the archive:

    sudo chown "$(whoami)" SOSREPORT_FILE_PATH
    

    Replace SOSREPORT_FILE_PATH with the full path to the generated sosreport archive.

Common sosreport flags

The following table describes commonly used sos report flags:

Flag Description
--alloptions Enables all options for loaded plugins.
--all-logs Collects all available logs regardless of size.
--batch Runs in batch mode without interactive prompts.
--clean Obfuscates sensitive information in the archive.
--estimate-only Estimates required disk space for a full sos run.
--tmp-dir Specifies an alternate temporary directory.

To view all available flags, check the command help:

sos report --help

Collect diagnostic information on SUSE Linux

On SUSE Linux VMs, use the supportconfig tool from the supportutils package to collect diagnostic information. After you connect to your SUSE Linux VM, complete the following steps:

  1. Check whether supportconfig is installed:

    sudo supportconfig -h
    

    The supportconfig tool is usually preinstalled on SUSE Linux VMs. If it isn't installed, install the supportutils package:

    sudo zypper install -y supportutils
    
  2. Generate a system overview report:

    sudo supportconfig -l
    

    The -l flag gathers additional rotated logs.

    The supportconfig tool collects system information, creates a compressed archive, and prints the path to the generated file. By default, supportconfig saves the archive in /var/log/ with a filename in the format scc_HOSTNAME_DATE_TIME.txz, where HOSTNAME is the VM hostname, DATE is the collection date, and TIME is the collection time.

  3. To avoid permission errors when you retrieve the archive, make your user the owner of the archive:

    sudo chown "$(whoami)" SUPPORTCONFIG_FILE_PATH
    

    Replace SUPPORTCONFIG_FILE_PATH with the full path to the generated supportconfig archive.

Retrieve the diagnostic archive from the VM

After you generate the diagnostic archive on the VM, download it to your local machine. Select one of the following options:

Console

  1. In the Google Cloud console, go to the VM instances page:

    Go to VM instances

  2. In the list of VMs, click SSH in the row of the VM that contains the diagnostic archive.

  3. On the SSH-in-browser toolbar, click DOWNLOAD FILE.

  4. For Path, in the Absolute file path field, enter the full path to the diagnostic archive on the VM.

  5. Click Download.

    The archive downloads to the default download folder on your workstation. For more information, see Transfer files using SSH-in-browser.

gcloud

If you have the Google Cloud CLI installed locally, copy the archive to your local machine by using the gcloud compute scp command:

gcloud compute scp USERNAME@INSTANCE_NAME:REMOTE_FILE_PATH \
    LOCAL_DESTINATION_PATH \
    --zone=ZONE \
    --project=PROJECT_ID \
    --compress

Replace the following:

  • USERNAME: the username on the VM that owns the diagnostic archive.
  • INSTANCE_NAME: the name of the VM.
  • REMOTE_FILE_PATH: the full path to the diagnostic archive on the VM.
  • LOCAL_DESTINATION_PATH: the destination directory on your local machine.
  • ZONE: the zone of the VM.
  • PROJECT_ID: the ID of the Google Cloud project.

Optional: After you retrieve the diagnostic archive, review it for confidential or personally identifiable information (PII) and mask or remove any sensitive data before uploading it.

When the archive is ready, attach it to your Customer Care support case. For more information about uploading attachments to an open case, see Update a support case.

What's next