diff --git a/collection-scripts/gather_ceph_logs b/collection-scripts/gather_ceph_logs index d84f27c..320112a 100755 --- a/collection-scripts/gather_ceph_logs +++ b/collection-scripts/gather_ceph_logs @@ -34,8 +34,8 @@ for ns in $namespaces; do oc debug nodes/"${node}" < journal_"${node}".gz - journalctl -k -o short-iso-precise --utc --no-hostname | gzip > kernel_"${node}".gz + journalctl --since "${JCTL_FILTER_ARGS}" | gzip > journal_"${node}".gz + journalctl --since "${JCTL_FILTER_ARGS}" -k -o short-iso-precise --utc --no-hostname | gzip > kernel_"${node}".gz exit CMDS done @@ -75,4 +75,4 @@ CMDS done dbglog "ceph core dump collection completed" -done \ No newline at end of file +done diff --git a/collection-scripts/utils.sh b/collection-scripts/utils.sh index 227e6bb..e9892a6 100755 --- a/collection-scripts/utils.sh +++ b/collection-scripts/utils.sh @@ -56,6 +56,27 @@ parse_since_time() { if [ -n "${FILTER_ARGS}" ]; then export LOG_FILTER_ARGS="${FILTER_ARGS}" fi + + # Journalctl doesn't support the same type of since and + # since-time args. Adapt the logic for journalctl + local JRNL_FILTER="" + + if [ -n "${MUST_GATHER_SINCE:-}" ]; then + JRNL_FILTER="${MUST_GATHER_SINCE} ago" + fi + + # This section adapts an ISO time like: 2024-04-04T09:23:26Z + # To 2024-04-04 09:23:26, a format that journalctl is happy with + if [ -n "${MUST_GATHER_SINCE_TIME:-}" ]; then + JRNL_FILTER=$(echo "${MUST_GATHER_SINCE_TIME}" | sed 's/T/ /; s/Z//') + fi + + # If the var is unset, export the default as 2 days ago + if [ -n "${JRNL_FILTER}" ]; then + export JCTL_FILTER_ARGS="${JRNL_FILTER}" + else + export JCTL_FILTER_ARGS="2 days ago" + fi } # Export the functions so that the file needs to be sourced only once