InfoSecREDD Posted February 12, 2020 Share Posted February 12, 2020 Battery Tester/CPU StressFor the SharkJack I keep seeing people talk about how the battery lasts less then 10 minutes, etc etc etc.. I made a script to test and prove the Battery Drains incredibly fast under load. Further more... The Script.. (NOTE: This Script should be ran on the SharkJack itself!) battery-tester.sh #!/bin/bash # Title : Battery Tester/CPU Stress # Author : REDD of Private-Locker # Version : 1.1 # Description : The script uses a simple log system to pull the # batteries status, date, and time into a log file for Hak5 # to help diagnose the issues. Also uses "sha256sum" to verify # a null file leaving it to stress the CPU. # # Log File : /root/battery.log # Set to YES to stress the CPU during Battery Test. MAX_LOAD=YES STRESS="sha256sum" # Time in seconds to report in log. (20 mins = 1200) TIME=600 # Initial Script Variables - DO NOT CHANGE UNDER_LOAD=0 DATE_NOW=$(date +'%r') START_TIME=$(date) CPU_USAGE=$(grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage "%"}') BATTERY_STATUS=$(BATTERY) LOG_FILE="/root/battery.log" function DISPLAY_TIME () { MINS=$((TIME / 60)) SECS=$((TIME % 60)) if [ "$TIME" -ge "60" ]; then printf "$MINS minutes and $SECS seconds" else printf "$SECS seconds" fi } TOTAL_TIME=$(DISPLAY_TIME "$TIME") if [ ! -f "$LOG_FILE" ]; then touch "$LOG_FILE" fi if [ -f "$LOG_FILE" ]; then echo -e "" >> "$LOG_FILE" echo -e " Battery Test Date: $START_TIME" >> "$LOG_FILE" echo -e "==================================================" >> "$LOG_FILE" echo -e "" >> "$LOG_FILE" echo -e "" echo -e " Battery Test Date: $START_TIME" echo -e "\n Battery Test running for $TOTAL_TIME." echo -e " Battery Test running for $TOTAL_TIME." >> "$LOG_FILE" echo -e " Battery Status: $BATTERY_STATUS" echo -e " Battery Status: $BATTERY_STATUS" >> "$LOG_FILE" echo -e "" if [ "$MAX_LOAD" == "YES" ]; then echo -e "\n\n -> LOAD created by $STRESS." echo -e " -> LOAD created by $STRESS." >> "$LOG_FILE" echo -e "" >> "$LOG_FILE" echo -e "==================================================" >> "$LOG_FILE" echo -e "" >> "$LOG_FILE" fi echo -e "" >> "$LOG_FILE" fi echo -e "[${DATE_NOW}] -> LOAD: $MAX_LOAD - CPU Load: ${CPU_USAGE} [Battery Status: ${BATTERY_STATUS}]" >> "$LOG_FILE" for ((i=0; i<=TIME; i++)); do if [ "$MAX_LOAD" == "YES" ]; then if [ "$UNDER_LOAD" == "0" ]; then UNDER_LOAD=1 $STRESS /dev/zero & fi fi DATE_NOW=$(date +'%r') CPU_USAGE=$(grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage "%"}') BATTERY_STATUS=$(BATTERY) printf "[%s%s] -> LOAD: %s - CPU Load: %s [Battery Status: %s]\r" $DATE_NOW $MAX_LOAD $CPU_USAGE $BATTERY_STATUS echo -e "[${DATE_NOW}] -> LOAD: $MAX_LOAD - CPU Load: ${CPU_USAGE} [Battery Status: ${BATTERY_STATUS}]" >> "$LOG_FILE" sleep 1; done if [ "$UNDER_LOAD" == "1" ]; then killall -9 $STRESS fi echo -e "" >> "$LOG_FILE" echo -e "==================================================" >> "$LOG_FILE" echo -e "" >> "$LOG_FILE" # Blank line for running in Terminal. printf " \n" printf "Finished.\n" Output Example: Battery Test Date: Tue Jan 28 13:47:30 UTC 2020 ================================================== Battery Test running for 10 seconds. Battery Status: full [01:47:30 PM] -> LOAD: NO - CPU Load: 18.0325% [Battery Status: full] [01:47:30 PM] -> LOAD: NO - CPU Load: 18.0437% [Battery Status: full] [01:47:31 PM] -> LOAD: NO - CPU Load: 18.0428% [Battery Status: full] [01:47:32 PM] -> LOAD: NO - CPU Load: 18.0432% [Battery Status: full] [01:47:33 PM] -> LOAD: NO - CPU Load: 18.0469% [Battery Status: full] [01:47:34 PM] -> LOAD: NO - CPU Load: 18.0515% [Battery Status: full] [01:47:35 PM] -> LOAD: NO - CPU Load: 18.0556% [Battery Status: full] [01:47:37 PM] -> LOAD: NO - CPU Load: 18.0596% [Battery Status: full] [01:47:38 PM] -> LOAD: NO - CPU Load: 18.0641% [Battery Status: full] [01:47:39 PM] -> LOAD: NO - CPU Load: 18.0678% [Battery Status: full] [01:47:40 PM] -> LOAD: NO - CPU Load: 18.0718% [Battery Status: full] [01:47:41 PM] -> LOAD: NO - CPU Load: 18.0759% [Battery Status: full] ================================================== I really hope this helps everyone else in their troubles in finding out if their Battery is just defective or it's just "Under Load" that makes it so short. Link to comment Share on other sites More sharing options...
InfoSecREDD Posted February 12, 2020 Author Share Posted February 12, 2020 @Darren Kitchen Currently mine only gets like 2 mins "Under Load".. Not sure if that's good thing.. Battery Test Date: Tue Jan 28 13:48:57 UTC 2020 ================================================== Battery Test running for 20 minutes and 0 seconds. Battery Status: full -> LOAD created by sha256sum. ================================================== [01:48:57 PM] -> LOAD: YES - CPU Load: 18.0481% [Battery Status: full] [01:48:57 PM] -> LOAD: YES - CPU Load: 18.0588% [Battery Status: full] [01:48:59 PM] -> LOAD: YES - CPU Load: 18.1068% [Battery Status: full] [01:49:00 PM] -> LOAD: YES - CPU Load: 18.1528% [Battery Status: discharging] [01:49:01 PM] -> LOAD: YES - CPU Load: 18.1969% [Battery Status: discharging] [01:49:02 PM] -> LOAD: YES - CPU Load: 18.2414% [Battery Status: discharging] [01:49:03 PM] -> LOAD: YES - CPU Load: 18.2865% [Battery Status: discharging] [01:49:05 PM] -> LOAD: YES - CPU Load: 18.3312% [Battery Status: discharging] [01:49:06 PM] -> LOAD: YES - CPU Load: 18.3785% [Battery Status: discharging] [01:49:07 PM] -> LOAD: YES - CPU Load: 18.4227% [Battery Status: discharging] [01:49:08 PM] -> LOAD: YES - CPU Load: 18.4666% [Battery Status: discharging] [01:49:09 PM] -> LOAD: YES - CPU Load: 18.5114% [Battery Status: discharging] [01:49:11 PM] -> LOAD: YES - CPU Load: 18.5555% [Battery Status: discharging] [01:49:12 PM] -> LOAD: YES - CPU Load: 18.6026% [Battery Status: discharging] [01:49:13 PM] -> LOAD: YES - CPU Load: 18.6469% [Battery Status: discharging] [01:49:14 PM] -> LOAD: YES - CPU Load: 18.6905% [Battery Status: discharging] [01:49:15 PM] -> LOAD: YES - CPU Load: 18.734% [Battery Status: discharging] [01:49:17 PM] -> LOAD: YES - CPU Load: 18.7782% [Battery Status: discharging] [01:49:18 PM] -> LOAD: YES - CPU Load: 18.8258% [Battery Status: discharging] [01:49:19 PM] -> LOAD: YES - CPU Load: 18.8703% [Battery Status: discharging] [01:49:20 PM] -> LOAD: YES - CPU Load: 18.9136% [Battery Status: discharging] [01:49:21 PM] -> LOAD: YES - CPU Load: 18.9569% [Battery Status: discharging] [01:49:22 PM] -> LOAD: YES - CPU Load: 19.0009% [Battery Status: discharging] [01:49:24 PM] -> LOAD: YES - CPU Load: 19.0474% [Battery Status: discharging] [01:49:25 PM] -> LOAD: YES - CPU Load: 19.0917% [Battery Status: discharging] [01:49:26 PM] -> LOAD: YES - CPU Load: 19.1344% [Battery Status: discharging] [01:49:27 PM] -> LOAD: YES - CPU Load: 19.1778% [Battery Status: discharging] [01:49:28 PM] -> LOAD: YES - CPU Load: 19.2215% [Battery Status: discharging] [01:49:30 PM] -> LOAD: YES - CPU Load: 19.2674% [Battery Status: discharging] [01:49:31 PM] -> LOAD: YES - CPU Load: 19.3126% [Battery Status: discharging] [01:49:32 PM] -> LOAD: YES - CPU Load: 19.3558% [Battery Status: discharging] [01:49:33 PM] -> LOAD: YES - CPU Load: 19.399% [Battery Status: discharging] [01:49:34 PM] -> LOAD: YES - CPU Load: 19.4421% [Battery Status: discharging] [01:49:36 PM] -> LOAD: YES - CPU Load: 19.4889% [Battery Status: discharging] [01:49:37 PM] -> LOAD: YES - CPU Load: 19.5334% [Battery Status: discharging] [01:49:38 PM] -> LOAD: YES - CPU Load: 19.5764% [Battery Status: discharging] [01:49:39 PM] -> LOAD: YES - CPU Load: 19.6208% [Battery Status: discharging] [01:49:40 PM] -> LOAD: YES - CPU Load: 19.6644% [Battery Status: discharging] [01:49:42 PM] -> LOAD: YES - CPU Load: 19.7087% [Battery Status: discharging] [01:49:43 PM] -> LOAD: YES - CPU Load: 19.7544% [Battery Status: discharging] [01:49:44 PM] -> LOAD: YES - CPU Load: 19.7972% [Battery Status: discharging] [01:49:45 PM] -> LOAD: YES - CPU Load: 19.8395% [Battery Status: discharging] [01:49:46 PM] -> LOAD: YES - CPU Load: 19.8826% [Battery Status: discharging] [01:49:48 PM] -> LOAD: YES - CPU Load: 19.9259% [Battery Status: discharging] [01:49:49 PM] -> LOAD: YES - CPU Load: 19.9717% [Battery Status: discharging] [01:49:50 PM] -> LOAD: YES - CPU Load: 20.015% [Battery Status: discharging] [01:49:51 PM] -> LOAD: YES - CPU Load: 20.0571% [Battery Status: discharging] [01:49:52 PM] -> LOAD: YES - CPU Load: 20.0995% [Battery Status: discharging] [01:49:54 PM] -> LOAD: YES - CPU Load: 20.1419% [Battery Status: discharging] [01:49:55 PM] -> LOAD: YES - CPU Load: 20.1879% [Battery Status: discharging] [01:49:56 PM] -> LOAD: YES - CPU Load: 20.2309% [Battery Status: discharging] [01:49:57 PM] -> LOAD: YES - CPU Load: 20.2728% [Battery Status: discharging] [01:49:58 PM] -> LOAD: YES - CPU Load: 20.315% [Battery Status: discharging] [01:50:00 PM] -> LOAD: YES - CPU Load: 20.3575% [Battery Status: discharging] [01:50:01 PM] -> LOAD: YES - CPU Load: 20.4021% [Battery Status: discharging] [01:50:02 PM] -> LOAD: YES - CPU Load: 20.4453% [Battery Status: discharging] [01:50:03 PM] -> LOAD: YES - CPU Load: 20.4869% [Battery Status: discharging] [01:50:04 PM] -> LOAD: YES - CPU Load: 20.5289% [Battery Status: discharging] [01:50:06 PM] -> LOAD: YES - CPU Load: 20.5712% [Battery Status: discharging] [01:50:07 PM] -> LOAD: YES - CPU Load: 20.6152% [Battery Status: discharging] [01:50:08 PM] -> LOAD: YES - CPU Load: 20.6585% [Battery Status: discharging] [01:50:09 PM] -> LOAD: YES - CPU Load: 20.6996% [Battery Status: discharging] [01:50:10 PM] -> LOAD: YES - CPU Load: 20.7406% [Battery Status: discharging] --- END OF FILE --- Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.