summaryrefslogtreecommitdiff
path: root/contrib/cirrus/logcollector.sh
blob: e0190971e59fd5d532dad77c25fd8e59cd6b887c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash

set -e

source $(dirname $0)/lib.sh

req_env_var CIRRUS_WORKING_DIR OS_RELEASE_ID TEST_REMOTE_CLIENT

# Assume there are other log collection commands to follow - Don't
# let one break another that may be useful, but also keep any
# actual script-problems fatal so they are noticed right away.
showrun() {
    echo '+ '$(printf " %q" "$@")
    set +e
    echo '------------------------------------------------------------'
    "$@"
    local status=$?
    [[ $status -eq 0 ]] || \
        echo "[ rc = $status -- proceeding anyway ]"
    echo '------------------------------------------------------------'
    set -e
}

case $1 in
    audit)
        case $OS_RELEASE_ID in
            ubuntu) showrun cat /var/log/kern.log ;;
            fedora) showrun cat /var/log/audit/audit.log ;;
            *) bad_os_id_ver ;;
        esac
        ;;
    df) showrun df -lhTx tmpfs ;;
    ginkgo) showrun cat $CIRRUS_WORKING_DIR/test/e2e/ginkgo-node-*.log ;;
    journal) showrun journalctl -b ;;
    podman) showrun ./bin/podman system info ;;
    varlink)
       if [[ "$TEST_REMOTE_CLIENT" == "true" ]]
       then
          echo "(Trailing 100 lines of $VARLINK_LOG)"
          showrun tail -100 $VARLINK_LOG
       else
          die 0 "\$TEST_REMOTE_CLIENT is not 'true': $TEST_REMOTE_CLIENT"
       fi
       ;;
    packages)
        # These names are common to Fedora and Ubuntu
        PKG_NAMES=(\
                    conmon \
                    containernetworking-plugins \
                    containers-common \
                    criu \
                    golang \
                    podman \
                    skopeo \
                    slirp4netns \
        )
        case $OS_RELEASE_ID in
            fedora*)
                cat /etc/fedora-release
                PKG_LST_CMD='rpm -q --qf=%{N}-%{V}-%{R}-%{ARCH}\n'
                PKG_NAMES+=(\
                    container-selinux \
                    crun \
                    runc \
                )
                ;;
            ubuntu*)
                cat /etc/issue
                PKG_LST_CMD='dpkg-query --show --showformat=${Package}-${Version}-${Architecture}\n'
                PKG_NAMES+=(\
                    cri-o-runc \
                )
                ;;
            *) bad_os_id_ver ;;
        esac
        echo "Kernel: " $(uname -r)
        echo "Cgroups: " $(stat -f -c %T /sys/fs/cgroup)
        # Any not-present packages will be listed as such
        $PKG_LST_CMD ${PKG_NAMES[@]} | sort -u
        ;;
    *) die 1 "Warning, $(basename $0) doesn't know how to handle the parameter '$1'"
esac