Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

collector: improve the log time format #117

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions hack/collector-harvester
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash -ux

source /tmp/common
HOST_PATH=$1
BUNDLE_DIR=$2

Expand Down Expand Up @@ -99,18 +100,18 @@ mv $HOST_PATH/var/log/scc_supportconfig_$SUPPORT_BUNDLE_NODE_NAME.txz ./scc
mkdir -p logs
cd logs

chroot $HOST_PATH /usr/bin/journalctl -k > kernel.log
chroot $HOST_PATH $JOURNALCTL -k > kernel.log
# also collect logs of previous two boots
for ((i=1; i<=2; i++)); do
log_name="kernel.log.$i"
chroot $HOST_PATH /usr/bin/journalctl -k -b $((-i)) > $log_name
chroot $HOST_PATH $JOURNALCTL -k -b $((-i)) > $log_name
[ ! -s $log_name ] && rm -f $log_name
done

units=(rke2-server rke2-agent rancherd rancher-system-agent wicked iscsid)

for unit in ${units[@]}; do
chroot $HOST_PATH /usr/bin/journalctl -b all -u $unit | tail -c 10m > $unit.log
chroot $HOST_PATH $JOURNALCTL -b all -u $unit | tail -c 10m > $unit.log
done

cp ${HOST_PATH}/var/lib/rancher/rke2/agent/logs/kubelet.log .
Expand Down
7 changes: 4 additions & 3 deletions hack/collector-longhorn
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash -ux

source /tmp/common
HOST_PATH=$1
BUNDLE_DIR=$2

Expand Down Expand Up @@ -33,11 +34,11 @@ function collect_syslog(){
function collect_kubelet_log(){
# On Linux nodes that use systemd, the kubelet and container runtime write to journald by default.
# ref. https://kubernetes.io/docs/concepts/cluster-administration/logging/#log-location-node
chroot ${HOST_PATH} /usr/bin/journalctl -r -u kubelet > kubelet.log
chroot ${HOST_PATH} $JOURNALCTL -r -u kubelet > kubelet.log

# For K3s cluster
chroot ${HOST_PATH} /usr/bin/journalctl -r -u k3s.service > k3s-service.log
chroot ${HOST_PATH} /usr/bin/journalctl -r -u k3s-agent.service > k3s-agent-service.log
chroot ${HOST_PATH} $JOURNALCTL -r -u k3s.service > k3s-service.log
chroot ${HOST_PATH} $JOURNALCTL -r -u k3s-agent.service > k3s-agent-service.log

if [ -f ${RKE2_KUBELET_LOG_PATH} ]; then
cp ${RKE2_KUBELET_LOG_PATH} .
Expand Down
2 changes: 2 additions & 0 deletions hack/common
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

JOURNALCTL="/usr/bin/journalctl -o short-precise"
2 changes: 2 additions & 0 deletions package/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ RUN chmod +x /usr/bin/support-bundle-kit
ADD hack/collector-* /usr/bin/
RUN chmod +x /usr/bin/collector-*

ADD hack/common /tmp/
Yu-Jack marked this conversation as resolved.
Show resolved Hide resolved

ENTRYPOINT ["entrypoint.sh"]