Skip to content

Instantly share code, notes, and snippets.

@josephoaks
Created May 24, 2017 22:57
Show Gist options
  • Save josephoaks/e65e337dc5565e32416a1341a977f360 to your computer and use it in GitHub Desktop.
Save josephoaks/e65e337dc5565e32416a1341a977f360 to your computer and use it in GitHub Desktop.
--- custom fact ---
Facter.add(:if_speed) do
setcode do
Facter::Core::Execution.exec('bash script')
end
end
--- bash script ---
#!/bin/bash
for i in `ifconfig -a | sed 's/[ \t].*//;/^\(lo\|\)$/d'`; do
ethtool $i | if [[ "Speed: 1000" ]]; then
line=$(head -n 1)
echo $line|awk '{print $3}'|sed 's/://'
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment