-
Notifications
You must be signed in to change notification settings - Fork 4
/
raspi-info-light
109 lines (92 loc) · 5.16 KB
/
raspi-info-light
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
#################################################################################
# _ _ __ _ _ _ _ #
# _ __ __ _ ___ _ __ (_) (_)_ __ / _| ___ | (_) __ _| |__ | |_ #
# | '__/ _` / __| '_ \| |_____| | '_ \| |_ / _ \ _____| | |/ _` | '_ \| __| #
# | | | (_| \__ \ |_) | |_____| | | | | _| (_) |_____| | | (_| | | | | |_ #
# |_| \__,_|___/ .__/|_| |_|_| |_|_| \___/ |_|_|\__, |_| |_|\__| #
# |_| |___/ #
# #
# #
# MIT License #
# Copyright (c) 2019-2024 Massimo Pissarello #
# Permission is hereby granted, free of charge, to any person obtaining a copy #
# of this software and associated documentation files (the "Software"), to deal #
# in the Software without restriction, including without limitation the rights #
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell #
# copies of the Software, and to permit persons to whom the Software is #
# furnished to do so, subject to the following conditions: #
# The above copyright notice and this permission notice shall be included in #
# all copies or substantial portions of the Software. #
# #
#################################################################################
##### VARIABLES AT BEGINNING FOR CORRECT MEASUREMENT!!!
# Temperature
CPUTEMP=$(cat /sys/class/thermal/thermal_zone0/temp)
#######################################################
RASPMOD=$(tr -d '\0' </proc/device-tree/model)
MEMTOT=$((`grep -i MemTotal /proc/meminfo | cut -f1 -dk | cut -f2 -d:` / (1024*1024) + 1))
clear
# System
if [[ "$RASPMOD" == "Raspberry Pi 4"* ]] || [[ "$RASPMOD" == "Raspberry Pi Compute Module 4"* ]] || [[ "$RASPMOD" == "Raspberry Pi 400"* ]] || [[ "$RASPMOD" == "Raspberry Pi 5"* ]]; then
echo -e '\e[33m'"$RASPMOD with ${MEMTOT}GB RAM"; else
echo -e '\e[33m'"$RASPMOD"; fi
echo -e '\e[32m'"`lsb_release -d | awk '/Description:/ {printf "%s %s ", $2, $3}' && cat /etc/debian_version | tr -d '\n' && lsb_release -d | awk '/Description:/ {printf " %s", $5}'`"
# Uptime and load average
echo -e "Load average (1m, 5m, 15m)`uptime | awk -F'[a-z]:' '{print $2}'`"
# Temperature
if [ `whoami` = 'root' ]; then
if [ "$CPUTEMP" -lt "45000" ]; then
echo -e '\e[36m'"CPU `vcgencmd measure_temp` ---> LOW TEMPERATURE"'\e[0m'
elif [ "$CPUTEMP" -gt "45000" ] && [ "$CPUTEMP" -lt "55000" ]; then
echo -e '\e[33m'"CPU `vcgencmd measure_temp` ---> NORMAL TEMPERATURE"'\e[0m'
elif [ "$CPUTEMP" -gt "55000" ] && [ "$CPUTEMP" -lt "65000" ]; then
echo -e '\e[33m\e[1m'"CPU `vcgencmd measure_temp` ---> NORMAL-HIGH TEMPERATURE"'\e[0m'
elif [ "$CPUTEMP" -gt "65000" ] && [ "$CPUTEMP" -lt "75000" ]; then
echo -e '\e[31m'"CPU `vcgencmd measure_temp`---> HIGH TEMPERATURE!"'\e[0m'
elif [ "$CPUTEMP" -gt "75000" ]; then
echo -e '\e[31m\e[1m'"CPU `vcgencmd measure_temp` ---> PLEASE SHUTDOWN RASPBERRYPI: TEMPERATURE IS VERY HIGH!"'\e[0m'
fi
fi
# Check Internet and IP
EXTIP=$(dig TXT +short o-o.myaddr.l.google.com @ns1.google.com | sed -e 's/^"//' -e 's/"$//')
COUNTRY=`whois $EXTIP | grep -m 1 country: | awk '{print $2}'`
ping -c 1 google.com &> /dev/null && echo -e "\e[32mInternet connected with IP $EXTIP ($COUNTRY)" || echo -e "\e[31m\e[1mInternet not connected"'\e[0m'
INTERFACE=$(ip -o -f inet addr show | awk '/scope global/ {print $2, $4}')
echo -e -n '\e[32m'"Internal IP:" $INTERFACE
# WLAN quality
if [[ $INTERFACE =~ wlan0 ]]; then
echo -e -n '\e[33m'" "
iwgetid | awk '{ print $2}'
iwconfig wlan0 | grep -i "Bit Rate" | sed -e 's/^\s*//' -e '/^$/d' # REMOVE TAB
iwconfig wlan0 | grep -i "Link Quality" | sed -e 's/^\s*//' -e '/^$/d' # REMOVE TAB
else
echo
fi
# File system
echo -e '\e[95m'
df -h | grep -v "tmpfs" | grep -v "udev"
echo -e '\e[0m'
# About date
echo -e '\e[96m'"Time now is `date +"%H:%M:%S"` in `timedatectl | awk '/Time zone:/ {print $3, $4, $5}'`"
echo -e "Uptime `uptime -p | sed "s/^[^ ]* //"`"
echo -e '\e[0m'
# Bitcoin
#BTCUSD=`curl -sk https://api.coindesk.com/v1/bpi/currentprice/usd.json | jq -r .bpi.USD.rate | tail -c +1 | head -c -1 | rev | cut -c3- | rev`
#echo " 1 Bitcoin = "$BTCUSD" USD "
# Tips and random color for fitglet
TIP=/usr/lib/raspi-info/shell-tips
FIGLETCOLOR=`shuf -i91-96 -n1`
echo -e '\e[44m\e[1m'" Shell tip: `shuf -n 1 $TIP` "'\e[0m\e['$FIGLETCOLOR'm'
# Print hostname
figlet `hostname -s`
# Check version
UPVER=$(curl -sSfL https://raw.githubusercontent.com/mapi68/raspi-info/master/version)
VERSION=$(dpkg -s raspi-info | grep '^Version:' | awk '/:/ {print $2}')
if [[ "$VERSION" -lt "$UPVER" ]]; then
echo -e '\e[1;33m'"NEW VERSION AVAILABLE: please run 'raspi-info-update'"; fi
# Need reboot?
if [ -f /var/run/reboot-required ]; then
echo -e '\e[1;31m'"***** SYSTEM RESTART REQUIRED *****"; fi
echo -e '\e[0m'"\c"
echo