Untitled
unknown
plain_text
a year ago
1.5 kB
7
Indexable
#!/system/bin/sh
# Package name and interval in seconds between runs
PACKAGE_NAME="$1"
INTERVAL=5 # Adjust this as needed
if [ -z "$PACKAGE_NAME" ]; then
echo "Usage: $0 <package_name>"
exit 1
fi
# Function to get the PID of the package
get_pid() {
pid=$(pidof "$PACKAGE_NAME")
echo "$pid"
}
# Output file paths
MEMINFO_FILE="/data/local/tmp/${PACKAGE_NAME}_meminfo.txt"
SMAP_FILE="/data/local/tmp/${PACKAGE_NAME}_smap.txt"
DMABUF_FILE="/data/local/tmp/${PACKAGE_NAME}_dmabuf.txt"
# Create or clear files
> "$MEMINFO_FILE"
> "$SMAP_FILE"
> "$DMABUF_FILE"
echo "Monitoring package: $PACKAGE_NAME"
echo "Output files:"
echo " Meminfo: $MEMINFO_FILE"
echo " Smaps: $SMAP_FILE"
echo " Dmabuf dump: $DMABUF_FILE"
# Continuous monitoring loop
while true; do
PID=$(get_pid)
if [ -z "$PID" ]; then
echo "$(date): Process $PACKAGE_NAME not running" | tee -a "$MEMINFO_FILE" "$SMAP_FILE" "$DMABUF_FILE"
else
echo "$(date): Process ID for $PACKAGE_NAME is $PID"
echo "$(date): Running dumpsys meminfo..." | tee -a "$MEMINFO_FILE"
dumpsys meminfo "$PACKAGE_NAME" >> "$MEMINFO_FILE" 2>&1
echo "$(date): Running smaps..." | tee -a "$SMAP_FILE"
cat "/proc/$PID/smaps" >> "$SMAP_FILE" 2>&1
echo "$(date): Running dmabuf_dump..." | tee -a "$DMABUF_FILE"
dmabuf_dump "$PID" >> "$DMABUF_FILE" 2>&1
fi
echo "Waiting for $INTERVAL seconds..."
sleep "$INTERVAL"
done
Editor is loading...
Leave a Comment