343a6389d6f6e5be16e93c73a8f0c32a890c9c14
[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=$(python print_hosts.py)
18 for host in $hosts; do
19     if [ "${host}" != "$(hostname)" ]; then
20         ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ServerAliveInterval=60 ${host} "sudo journalctl" > /tmp/journal_${host}.log
21         ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ServerAliveInterval=60 ${host} "sudo journalctl -o json" > /tmp/journal_${host}_json.log
22     else
23         sudo journalctl > /tmp/journal_${host}.log
24         sudo journalctl -o json > /tmp/journal_${host}_json.log
25     fi
26 done
27
28 cd /tmp
29 tar czf node_journals.tgz journal_*.log
30 rm -f journal_*.log
31 cd -