230 x served & 59 x viewed
Voici donc le script que j’ai fait :
#!/bin/bash # # MariaDB [mysql]> create database CPU; # Query OK, 1 row affected (0.00 sec) # MariaDB [(none)]> CREATE USER 'arias'@'localhost' IDENTIFIED BY 'arias'; # Query OK, 0 rows affected (0.00 sec) # MariaDB [(none)]> GRANT USAGE ON *.* TO 'arias'@'localhost' IDENTIFIED BY 'arias'; # Query OK, 0 rows affected (0.00 sec) # MariaDB [(none)]> GRANT ALL privileges ON CPU.* TO 'arias'@'localhost'; # Query OK, 0 rows affected (0.00 sec) # MariaDB [(none)]> FLUSH PRIVILEGES; # Query OK, 0 rows affected (0.00 sec) # # #mysql -u root -e "CREATE DATABASE CPU;" #mysql -u root -e "USE CPU; CREATE TABLE information (date datetime, cpu float, fanId int, rawFanDuty int, fanDuty float, remoteTemp int, localTemp int);" CPU_USAGE=$(awk '{u=$2+$4; t=$2+$4+$5; if (NR==1){u1=u; t1=t;} else print ($2+$4-u1) * 100 / (t-t1) "%"; }' <(grep 'cpu ' /proc/stat) <(sleep 1;grep 'cpu ' /proc/stat)) DATE=$(date "+%Y-%m-%d %H:%M:%S") CPU_USAGE_2=$(echo $CPU_USAGE | sed 's/%//g' ) #ff0000;">/usr/bin/tuxedofancontrol --show > /tmp/tuxedofancontrol.out FANID=$(cat /tmp/tuxedofancontrol.out | grep "fanId" | awk '{print $2}' | sed 's/,//g') RAWFANDUTY=$(cat /tmp/tuxedofancontrol.out | grep "rawFanDuty" | awk '{print $2}' | sed 's/,//g' ) FANDUTY=$(cat /tmp/tuxedofancontrol.out | grep "fanDuty" | awk '{print $2}' | sed 's/,//g') REMOTETEMP=$(cat /tmp/tuxedofancontrol.out | grep "remoteTemp:" | awk '{print $2}' | sed 's/,//g') LOCALTEMP=$(cat /tmp/tuxedofancontrol.out | grep "localTemp:" | awk '{print $2}' | sed 's/,//g' ) if [ ! -z $FANID ] then SQL="USE CPU; INSERT INTO information (date, cpu, fanId, rawFanDuty, fanDuty, remoteTemp, localTemp) VALUES ('$DATE',$CPU_USAGE_2,$FANID,$RAWFANDUTY,$FANDUTY,$REMOTETEMP,$LOCALTEMP);" else SQL="USE CPU; INSERT INTO information (date, cpu) VALUES ('$DATE',$CPU_USAGE_2);" fi echo $SQL > /tmp/lastsql.out mysql -u root -e "$SQL"
C’est assez simple, je prends la date et l’utilisation du CPU. Et aussi je note toutes les informations de tuxedofancontrol.
J’ai mis le script toutes les 2 minutes dans ma crontab, ensuite je ferai un script pour Grafana.
$ sudo crontab -l */2 * * * * /home/arias/Bash/cpu.bash
Par exemple :
A suivre.
Visiblement je ne suis pas le seul à trouver le ventilateur un peu trop bruyant : https://www.tuxedocomputers.com/en/Infos/Help-Support/Frequently-asked-questions/Why-is-the-ventilator-so-loud-.tuxedo .
#ff0000;">Why is the ventilator so loud?