• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2#
3# Copyright (C) 2023 The Android Open Source Project
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
18# This function searches for log files within the specified directory
19# that contain the given string in their filenames.
20# It returns a list of matching log file paths.
21FindLogFiles() {
22    # Check for the correct number of arguments
23    if [[ "$#" -ne 2 ]]; then
24        echo "Usage: ${FUNCNAME} <directory> <string>"
25        return 1
26    fi
27
28    # Get the directory and string from the arguments
29    local directory="$1"
30    local string="$2"
31
32    # Ensure the directory exists
33    if [[ ! -d "$directory" ]]; then
34        echo "Error: Directory $directory does not exist."
35        return 1
36    fi
37
38    # Use the find command to search for files with names containing the given string
39    find "$directory" -type f -name "*$string*"
40}
41
42# /tmp/clearcut-logwriter is the default directory where clearcut logs are stored
43logs_directory="/tmp/clearcut-logwriter"
44
45# Find log files for "cuttlefish" metrics
46cuttlefish_logs=$(FindLogFiles "$logs_directory" "cuttlefish")
47echo "$cuttlefish_logs"
48
49# Find log files for "atest" internal metrics
50atest_internal_logs=$(FindLogFiles "$logs_directory" "atest_internal")
51echo "$atest_internal_logs"
52
53# Find log files for "atest" external metrics
54atest_external_logs=$(FindLogFiles "$logs_directory" "atest_external")
55echo "$atest_external_logs"
56
57# gqui is a tool to parse clearcut logs
58gqui from "$cuttlefish_logs" proto GWSLogEntryProto > clearcut_cf.txt 2> clearcut_cf_error.txt
59gqui from "$atest_internal_logs" proto GWSLogEntryProto > clearcut_atest_internal.txt 2> clearcut_atest_internal_error.txt
60gqui from "$atest_external_logs" proto GWSLogEntryProto > clearcut_atest_external.txt 2> clearcut_atest_external_error.txt
61