Add aarch64 support
[ta/remote-installer.git] / src / scripts / get_journals.sh
1 #!/bin/bash
2
3 # Copyright 2019 Nokia
4
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 hosts_names_file="$1"
18 for host in $(cat ${hosts_names_file}); do
19     if [ "${host}" != "$(hostname)" ]; then
20         address=${host}
21         if [ -e /etc/infra_internal_addresses ]; then
22             internal_ip=$(grep ${host} /etc/infra_internal_addresses | cut -d ' ' -f 2)
23             if [ -n "$internal_ip" ]; then
24                 address=${internal_ip}
25             fi
26         fi
27         ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ServerAliveInterval=60 ${address} "sudo journalctl" > /tmp/journal_${host}.log
28         ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ServerAliveInterval=60 ${address} "sudo journalctl -o json" > /tmp/journal_${host}_json.log
29     else
30         sudo journalctl > /tmp/journal_${host}.log
31         sudo journalctl -o json > /tmp/journal_${host}_json.log
32     fi
33 done
34
35 cd /tmp
36 tar czf node_journals.tgz journal_*.log
37 rm -f journal_*.log
38 cd -