Skip to content

Instantly share code, notes, and snippets.

View rnanba's full-sized avatar

R.Nanba rnanba

  • Yokohama, Japan
View GitHub Profile
@rnanba
rnanba / smart_power_on_hours.sh
Created September 5, 2025 04:12
Display S.M.A.R.T Power_On_Hours information for a specified device or all devices.
#!/bin/bash
function print_device() {
JSON=`sudo smartctl -j --all $1`
DEVICE=`echo "$JSON"|jq -r '.device.name'`
NAME=`echo "$JSON"|jq -r '.model_name'`
TABLE=`echo "$JSON"|jq ".ata_smart_attributes.table"`
if [ "$TABLE" == 'null' ]; then
TABLE=`echo "$JSON"|jq ".nvme_smart_health_information_log"`
POH=`echo $TABLE|jq -r ".power_on_hours"`
else