Show the Ceph PGs whose last deep scrub is longest ago, and print the primary OSD (plus acting set).
Useful for spotting partitions that have not been deep-scrubbed for a while.
- Parses both legacy
"YYYY-MM-DD HH:MM:SS[.us]"and ISO-8601 timestamps withZ,+HH:MM, or+HHMM - Works with
ceph pg ls -f jsonandceph pg dump_jsonacross Ceph versions - Deterministic sorting by oldest deep scrub first
- Option
-n <NUM>to show the last N PGs (default: 5) --debugto show parsed epoch timestamps for verification
- Perl 5.26+
- Ceph CLI on PATH with permissions to query PGs
- Perl modules:
Cpanel::JSON::XSDateTime::Format::ISO8601Try::TinyGetopt::Long(core)
apt update
apt install -y libcpanel-json-xs-perl libdatetime-format-iso8601-perl libtry-tiny-perlOr via cpanm:
cpanm Cpanel::JSON::XS DateTime::Format::ISO8601 Try::Tiny# default: show 5 oldest PGs
./osd-scrub-least.pl
# show 10 oldest
./osd-scrub-least.pl -n 10
# debug epoch parsing
./osd-scrub-least.pl --debugExample output:
Top 5 PGs by oldest deep scrub:
PGID Primary Acting Last Deep Scrub
----------------------------------------------------------------------
1.2f osd.7 7,19,3 2025-07-14T03:12:45.123456Z
2.a3 osd.11 11,8,5 2025-07-15T08:02:17.457221+0000
- The script collects JSON from
ceph pg ls -f json(preferred) orceph pg dump_json(fallback). - It extracts the PG array in a version-agnostic way (
.pg_stats,.pg_map.pg_stats,.entries, or top-level array). - Field
last_deep_scrub_stampis normalized:- Space is turned into
T - Timezone
+HHMMis normalized to+HH:MM - Missing timezone defaults to
Z(UTC)
- Space is turned into
- Timestamps are parsed to epoch seconds. Missing/unknown becomes
0and sorts first. - Rows are sorted by
tsascending, with tie-breakers on the original stamp andpgid.
0on success- Non-zero when Ceph JSON cannot be read/parsed or no PGs are found
- If all timestamps are shown in ascending PGID order, enable
--debugand check epochs.
Usually this indicates a timestamp format that was not normalized. The script already handles+HHMM→+HH:MM, ISOZ, and space vsT. - For machine-readable output (JSON/TSV), open an issue or extend the printing section.
The data is already in structured form in@rows.