Last active
August 29, 2015 14:20
-
-
Save dgraziotin/9fda0e2bdf0befed19cf to your computer and use it in GitHub Desktop.
Chart CPU temperature and Fan Speed for OS X
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
# monitor your Macbook CPU temperature and the fan speed | |
# Required: iStats, https://github.com/Chris911/iStats | |
# Usage: Rscript chart.temp.fan.speed.osx.R | |
# Output: Rplots.pdf | |
if (!require("ggplot2")){ | |
install.packages("ggplot2", dep=T) | |
} | |
require(ggplot2) | |
# Set the following variable to the path containing the script | |
temp.fan.files.dir.path <- "/Users/Daniel/Desktop" | |
# Capture values for X seconds | |
capture.duration.secs <- 60 * 60 | |
# Capture values each X seconds | |
capture.polling.secs <- 2 | |
# End edit | |
capture.current.secs <- 0 | |
print("Capturing for") | |
print(capture.duration.secs) | |
print("Seconds. Please wait.") | |
while(capture.current.secs < capture.duration.secs){ | |
system("istats cpu | awk 'BEGIN { FS = \" \" } ; { print $3 }' | cut -c -4 >> cpu.temp.csv && istats fan speed | awk 'BEGIN { FS = \" \" } ; { print $4 }' >> fan.speed.csv") | |
Sys.sleep(capture.polling.secs) | |
capture.current.secs = capture.current.secs + capture.polling.secs | |
} | |
setwd(temp.fan.files.dir.path) | |
temp.file <- "cpu.temp.csv" | |
fan.file <- "fan.speed.csv" | |
temp.df <- read.csv(temp.file, header=F, col.names=c("Temperature")) | |
fan.df <- read.csv(fan.file, header=F, col.names=c("Fan.Speed")) | |
temp.df$Fan.Speed <- fan.df$Fan.Speed | |
temp.fan.df <- temp.df | |
df <- temp.fan.df | |
x = seq(1,length(df$Temp)) | |
y.Temp = df$Temp | |
y.Fan = df$Fan / 100 | |
ggplot(df, aes(x)) + | |
geom_point(aes(y = y.Temp, colour = "Temperature values (C)")) + | |
geom_point(aes(y = y.Fan, colour = "Fan Speed RMP / 100")) + | |
xlab("Time (seconds)") + ylab("Value") + theme_classic() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment