<commit_before>#!/bin/sh
##########################################################################
# If not stated otherwise in this file or this component's Licenses.txt
# file the following copyright and licenses apply:
#
# Copyright 2016 RDK Management
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##########################################################################
#

. /etc/include.properties
. /etc/device.properties
. /etc/env_setup.sh

LOG_FILE=/opt/logs/top_log.txt
TEMP_LOG=/tmp/top_log.txt
if [ -f /etc/os-release ];then
    if [ "$DEVICE_TYPE" != "mediaclient" ];then
         if [ -f /tmp/.standby ]; then
              LOG_FILE=$TEMP_LOG
         else
              if [ -f /tmp/top_log.txt ];then
                    cat $TEMP_LOG >> $LOG_FILE
                    cat /dev/null > $TEMP_LOG
              fi
        fi
    fi
fi
count=0
if [ "$DEVICE_TYPE" = "mediaclient" ]; then
     top_cmd="top | grep -e load -e Tasks -e Cpu -e Mem -e Swap -e COMMAND -e Receiver -e uimgr_main -e lighttpd -e rmfStreamer -e IARMDaemonMain -e dsMgrMain -e Main -e nrdPluginApp"
elif [ "$DEVICE_TYPE" = "hybrid" ]; then
     top_cmd="top | grep -e load -e Tasks -e Cpu -e Mem -e Swap -e COMMAND -e rmfStreamer -e Receiver -e lighttpd -e IARMDaemonMain -e dsMgrMain -e runPod -e Main -e nrdPluginApp"
else
     top_cmd="top | grep -e load -e Tasks -e Cpu -e Mem -e Swap -e COMMAND -e mpeos -e Receiver -e uimgr_main -e lighttpd -e IARMDaemonMain -e dsMgrMain -e Main -e nrdPluginApp"
fi

# adding sleep of 180 sec to reduce high load condition during bootup
if [ ! -f /etc/os-release ]; then
    sleep 180
fi

# Adding the Clock Frequency Info
echo "Clock Frequency Info:"
cat /proc/cpuinfo | grep MH | sed 's/[[:blank:]]*//g'

if [ ! -f /etc/os-release ]; then
	while true
	do
		echo "`/bin/timestamp`"
                uptime
		eval $top_cmd
                echo "********** Disk Space Usage **********"
		echo "`/bin/df -h`"
		count=`expr $count + 1`
                if [ ! -f /tmp/.standby ];then
	             if [ -f /lib/rdk/heap-usage-stats.sh ];then
                         sh /lib/rdk/heap-usage-stats.sh >> $LOG_PATH/messages.txt
                     fi
                fi
		sleep $1
		if [ $count -eq 12 ]; then
       			top -n1
       			count=0
                        mpstat | awk '/all/{printf("FREE_CPU:%.2f%\n"),$11}' >> $LOG_FILE
                        free | awk '/Mem/{printf("USED_MEM:%d\nFREE_MEM:%d\n"),$3,$4}' >> $LOG_FILE
  		fi
	done
else
	echo "`/bin/timestamp`" >> $LOG_FILE
        uptime >> $LOG_FILE
	eval $top_cmd >> $LOG_FILE
	echo "********** Disk Space Usage **********" >> $LOG_FILE
	echo "`/bin/df -h`" >> $LOG_FILE
        if [ ! -f /tmp/.standby ];then
            if [ -f /lib/rdk/heap-usage-stats.sh ];then
                 sh /lib/rdk/heap-usage-stats.sh >> $LOG_PATH/messages.txt
            fi
        fi
	if [ -f /tmp/.top_count ]; then
		curr_count=`cat /tmp/.top_count`
		count=`expr ${curr_count} + 1`
		if [ $count -eq 12 ]; then
			top -n1
			count=0
                        mpstat | awk '/all/{printf("FREE_CPU:%.2f%\n"),$11}' >> $LOG_FILE
                        free | awk '/Mem/{printf("USED_MEM:%d\nFREE_MEM:%d\n"),$3,$4}' >> $LOG_FILE
		fi
	fi
	echo "$count" > /tmp/.top_count
fi

<commit_msg>RDKCMF-6367 yocto top log interval is not in sync with RDK<commit_after>#!/bin/sh
##########################################################################
# If not stated otherwise in this file or this component's Licenses.txt
# file the following copyright and licenses apply:
#
# Copyright 2016 RDK Management
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##########################################################################
#

. /etc/include.properties
. /etc/device.properties
. /etc/env_setup.sh

LOG_FILE=/opt/logs/top_log.txt
TEMP_LOG=/tmp/top_log.txt
if [ -f /etc/os-release ];then
    if [ "$DEVICE_TYPE" != "mediaclient" ];then
         if [ -f /tmp/.standby ]; then
              LOG_FILE=$TEMP_LOG
         else
              if [ -f /tmp/top_log.txt ];then
                    cat $TEMP_LOG >> $LOG_FILE
                    cat /dev/null > $TEMP_LOG
              fi
        fi
    fi
fi
count=0
if [ "$DEVICE_TYPE" = "mediaclient" ]; then
     top_cmd="top | grep -e load -e Tasks -e Cpu -e Mem -e Swap -e COMMAND -e Receiver -e uimgr_main -e lighttpd -e rmfStreamer -e IARMDaemonMain -e dsMgrMain -e Main -e nrdPluginApp"
elif [ "$DEVICE_TYPE" = "hybrid" ]; then
     top_cmd="top | grep -e load -e Tasks -e Cpu -e Mem -e Swap -e COMMAND -e rmfStreamer -e Receiver -e lighttpd -e IARMDaemonMain -e dsMgrMain -e runPod -e Main -e nrdPluginApp"
else
     top_cmd="top | grep -e load -e Tasks -e Cpu -e Mem -e Swap -e COMMAND -e mpeos -e Receiver -e uimgr_main -e lighttpd -e IARMDaemonMain -e dsMgrMain -e Main -e nrdPluginApp"
fi

# adding sleep of 180 sec to reduce high load condition during bootup
if [ ! -f /etc/os-release ]; then
    sleep 180
fi

# Adding the Clock Frequency Info
echo "Clock Frequency Info:"
cat /proc/cpuinfo | grep MH | sed 's/[[:blank:]]*//g'

if [ ! -f /etc/os-release ]; then
	while true
	do
		echo "`/bin/timestamp`"
                uptime
		eval $top_cmd
                echo "********** Disk Space Usage **********"
		echo "`/bin/df -h`"
		count=`expr $count + 1`
                if [ ! -f /tmp/.standby ];then
	             if [ -f /lib/rdk/heap-usage-stats.sh ];then
                         sh /lib/rdk/heap-usage-stats.sh >> $LOG_PATH/messages.txt
                     fi
                fi
		sleep $1
		if [ $count -eq 12 ]; then
       			top -n1
       			count=0
                        mpstat | awk '/all/{printf("FREE_CPU:%.2f%\n"),$11}' >> $LOG_FILE
                        free | awk '/Mem/{printf("USED_MEM:%d\nFREE_MEM:%d\n"),$3,$4}' >> $LOG_FILE
  		fi
	done
else
	echo "`/bin/timestamp`" >> $LOG_FILE
        uptime >> $LOG_FILE
	eval $top_cmd >> $LOG_FILE
	echo "********** Disk Space Usage **********" >> $LOG_FILE
	echo "`/bin/df -h`" >> $LOG_FILE
        if [ ! -f /tmp/.standby ];then
            if [ -f /lib/rdk/heap-usage-stats.sh ];then
                 sh /lib/rdk/heap-usage-stats.sh >> $LOG_PATH/messages.txt
            fi
        fi
	if [ -f /tmp/.top_count ]; then
		curr_count=`cat /tmp/.top_count`
		count=`expr ${curr_count} + 1`
		if [ $count -eq 6 ]; then
			top -n1
			count=0
                        mpstat | awk '/all/{printf("FREE_CPU:%.2f%\n"),$11}' >> $LOG_FILE
                        free | awk '/Mem/{printf("USED_MEM:%d\nFREE_MEM:%d\n"),$3,$4}' >> $LOG_FILE
		fi
	fi
	echo "$count" > /tmp/.top_count
fi


{'fraction_non_alphanumeric': 0.17297511911064056, 'fraction_numerical': 0.00992588671254632, 'mean_word_length': 2.3086690017513134, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1976288', 'n_tokens_mistral': 2640, 'n_tokens_neox': 2474, 'n_words': 782}