How to Use the Linux Check Script (linux-check)

linux-check is the ITCheckAI read-only check script for Linux, covering RHEL / CentOS / Rocky / AlmaLinux / Ubuntu / Debian / SLES / openEuler / Anolis / Kylin / UOS and their derivatives. It collects system, hardware, storage, network, service, error-log and performance data and writes a single .tar.gz check archive containing a versioned check.json contract (itcheck.linux.check/1) to the output directory (default /tmp). A full run typically takes 1-3 minutes, of which live performance sampling accounts for about 45-50 seconds (pass --skip-perf to skip live sampling and finish in a few seconds).

Script Overview

  • File, version and checksum: linux-check-v2.3.0.sh, version 2.3.0, inner collection schema itcheck.linux.check/1, written in Bash. Download it from Linux check script download (the response includes an X-Content-SHA256 header); scripts for other platforms are listed on the OS check scripts tool page. It is byte-for-byte identical to the script embedded in ITCheckAI Center and can be verified with sha256sum or itcheckai-center inspect --show-script against SHA-256 8fb14f714601a6294a3ed35bfd3a857ef8e576a5e9d7582b07e689db1f2fedb6.
  • Read-only and umask-protected: runs with umask 077, executes query commands and reads /proc, /sys and selected config files without modifying configuration, restarting services or installing packages. The only writes are a temporary working directory and the final .tar.gz under the chosen output directory.
  • Raw values only; thresholds stay on the server: the collector records raw command outputs, original host timestamps with timezone offset, per-item exit codes, elapsed milliseconds, source provenance, byte sizes and SHA-256 hashes. It never embeds health verdicts or alert thresholds; collection.status (complete / partial / failed) describes collection completeness only.
  • Distinguishable per-item statuses and command timeouts: default per-command timeout is 30 seconds (60 seconds for performance sampling). A failing or hung command never aborts the run and is classified in check.json as ok, empty, permission_denied (non-root privilege denial), command_missing (exit 127), timeout (exit 124/137), failed, not_applicable or skipped.
  • Credential restriction and stream redaction: top10cpu, top10mem, ps-count and /proc/[0-9]*/stat zombie scanning record only short comm names and never collect raw command arguments; crontab.log retains only schedules, executable basenames and entry counts; sshd-effective.log emits only whitelisted policy keys and user/group counts (never private keys, HostKeys or banners); uid0-sudo.log reads only /etc/passwd and sudo/wheel group membership and never touches /etc/shadow; ssh-auth-failures.log emits 24h aggregate counters only; kdump.log lists /var/crash metadata only without reading vmcore contents; kernel command line, fstab, mount, iscsiadm, firewall and all error logs pass through a POSIX awk redactor that masks PEM private keys, embedded URL passwords, Authorization / Cookie / X-API-Key headers, Bearer / JWT / cloud and Git tokens, CLI password flags and sensitive key-value pairs to [REDACTED].
  • Standalone upload vs. Center transport envelope: the generated .tar.gz can be uploaded directly to generate an online diagnostic report or transported verbatim as a role="main" file inside an ITCheckAI Center offline upload package (itcheck.package/1 + itcheck.manifest/1). Previous v1.0.0 through v2.2.0 archives remain fully backward-compatible.

What It Collects

The script collects data into seven stable section subdirectories and records every item's unique id, stable relative path, source, started_at_raw / finished_at_raw, duration_ms, exit_code, status, redacted, truncated, size_bytes and sha256 in check.json:

CategoryContentStable paths and main commands / sources
System (system)Distribution and kernel, hostname, virtualization/container detection, uptime, reboot history, timedatectl plus chronyc/ntpstat/ntpq clock sync, sysctl parameters, kernel taint & file-nr FD usage, active Tuned profile, THP & HugePages, boot command line (redacted), SELinux & AppArmor, whitelist-only SSH policy, UID=0 & sudo/wheel audit, scheduled job metadata (restricted)os-release.log, uname.log, hostnamectl.log, virt.log (systemd-detect-virt + container markers), uptime.log, last-reboot.log, timedatectl.log, ntp-sync.log (chronyc -n tracking/sources; ntpstat; ntpq -pn), sysctl.log, kernel-taint.log (/proc/sys/kernel/tainted), file-nr.log (/proc/sys/fs/file-nr), tuned.log (tuned-adm active), thp-hugepages.log, kernel-cmdline.log, selinux.log, apparmor.log, sshd-effective.log (whitelist sshd -T as root, Include-aware config parse otherwise), uid0-sudo.log (/etc/passwd + sudo/wheel only), crontab.log
Hardware (hardware)Product model, serial number, BIOS version, CPU, memory modules, NUMA topology, PCI / USB / SCSI devices, sensors, IPMI SEL / SDR / FRUdmidecode.log, model.txt, serial.txt, bios.txt, lscpu.log, cpuinfo.log, meminfo.log, numa.log (numactl --hardware & /sys/devices/system/node), dmidecode-mem.log, lspci.log (lspci -vv), lsusb.log, lsscsi.log, sensors.log, ipmi-sel.log, ipmi-sensor.log, ipmi-fru.log
Storage (storage)Block devices & TRAN, filesystem capacity & inodes, mounts & fstab (redacted), partitions, LVM, software RAID, multipath, iSCSI sessions (CHAP redacted), block I/O schedulers & read-ahead, NVMe SMART (nvme-cli), FC HBA link state & error counters, hardware RAID detection & vendor CLIs (with smartctl -d megaraid fallback), per-local-disk SMARTlsblk.log, df.log, inode.log, mount.log, fstab.log, fdisk.log, pvs.log, vgs.log, lvs.log, mdstat.log, mdadm.log, multipath.log, iscsi.log, io-scheduler.log (/sys/block/*/queue/*), nvme-smart.log (nvme list; nvme smart-log), fc-host.log (/sys/class/fc_host/host*), raid-detect.log, raid-<tool>-*.log, raid-smartctl-megaraid.log, smart.<disk>.log (excluding FC/iSCSI SAN LUNs)
Network (network)IP addresses, IPv4 / IPv6 routes, interface counters, DNS, hosts, listening sockets, aggregated TCP socket state counts, bonding, firewall rules, per-NIC link and driver countersip-addr.log, ip-route.log, ip-link.log, resolv.log, hosts.log, listen.log (ss -lntup), tcp-states.log (ss -Htan state counts only, no peer IPs), bonding.log, firewall.log, ethtool.<nic>.log (including first 80 lines of ethtool -S)
Software and services (software)Installed packages, running services, failed units, enabled unit filespackages.log (latest 500 via rpm -qa --last and/or dpkg -l), services.log, failed-units.log, enabled.log (all with --no-pager)
Error logs (logs)Kernel errors, all-level hardware/link error filter, err-level journal for current and previous boot, system log tail, sysfs EDAC / MCE, OOM records, kdump service state & /var/crash metadata, 24h SSH auth failure aggregates (including OpenSSH 9.8+ sshd-session)dmesg-err.log (last 400 lines), dmesg-hw.log (last 200 lines), journal-err.log (last 600 entries), journal-prev-boot.log (last 300 entries), messages-tail.log (last 500 lines), mcelog.log (/sys/devices/system/edac/mc, /var/log/mcelog & edac-util -v), oom.log, kdump.log (entry names/timestamps/sizes only, never reads vmcore), ssh-auth-failures.log (counts only for sshd & sshd-session)
Performance snapshot (performance)Live CPU / memory / disk I/O samples, today's sar data, memory and swap, PSI pressure stalls, top 10 processes by CPU and memory (short comm only), total / D-state counts and TTY-independent /proc zombie detailsvmstat.log (vmstat 3 10), iostat.log (iostat -x 3 5), mpstat.log (mpstat -P ALL 3 3), sar-today.log (last 60 lines), free.log (free -m), psi.log (/proc/pressure/{cpu,memory,io}; not_applicable on older kernels), top10cpu.log, top10mem.log, ps-count.log, zombies.log (scans /proc/[0-9]*/stat excluding collector children), swap.log

SMART runs for each local device reported as type disk by lsblk -dn -o NAME,TYPE,TRAN excluding fc/iscsi SAN LUNs (if smartctl returns a bitmask exit code with low 3 bits equal to 0, such as exit_code=8, the item is recorded as status=ok with the raw exit code preserved). ethtool runs in lexical order for each interface under /sys/class/net/ except lo.

Before You Run It

  • Privileges: run as root or via sudo bash (recorded as privilege_mode="root" or "sudo"). A non-root user can still run the script; collection.is_root becomes false, privilege_mode becomes non_root, warning.txt is created, and privileged items that fail due to permissions are marked permission_denied rather than mixed with command_missing.
  • Optional tools: smartctl, nvme, ipmitool, sensors, lsscsi, numactl, chronyc / ntpstat, tuned-adm, iostat / mpstat / sar (sysstat), multipath, iscsiadm, edac-util and mdadm are optional. Missing tools or absent hardware are explicitly recorded as command_missing or not_applicable; the script never installs packages.
  • Disk space: writes to /tmp by default. If /tmp is small or mounted noexec, pass --out-dir /var/tmp and confirm a few tens of MB of free space.
  • Per-command timeout protection: even if a hung NFS or network storage mount blocks df, mount or sar, the stuck command is terminated after the configured timeout and recorded as timeout (exit code 124) so collection continues cleanly.

Parameters

The script runs with zero arguments out of the box (preserving compatibility with existing automation and ITCheckAI Center) and also accepts the following optional flags and environment variables:

CLI FlagEnvironment VariableDefaultDescription
--out-dir DIRITCHECK_OUT_DIR/tmpWorking and output directory for the final .tar.gz
--cmd-timeout SECITCHECK_CMD_TIMEOUT30Per-command timeout in seconds for standard collection items
--perf-timeout SECITCHECK_PERF_TIMEOUT60Per-command timeout in seconds for live performance sampling (vmstat / iostat / mpstat)
--max-item-bytes NITCHECK_MAX_ITEM_BYTES1048576Per-item payload byte cap (default 1 MiB; sets truncated: true if exceeded)
--skip-perfITCHECK_SKIP_PERF=1offSkip live vmstat / iostat / mpstat sampling (marks those items skipped) for fast smoke checks
--version / --help——Print script version and inner schema, or show usage and exit

Executable Real-Machine Sampling Steps

  1. Download the script to your workstation and verify its SHA-256 (matching the website tool page and itcheckai-center inspect --show-script):
curl -fSL -o linux-check-v2.3.0.sh https://<your-itcheckai-site>/tools/os-check/download/linux/
sha256sum linux-check-v2.3.0.sh
# Expected digest: 8fb14f714601a6294a3ed35bfd3a857ef8e576a5e9d7582b07e689db1f2fedb6
less linux-check-v2.3.0.sh   # review every command before running it
  1. Copy the script to /tmp on the authorized target Linux host (or transfer via bastion / removable media in air-gapped networks):
scp linux-check-v2.3.0.sh root@192.168.1.10:/tmp/
  1. Log in and run the real-machine capture (use root or sudo bash; optionally run a quick --skip-perf check first, then a full capture):
ssh root@192.168.1.10
bash /tmp/linux-check-v2.3.0.sh --version
# Full capture (1-3 minutes including ~45s live performance sampling):
bash /tmp/linux-check-v2.3.0.sh
# As a non-root user with sudo:
sudo bash /tmp/linux-check-v2.3.0.sh
# Alternate output directory or fast sampling:
sudo bash /tmp/linux-check-v2.3.0.sh --out-dir /var/tmp --skip-perf
# Final line example: Check data saved to /tmp/host01.SN123.check-20261120_140600.tar.gz
  1. Fetch the archive back to your workstation and inspect check.json locally (no extra tools required on the target server):
mkdir -p results
scp root@192.168.1.10:/tmp/host01.*.check-*.tar.gz ./results/

# Verify archive layout, schema version, per-status counts and redaction metadata locally
ARCHIVE=$(ls -t results/*.check-*.tar.gz | head -n 1)
tar -tzf "$ARCHIVE" | head -n 25
tar -xOzf "$ARCHIVE" --wildcards '*/check.json' | python3 -m json.tool | head -n 45
  1. Alternatively, collect over SSH and produce a verified offline upload package (package.json + manifest.json) using ITCheckAI Center:
# Confirm Center embeds the exact same script SHA-256
itcheckai-center inspect --show-script | head -n 6
# Upload, execute, download and automatically clean up temporary remote files
itcheckai-center inspect --host 192.168.1.10 --user ops --sudo --customer "DemoCustomer" --out ./collected
# Verify the packaged offline zip
itcheckai-center verify ./collected/ITCheckAI-*.zip
  1. Once the archive is verified on your workstation, remove the script and archive from the target host:
ssh root@192.168.1.10 'rm -f /tmp/linux-check-v2.3.0.sh /tmp/host01.*.check-*.tar.gz'

Output

The default archive path is /tmp/<hostname>.<serial>.check-<YYYYMMDD_HHMMSS>.tar.gz. The hostname comes from hostname; the serial number is read from dmidecode -s system-serial-number (serial_source="dmidecode"), falling back to /sys/class/dmi/id/product_serial (serial_source="sysfs") with spaces and slashes stripped. If still empty, host.serial is an empty string and the filename uses NotAvailable. The script deletes its temporary directory and exits 0 on success, or returns a non-zero exit code if archiving fails.

Archive layout (<disk> and <nic> expand to actual devices):

host01.SN123.check-20261120_140600/
├── check.json           # itcheck.linux.check/1 contract manifest (timestamps, statuses, durations, sources, SHA-256)
├── date.log             # raw host date output at collection start
├── warning.txt          # created only when not running as root
├── system/      os-release.log  uname.log  hostnamectl.log  virt.log  uptime.log  last-reboot.log
│                timedatectl.log  ntp-sync.log  sysctl.log  kernel-taint.log  file-nr.log
│                tuned.log  thp-hugepages.log  kernel-cmdline.log  selinux.log  apparmor.log
│                sshd-effective.log  uid0-sudo.log  crontab.log
├── hardware/    dmidecode.log  model.txt  serial.txt  bios.txt  lscpu.log  cpuinfo.log
│                meminfo.log  numa.log  dmidecode-mem.log  lspci.log  lsusb.log  lsscsi.log
│                sensors.log  ipmi-sel.log  ipmi-sensor.log  ipmi-fru.log
├── storage/     lsblk.log  df.log  inode.log  mount.log  fstab.log  fdisk.log  pvs.log  vgs.log
│                lvs.log  mdstat.log  mdadm.log  multipath.log  iscsi.log  io-scheduler.log
│                nvme-smart.log  fc-host.log  raid-detect.log  raid-<tool>-*.log  smart.<disk>.log
├── network/     ip-addr.log  ip-route.log  ip-link.log  resolv.log  hosts.log  listen.log
│                tcp-states.log  bonding.log  firewall.log  ethtool.<nic>.log
├── software/    packages.log  services.log  failed-units.log  enabled.log
├── logs/        dmesg-err.log  dmesg-hw.log  journal-err.log  journal-prev-boot.log
│                messages-tail.log  mcelog.log  oom.log  kdump.log  ssh-auth-failures.log
└── performance/ vmstat.log  iostat.log  mpstat.log  sar-today.log  free.log  psi.log
                 top10cpu.log  top10mem.log  ps-count.log  zombies.log  swap.log
  • Standalone vs. Center envelope: standalone uploads submit the .tar.gz directly; when packaged by ITCheckAI Center, the outer zip uses itcheck.package/1 (root package.json + per-device manifest.json with itcheck.manifest/1 and log.type="itcheck.linux.pm") carrying the exact same .tar.gz bytes as role="main".
  • Per-file format: each section file begins with ### <logical command>, followed by raw (or redacted) output and, for non-ok statuses, an explicit status footer such as [command missing: ...], [permission denied: ...], [command timed out after Ns], [not applicable: ...], [skipped: ...] or [command failed with exit code N].

Reviewing the Results

Upload the archive to the website to generate an automated diagnostic report and AI recommendations, or inspect the archive manually in the following order:

  1. Collection completeness and virtualization context: inspect collection.status, privilege_mode and counts in check.json alongside system/virt.log to confirm bare-metal, VM or container context (containers automatically suppress host kernel taint and host-managed NTP false alerts).
  2. Services, crash dumps and security baseline: failed units in software/failed-units.log; hardware/kernel faults in logs/dmesg-err.log, logs/dmesg-hw.log and historical dumps in logs/kdump.log; SSH policy in system/sshd-effective.log (permitrootlogin / permitemptypasswords), non-root UID 0 accounts in system/uid0-sudo.log and 24h SSH auth failure totals in logs/ssh-auth-failures.log.
  3. Hardware, disks and FC links: ECC, power, fan and thermal events in hardware/ipmi-sel.log, sensors.log and logs/mcelog.log; SMART and NVMe health in storage/smart.*.log and storage/nvme-smart.log; FC HBA link state and CRC counters in storage/fc-host.log; RAID status in storage/raid-*.log and storage/mdstat.log.
  4. Capacity, network and cross-layer tuning: filesystem usage in storage/df.log / inode.log and block schedulers in storage/io-scheduler.log; SYN-RECV / CLOSE-WAIT counts in network/tcp-states.log, bonding.log and ethtool.*.log errors; hardware/numa.log, system/thp-hugepages.log and system/tuned.log for database and workload tuning.
  5. Pressure stalls and zombie processes: sustained avg60 / avg300 stalls in performance/psi.log, plus vmstat.log, iostat.log and mpstat.log; TTY-independent zombie counts in performance/zombies.log; file descriptor usage in system/file-nr.log; clock sync in system/ntp-sync.log and timedatectl.log.

Batch Check

For a small fleet, use an SSH loop with hosts.txt (one IP or hostname per line):

mkdir -p results
for h in $(cat hosts.txt); do
  scp linux-check-v2.3.0.sh root@$h:/tmp/ && \
  ssh root@$h "bash /tmp/linux-check-v2.3.0.sh" && \
  scp root@$h:/tmp/*.check-*.tar.gz results/ && \
  ssh root@$h "rm -f /tmp/linux-check-v2.3.0.sh /tmp/*.check-*.tar.gz"
done

With Ansible, use the script module and fetch the exact path printed on the last line:

# ad-hoc command
ansible all -i hosts.txt -m script -a "linux-check-v2.3.0.sh" --become

# playbook: run, fetch, then remove the remote archive
- hosts: all
  become: true
  tasks:
    - name: run linux-check
      ansible.builtin.script: linux-check-v2.3.0.sh
      register: chk
    - name: fetch archive
      ansible.builtin.fetch:
        src: "{{ chk.stdout_lines[-1] | regex_replace('^Check data saved to ', '') }}"
        dest: results/
        flat: true
    - name: remove remote archive
      ansible.builtin.file:
        path: "{{ chk.stdout_lines[-1] | regex_replace('^Check data saved to ', '') }}"
        state: absent

Precautions

  • Security and compliance: although v2.x restricts process arguments, crontab bodies, SSH whitelist keys and aggregated auth counters while masking common credential patterns in logs and configs, the archive still contains hostnames, IP addresses, hardware serial numbers, topology and system logs. Spot-check items marked redacted: true in check.json before sharing outside controlled environments.
  • Files read: the script never reads /etc/shadow, SSH private keys or /var/crash/*/vmcore dump contents. It reads /etc/os-release, /etc/passwd (UID 0 usernames only), /etc/hosts, /etc/resolv.conf, /etc/ssh/sshd_config (whitelisted policy keys and counts only), /etc/fstab (redacted), /proc/cmdline (redacted), /proc/1/environ (container= marker only) and system error logs (redacted).
  • Difference from vendor support bundles: this script targets routine preventive maintenance with bounded log tails and a 1 MiB per-item cap. When opening a vendor support case with Red Hat, SUSE or Canonical, continue using official tools such as sosreport (sos report) or supportconfig.

Note: repeated runs accumulate archives in the output directory (default /tmp). Delete the script and archives from the target host once retrieved and verified.

57 views Updated 2026-11-22

More in this groupOS Check Scripts

View all 6 in this group

Can't find an answer?

Upload a log for AI diagnosis, or ask the AI assistant directly in the console.