Skip to content

Instantly share code, notes, and snippets.

@markcaudill
Last active December 16, 2015 09:29
Show Gist options
  • Save markcaudill/5413391 to your computer and use it in GitHub Desktop.
Save markcaudill/5413391 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>tmplog</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Le styles -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
body {
padding-top: 20px;
padding-bottom: 40px;
}
/* Custom container */
.container-narrow {
margin: 0 auto;
max-width: 700px;
}
.container-narrow > hr {
margin: 30px 0;
}
/* Supporting marketing content */
.marketing {
margin: 60px 0;
}
.marketing p + h4 {
margin-top: 28px;
}
</style>
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- Fav and touch icons -->
<link rel="shortcut icon" href="favicon.ico">
</head>
<body>
<div class="container-narrow">
<div class="masthead">
<ul class="nav nav-pills pull-right">
<li class="active"><a href="index.html">Home</a></li>
</ul>
<h3 class="muted">tmplog</h3>
</div>
<hr>
<div class="row-fluid marketing">
<p>
<img src="day.png" />
</p>
<p>
<img src="week.png" />
</p>
<p>
<img src="month.png" />
</p>
<p>
<img src="year.png" />
</p>
<p>
<img src="decade.png" />
</p>
</div>
<hr>
<div class="footer">
<p>&copy; 2013 Mark Caudill</p>
</div>
</div> <!-- /container -->
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
#!/bin/bash
database=${1:-"templog.rrd"}
temperature=$(/usr/local/bin/temper | cut -d',' -f2)
rrdtool update $database N:$temperature
rrdtool graph /var/www/html/tmplog/day.png \
-t "Temperature - Day" \
--end now --start now-86400s \
DEF:temperature=$database:temperature:LAST \
LINE1:temperature#E9B64D:"Temperature (C)\t" \
GPRINT:temperature:MIN:"Min\: %2.1lf\t" \
GPRINT:temperature:MAX:"Max\: %2.1lf\t" \
GPRINT:temperature:LAST:"Cur\: %2.1lf\n" \
COMMENT:"Last update\: $(date '+%Y-%m-%d %H\:%M\:%S UTC')"
rrdtool graph /var/www/html/tmplog/week.png \
-t "Temperature - Week" \
--end now --start now-604800s \
DEF:temperature=$database:temperature:LAST \
LINE1:temperature#E9B64D:"Temperature (C)\t" \
GPRINT:temperature:MIN:"Min\: %2.1lf\t" \
GPRINT:temperature:MAX:"Max\: %2.1lf\t" \
GPRINT:temperature:LAST:"Cur\: %2.1lf\n" \
COMMENT:"Last update\: $(date '+%Y-%m-%d %H\:%M\:%S UTC')"
rrdtool graph /var/www/html/tmplog/month.png \
-t "Temperature - Month" \
--end now --start now-2419200s \
DEF:temperature=$database:temperature:LAST \
LINE1:temperature#E9B64D:"Temperature (C)\t" \
GPRINT:temperature:MIN:"Min\: %2.1lf\t" \
GPRINT:temperature:MAX:"Max\: %2.1lf\t" \
GPRINT:temperature:LAST:"Cur\: %2.1lf\n" \
COMMENT:"Last update\: $(date '+%Y-%m-%d %H\:%M\:%S UTC')"
rrdtool graph /var/www/html/tmplog/year.png \
-t "Temperature - Year" \
--end now --start now-31536000s \
DEF:temperature=$database:temperature:LAST \
LINE1:temperature#E9B64D:"Temperature (C)\t" \
GPRINT:temperature:MIN:"Min\: %2.1lf\t" \
GPRINT:temperature:MAX:"Max\: %2.1lf\t" \
GPRINT:temperature:LAST:"Cur\: %2.1lf\n" \
COMMENT:"Last update\: $(date '+%Y-%m-%d %H\:%M\:%S UTC')"
rrdtool graph /var/www/html/tmplog/decade.png \
-t "Temperature - Decade" \
--end now --start now-315360000s \
DEF:temperature=$database:temperature:LAST \
LINE1:temperature#E9B64D:"Temperature (C)\t" \
GPRINT:temperature:MIN:"Min\: %2.1lf\t" \
GPRINT:temperature:MAX:"Max\: %2.1lf\t" \
GPRINT:temperature:LAST:"Cur\: %2.1lf\n" \
COMMENT:"Last update\: $(date '+%Y-%m-%d %H\:%M\:%S UTC')"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment