24 lines
		
	
	
	
		
			561 B
		
	
	
	
		
			Bash
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
	
		
			561 B
		
	
	
	
		
			Bash
		
	
	
	
	
	
#!/bin/bash
 | 
						|
 | 
						|
for device in $(smartctl --scan | cut -d' ' -f1)
 | 
						|
do
 | 
						|
  # POWER STATUS
 | 
						|
 | 
						|
  if $(smartctl -n idle -n sleep -i $device | grep "Power mode" | grep -q "STANDBY")
 | 
						|
  then
 | 
						|
    active=False
 | 
						|
  else
 | 
						|
    active=True
 | 
						|
  fi
 | 
						|
  echo "smartctl,host=${node.name},device=$device active=$active $(date --utc +%s%N)"
 | 
						|
 | 
						|
  # TEMPS
 | 
						|
 | 
						|
  temp=$(smartctl -n idle -A --json=c $device | jq .temperature.current)
 | 
						|
  
 | 
						|
  # hdd might be sleeping
 | 
						|
  if [[ $temp == ?(-)+([0-9]) ]]
 | 
						|
  then
 | 
						|
    echo "smartctl,host=${node.name},device=$device temperature=$temp $(date --utc +%s%N)"
 | 
						|
  fi
 | 
						|
done
 |