#!/usr/bin/ruby require 'socket' TCPSocket.open('localhost', 7634) { |client| print "HDD: " count = 0 client.readline.split(/\|\|/).each { |entry| entry.gsub!(/^\||\|$/, '') fields = entry.split(/\|/) if count > 0 print "/" else count += 1 end print fields[2] } puts "" } temps = Hash.new rd, wr = IO.pipe fork { rd.close STDOUT.reopen(wr) wr.close exec('sensors', '-A') } wr.close cores = Array.new rd.readlines.each { |line| if line =~ /Temp:/ line.scan(/^(.*) Temp: +\+?(-?\d+).*/) { |id, temp| temps[id] = temp if id =~ /^Core/ cores.push(id) end } end } print "CPU: " cores.each { |core| print temps[core] + "/" } puts temps["CPU"] puts "MB: " + temps["M/B"]