Skip to content

Instantly share code, notes, and snippets.

@dbknickerbocker
Created April 3, 2013 12:52
Show Gist options
  • Save dbknickerbocker/5300944 to your computer and use it in GitHub Desktop.
Save dbknickerbocker/5300944 to your computer and use it in GitHub Desktop.
function get_temp() {
exec("/usr/local/bin/mbmon -c1 -T1", $dfout);
return trim($dfout[0]);
}
function get_temp() {
exec("/usr/local/bin/mbmon -r -c1 | /usr/bin/grep TEMP | /usr/bin/awk '{ print $3 }'", $temps);
return $temps;
}
function has_temp() {
return true;
}
<?php
if(has_temp()):
$temps = get_temp();
foreach ($temps as &$temp) {
?>
<tr>
<td width='25%' class='vncellt'>Temperature</td>
<td width='75%' class='listr'>
<img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_left.gif" height="15" width="4" border="0" align="middle" alt="left bar" /><img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_blue.gif" height="15" name="tempwidtha" id="tempwidtha" width="<?= $temp; ?>" border="0" align="middle" alt="red bar" /><img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_gray.gif" height="15" name="tempwidthb" id="tempwidthb" width="<?= (100 - $temp); ?>" border="0" align="middle" alt="gray bar" /><img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_right.gif" height="15" width="5" border="0" align="middle" alt="right bar" />
&nbsp;
<input style="border: 0px solid white;" size="30" name="tempmeter" id="tempmeter" value="<?= $temp."C"; ?>" />
</td>
</tr>
<?php
}
endif;
?>
<?php
if(has_temp()):
?>
<tr>
<td width='25%' class='vncellt'>Temperature</td>
<td width='75%' class='listr'>
<?php $temp = get_temp(); ?>
<img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_left.gif" height="15" width="4" border="0" align="middle" alt="left bar" /><img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_blue.gif" height="15" name="tempwidtha" id="tempwidtha" width="<?= $temp; ?>" border="0" align="middle" alt="red bar" /><img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_gray.gif" height="15" name="tempwidthb" id="tempwidthb" width="<?= (100 - $temp); ?>" border="0" align="middle" alt="gray bar" /><img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_right.gif" height="15" width="5" border="0" align="middle" alt="right bar" />
&nbsp;
<input style="border: 0px solid white;" size="30" name="tempmeter" id="tempmeter" value="<?= $temp."C"; ?>" />
</td>
</tr>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment