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, version2.3.0, inner collection schemaitcheck.linux.check/1, written in Bash. Download it from Linux check script download (the response includes anX-Content-SHA256header); 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 withsha256sumoritcheckai-center inspect --show-scriptagainst SHA-2568fb14f714601a6294a3ed35bfd3a857ef8e576a5e9d7582b07e689db1f2fedb6. - Read-only and umask-protected: runs with
umask 077, executes query commands and reads/proc,/sysand selected config files without modifying configuration, restarting services or installing packages. The only writes are a temporary working directory and the final.tar.gzunder 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.jsonasok,empty,permission_denied(non-root privilege denial),command_missing(exit 127),timeout(exit 124/137),failed,not_applicableorskipped. - Credential restriction and stream redaction:
top10cpu,top10mem,ps-countand/proc/[0-9]*/statzombie scanning record only shortcommnames and never collect raw command arguments;crontab.logretains only schedules, executable basenames and entry counts;sshd-effective.logemits only whitelisted policy keys and user/group counts (never private keys, HostKeys or banners);uid0-sudo.logreads only/etc/passwdandsudo/wheelgroup membership and never touches/etc/shadow;ssh-auth-failures.logemits 24h aggregate counters only;kdump.loglists/var/crashmetadata only without readingvmcorecontents; kernel command line,fstab,mount,iscsiadm,firewalland all error logs pass through a POSIXawkredactor that masks PEM private keys, embedded URL passwords,Authorization/Cookie/X-API-Keyheaders, 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.gzcan be uploaded directly to generate an online diagnostic report or transported verbatim as arole="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:
| Category | Content | Stable 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 / FRU | dmidecode.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 SMART | 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 (/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 counters | ip-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 files | packages.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 details | vmstat.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
rootor viasudo bash(recorded asprivilege_mode="root"or"sudo"). A non-root user can still run the script;collection.is_rootbecomesfalse,privilege_modebecomesnon_root,warning.txtis created, and privileged items that fail due to permissions are markedpermission_deniedrather than mixed withcommand_missing. - Optional tools:
smartctl,nvme,ipmitool,sensors,lsscsi,numactl,chronyc/ntpstat,tuned-adm,iostat/mpstat/sar(sysstat),multipath,iscsiadm,edac-utilandmdadmare optional. Missing tools or absent hardware are explicitly recorded ascommand_missingornot_applicable; the script never installs packages. - Disk space: writes to
/tmpby default. If/tmpis small or mountednoexec, pass--out-dir /var/tmpand confirm a few tens of MB of free space. - Per-command timeout protection: even if a hung NFS or network storage mount blocks
df,mountorsar, the stuck command is terminated after the configured timeout and recorded astimeout(exit code124) 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 Flag | Environment Variable | Default | Description |
|---|---|---|---|
--out-dir DIR | ITCHECK_OUT_DIR | /tmp | Working and output directory for the final .tar.gz |
--cmd-timeout SEC | ITCHECK_CMD_TIMEOUT | 30 | Per-command timeout in seconds for standard collection items |
--perf-timeout SEC | ITCHECK_PERF_TIMEOUT | 60 | Per-command timeout in seconds for live performance sampling (vmstat / iostat / mpstat) |
--max-item-bytes N | ITCHECK_MAX_ITEM_BYTES | 1048576 | Per-item payload byte cap (default 1 MiB; sets truncated: true if exceeded) |
--skip-perf | ITCHECK_SKIP_PERF=1 | off | Skip 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
- 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- Copy the script to
/tmpon 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/- Log in and run the real-machine capture (use
rootorsudo bash; optionally run a quick--skip-perfcheck 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- Fetch the archive back to your workstation and inspect
check.jsonlocally (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- 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- 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.gzdirectly; when packaged by ITCheckAI Center, the outer zip usesitcheck.package/1(rootpackage.json+ per-devicemanifest.jsonwithitcheck.manifest/1andlog.type="itcheck.linux.pm") carrying the exact same.tar.gzbytes asrole="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:
- Collection completeness and virtualization context: inspect
collection.status,privilege_modeandcountsincheck.jsonalongsidesystem/virt.logto confirm bare-metal, VM or container context (containers automatically suppress host kernel taint and host-managed NTP false alerts). - Services, crash dumps and security baseline: failed units in
software/failed-units.log; hardware/kernel faults inlogs/dmesg-err.log,logs/dmesg-hw.logand historical dumps inlogs/kdump.log; SSH policy insystem/sshd-effective.log(permitrootlogin/permitemptypasswords), non-root UID 0 accounts insystem/uid0-sudo.logand 24h SSH auth failure totals inlogs/ssh-auth-failures.log. - Hardware, disks and FC links: ECC, power, fan and thermal events in
hardware/ipmi-sel.log,sensors.logandlogs/mcelog.log; SMART and NVMe health instorage/smart.*.logandstorage/nvme-smart.log; FC HBA link state and CRC counters instorage/fc-host.log; RAID status instorage/raid-*.logandstorage/mdstat.log. - Capacity, network and cross-layer tuning: filesystem usage in
storage/df.log/inode.logand block schedulers instorage/io-scheduler.log;SYN-RECV/CLOSE-WAITcounts innetwork/tcp-states.log,bonding.logandethtool.*.logerrors;hardware/numa.log,system/thp-hugepages.logandsystem/tuned.logfor database and workload tuning. - Pressure stalls and zombie processes: sustained
avg60/avg300stalls inperformance/psi.log, plusvmstat.log,iostat.logandmpstat.log; TTY-independent zombie counts inperformance/zombies.log; file descriptor usage insystem/file-nr.log; clock sync insystem/ntp-sync.logandtimedatectl.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"
doneWith 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: absentPrecautions
- Security and compliance: although v2.x restricts process arguments,
crontabbodies, 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 markedredacted: trueincheck.jsonbefore sharing outside controlled environments. - Files read: the script never reads
/etc/shadow, SSH private keys or/var/crash/*/vmcoredump 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) orsupportconfig.
Note: repeated runs accumulate archives in the output directory (default
/tmp). Delete the script and archives from the target host once retrieved and verified.