lib/keystone/os/unix.rb in kanamei-keystone-0.0.17 vs lib/keystone/os/unix.rb in kanamei-keystone-0.0.18
- old
+ new
@@ -12,22 +12,31 @@
end
}
return ips
end
+ def bin_or_usrbin(cmd,option="")
+ cmd_option = "#{cmd} #{option}"
+ begin;return `/bin/#{cmd_option}` if File.exists?("/bin/#{cmd}");rescue;end
+ begin;return `/usr/bin/#{cmd_option}` if File.exists?("/usr/bin/#{cmd}");rescue;end
+ begin;return `/sbin/#{cmd_option}` if File.exists?("/sbin/#{cmd}");rescue;end
+ begin;return `/usr/sbin/#{cmd_option}`.chomp;rescue;end
+ end
+
def hostname
- `/bin/hostname`.chomp
+ bin_or_usrbin("hostname")
end
def disk
- `/bin/df -h`.chomp
+ bin_or_usrbin("df","-h")
end
def process_list
- `/bin/ps -ef`.chomp
+ bin_or_usrbin("ps","-aux")
end
def netstat
+ bin_or_usrbin("netstat","-an")
`/usr/sbin/netstat -an`.chomp
end
end
end
end
\ No newline at end of file