Last active
August 29, 2015 14:17
-
-
Save skottler/198d05914bd8d4bf499d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ohai.plugin(:Trim) do | |
# This ohai plugin provides data about TRIM support on each underlying block | |
# device available on the system. Its functionality is rather simple - it | |
# iterates over each physical device, ignoring partitions, and then runs | |
# hdparm to find the drives' capabilities, finally grepping for TRIM support. | |
provides "block_device/trim" | |
depends "block_device" | |
collect_data(:default) do | |
devices = shell_out("ls /dev/sd[a-z]").stdout.lines | |
if devices | |
devices.each do |device| | |
device = device.chomp | |
so = shell_out("hdparm -I #{device} | grep 'TRIM supported'") | |
block_device[device.gsub(/.*\//, '').to_sym][:trim] = so.exitstatus == 0 ? true : false | |
end | |
block_device | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"sda": { | |
"size": "$SIZE", | |
"removable": "0", | |
"model": "$MODEL", | |
"rev": "$REV", | |
"state": "running", | |
"timeout": "90", | |
"vendor": "$VENDOR", | |
"trim": false | |
}, | |
"sdb": { | |
"size": "$SIZE", | |
"removable": "0", | |
"model": "$MODEL", | |
"rev": "$REV", | |
"state": "running", | |
"timeout": "30", | |
"vendor": "$VENDOR", | |
"trim": true | |
}, | |
"sdc": { | |
"size": "$SIZE", | |
"removable": "0", | |
"model": "$MODEL", | |
"rev": "$REV", | |
"state": "running", | |
"timeout": "30", | |
"vendor": "$VENDOR", | |
"trim": true | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment