======Monitoring serveur et activités du disque dur avec Raspberry Pi======
===== Introduction =====
Pour illustrer le fait qu'un son peut altérer l'écriture sur un disque ou plus globalement pour monitorer l'activité d'un serveur, on va utiliser la combinaison de collectd, influxdb et grafana à installer sur une raspberry pi
Cette illustration est notamment faite pour l'exposition "go cany go" pour laquelle un dispositif est créé afin d'illustrer le phénomène vu dans cette vidéo :
{{ youtube>tDacjrSCeq4 }}
* [[https://motherboard.vice.com/en_us/article/a-loud-sound-just-shut-down-a-banks-data-center-for-10-hours|a loud sound just shut down a banks data center for 10 hours sur motherboard.vice.com
]]
===== Installation =====
==== Netdata ====
Un outil simple, joli et facile à installer https://github.com/firehol/netdata
* installer avec l'automatique installer https://github.com/firehol/netdata/wiki/Installation
* aller sur http://localhost:19999
{{ media_05:c882bbf4-f554-11e5-8863-1788d643d2c0.gif?600 |}}
===== Installation scripts =====
Installer netdata :
bash <(curl -Ss https://my-netdata.io/kickstart.sh)
==== Install brute ====
sudo apt install sox openvpn
Ajouter config file openvpn dans le home, créer le fichier datacrash.sh dans le home, chmod +x
Mettre le son par défaut sur Analog + volume max + sudo alsactl store
datacrash.sh
#!/bin/bash
# en bas du fichier
# sudo nano /home/pi/.config/lxsession/LXDE-pi/autostart
# @chromium-browser --kiosk http://localhost:19999/#menu_disk_submenu_sda;theme=slate;help=true;update_always=true
# mount external hdd via fstab /dev/sda1 /media/usbhdd ext4 defaults 0 0
# python off-button.py &
sleep 10
while true
do
sudo dd if=/dev/zero of=/media/usbhdd/oo bs=512 count=500M &
sleep 120
play -n synth 20 sin 300 gain -15 &
sleep 6
play -n synth 8 sin 295 gain -15 &
sleep 2
play -n synth 4 sin 290 gain -15
sleep 180
sudo killall dd
sudo rm /media/usbhdd/oo
sleep 3
done
/etc/rc.local
openvpn --config /home/pi/install3.ovpn &
python /home/pi/pioff.py &
cd /home/pi/
sudo ./datacrash.sh
sudo nano /home/pi/.config/lxsession/LXDE-pi/autostart
ou plutot
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash
@point-rpi
@xset s off
@xset -dpms
@xset s noblank
@chromium-browser --kiosk http://localhost:19999/#menu_disk_submenu_sda;theme=slate;help=true;update_always=true
**Script pour extinction propre de la pi avec bouton externe**
pioff.py
#!/bin/python
#This script was authored by AndrewH7 and belongs to him (www.instructables.com/member/AndrewH7)
#You have permission to modify and use this script only for your own personal usage
#You do not have permission to redistribute this script as your own work
#Use this script at your own risk
import RPi.GPIO as GPIO
import os
gpio_pin_number=21
#Replace YOUR_CHOSEN_GPIO_NUMBER_HERE with the GPIO pin number you wish to use
#Make sure you know which rapsberry pi revision you are using first
#The line should look something like this e.g. "gpio_pin_number=7"
GPIO.setmode(GPIO.BCM)
#Use BCM pin numbering (i.e. the GPIO number, not pin number)
#WARNING: this will change between Pi versions
#Check yours first and adjust accordingly
GPIO.setup(gpio_pin_number, GPIO.IN, pull_up_down=GPIO.PUD_UP)
#It's very important the pin is an input to avoid short-circuits
#The pull-up resistor means the pin is high by default
try:
GPIO.wait_for_edge(gpio_pin_number, GPIO.FALLING)
#Use falling edge detection to see if pin is pulled
#low to avoid repeated polling
os.system("sudo shutdown -h now")
#Send command to system to shutdown
except:
pass
GPIO.cleanup()
#Revert all GPIO pins to their normal states (i.e. input = safe)
===== Références =====
* https://sonnguyen.ws/monitor-server-with-collectd-influxdb-and-grafana/
* http://giatro.me/2015/09/30/install-influxdb-and-grafana-on-raspberry-pi.html
* stats disk du kernel https://www.kernel.org/doc/Documentation/iostats.txt
{{tag>bj micro_ordinateur raspberry_pi serveur linux}}