#!/bin/bash #Copyright (c) 2016 Wind River Systems, Inc. # #SPDX-License-Identifier: Apache-2.0 # # The following script is used when either memstats or filestats summary reports # a possible memory or file leak respectively. It can be run for a particular host or # for all hosts as configured in the lab.conf. # Make sure to run cleanup-uncompressed.sh script before running this script to remove # any uncompressed files as memstats/filestats parser can produce erronous result if # there are both uncompressed and compressed version of the same file. # # Usage: # ./parse-daily.sh to generate daily stats for all hosts # ./parse-daily.sh to generate daily stats for # specified host. # # e.g. >./parse-daily.sh memstats sm-eru # >./parse-daily.sh controller-0 filestats postgress function print_usage() { echo "Usage: ./parse-daily.sh will parse daily data for all hosts." echo "Usage: ./parse-daily.sh will parse daily data for specified host." echo "Valid parsers for daily stats are: memstats & filestats." exit 1 } function parse_daily_stats() { local PARSER_NAME=$1 local PROCESS_NAME=$2 local TMPFILE="tmp.txt" # Inserting the header in the summary csv file. The summary file is a concatenation # of the daily file. If there is a large number of files, the parser may not have # enough memory to process them all. The safest way is to parse one day at a time. if [ ${PARSER_NAME} == "memstats" ]; then local SUMMARYFILE=memstats-summary-${PROCESS_NAME}.csv echo "Date,RSS,VSZ" > ${SUMMARYFILE} else local SUMMARYFILE=filestats-summary-${PROCESS_NAME}.csv echo "Date,Read/Write,Write,Read" > ${SUMMARYFILE} fi # Get the list of dates for memstats/filestats bz2 files in this directory. # The filename convention is : _YYYY-MM-DD_