Currently Browsing: sysadmin

Improve speed and availability of Safari on Snow Leopard

I grew tired of staring at the beach ball every morning so I decided to do something about it. I long thought the culprit to be flash based content; through my research to disable Flash I discovered the ClickToFlash Safari plug-in which gives you the option to view the flash based content on demand rather than having it pre-loaded. Some websites have multiple flash-based elements which can be taxing on memory and CPU cycles, particularly with the multi-tabbed web browsing I do. I did not want to disable all plug-ins as I like some of the Safari 5 extensions, that coupled with the fact that flash-based video is widely used.


fixing “perl: warning: Setting locale failed” error

for ubuntu 8.04LTS through 10.04LTS you can resolve the problem which creates the error message:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
 LANGUAGE = "en_US:en",
 LC_ALL = (unset),
 LANG = "en_US"
 are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory

with the following two commands:

% sudo locale-gen fr_FR fr_FR.UTF-8 en_US en_US.UTF-8
% sudo dpkg-reconfigure locales

Expanding LVM Partition on Ubuntu 8.04 LTS with VMWare

  • power off VM
  • edit settings in vmware client to expand hard drive to desired size (i went from 15G to 40G)
  • power on VM
  • parition the expanded area (/dev/sda3 in my case)
fdisk /dev/sda
  • Create a physical volume for LVM:
# pvcreate /dev/sda3
Physical volume “/dev/sda3″ successfully created
  • Add the new physical volume to the volume group:
 #vgextend vg0 /dev/sda3
Volume group “vg0″ successfully extended
  • Extend the Logical Volume, you can find the amount of space with which you can expand by running the ‘vgdisplay’ command and use the value from “Free PE/Size”
# lvextend -L+24.99G /dev/vg0/lv0
  Rounding up size to full physical extent 24.99 GB
  Extending logical volume lv0 to 39.09 GB
  Logical volume lv0 successfully resized

Sourced some of the steps from http://www.swizzling.org/2008/04/01/expand-lvm-disk-on-linux-in-vmware/


Ways to disable emailed output or mail alert by crontab

Prevent the sending of errors and output by crontab

For a entry-by-entry method to prevent the sending of errors and output, add any one of the following at the end of the line for each cron job to redirect output to /dev/null:
>/dev/null 2>&1.
OR
&> /dev/null

as in

0 1 5 10 * /path/to/script.sh >/dev/null 2>&1

or to enforce for all entries in the crontab, enter the following to the first line of your crontab:

MAILTO=""

Graphing wind speed and direction using rrdtool and Wunderground.com XML Feeds

  • Create windspeed RRD data file:
rrdtool create sbwind.rrd \
 --start 1127253600 \
 DS:wind:GAUGE:600:U:U \
 DS:gust:GAUGE:600:U:U \
 RRA:MIN:0.5:1:600 \
 RRA:MIN:0.5:6:700 \
 RRA:MIN:0.5:24:775 \
 RRA:MIN:0.5:288:797 \
 RRA:AVERAGE:0.5:1:600 \
 RRA:AVERAGE:0.5:6:700 \
 RRA:AVERAGE:0.5:24:775 \
 RRA:AVERAGE:0.5:288:797 \
 RRA:MAX:0.5:1:600 \
 RRA:MAX:0.5:6:700 \
 RRA:MAX:0.5:24:775 \
 RRA:MAX:0.5:288:797
  • Create wind direction RRD data file:
rrdtool create sbwinddir.rrd \
 --start 1127253600 \
 DS:wind_direction:GAUGE:600:0:360 \
 RRA:AVERAGE:0.5:1:600

update_rrd_data.php

<?php
// 2010-02-22 - testing simplexml

/*
 - ellwood: http://api.wunderground.com/weatherstation/WXCurrentObXML.asp?ID=MSBELL
 - bel air: http://api.wunderground.com/weatherstation/WXCurrentObXML.asp?ID=KCASANTA122
 - mesa   : http://api.wunderground.com/weatherstation/WXCurrentObXML.asp?ID=MAS714
 - cumbre : http://api.wunderground.com/weatherstation/WXCurrentObXML.asp?ID=MAS303
 - airport: http://api.wunderground.com/weatherstation/WXCurrentObXML.asp?ID=MKSBA
 */

// setup variables

$debug = 1;

$a = array();
$a['ellwood']  = 'http://api.wunderground.com/weatherstation/WXCurrentObXML.asp?ID=MSBELL';
$a['belair']   = 'http://api.wunderground.com/weatherstation/WXCurrentObXML.asp?ID=KCASANTA122';
$a['mesa']     = 'http://api.wunderground.com/weatherstation/WXCurrentObXML.asp?ID=MAS714';
$a['lacumbre'] = 'http://api.wunderground.com/weatherstation/WXCurrentObXML.asp?ID=MAS303';
$a['airport']  = 'http://api.wunderground.com/weatherstation/WXCurrentObXML.asp?ID=MKSBA';

$wdir = "/var/www/redigital.org/sbwindi/xml";

// loop through the locations and update the graphs
foreach ($a as $location => $value) {

 $xml_url = $value;

 $wind_data = simplexml_load_file($xml_url);

 //$wind_data = $xml;

 $wind_mph      = $wind_data->wind_mph;
 $wind_gust_mph = $wind_data->wind_gust_mph;
 if ($wind_gust_mph == "0")
 $wind_gust_mph = $wind_mph;
 $wind_direction      = $wind_data->wind_direction;
 $wind_degrees  = $wind_data->wind_degrees;
 $wind_string   = $wind_data->wind_string;

 //$update_rrd_data_cmd = "/usr/bin/rrdtool update ${wdir}/${location}.rrd \"N:${wind_mph}:${wind_gust_mph}\"";
 //$update_rrd_data = `$update_rrd_data_cmd`;

 $update_dir_data_cmd = "/usr/bin/rrdtool update ${wdir}/${location}_dir.rrd \"N:${wind_degrees}\"";
 $update_dir_data = `$update_dir_data_cmd`;

 $update_graph_cmd = "/usr/bin/rrdtool graph ${wdir}/${location}_d.png \
 -M -v mph -t ${location}-'${wind_string}' -w 320 --height=120 --alt-autoscale-max --lower-limit=0 -s 09:00 -e 20:00 \
DEF:a=${wdir}/${location}_dir.rrd:wind_direction:AVERAGE  \
DEF:b=${wdir}/${location}_dir.rrd:wind_direction:AVERAGE \
DEF:c=${wdir}/${location}_dir.rrd:wind_direction:AVERAGE  \
DEF:d=${wdir}/${location}_dir.rrd:wind_direction:AVERAGE \
DEF:e=${wdir}/${location}_dir.rrd:wind_direction:AVERAGE \
DEF:f=${wdir}/${location}_dir.rrd:wind_direction:AVERAGE \
DEF:g=${wdir}/${location}_dir.rrd:wind_direction:AVERAGE \
DEF:h=${wdir}/${location}_dir.rrd:wind_direction:AVERAGE \
DEF:i=${wdir}/${location}_dir.rrd:wind_direction:AVERAGE  \
DEF:j=${wdir}/${location}.rrd:wind:AVERAGE \
DEF:ba=${wdir}/${location}.rrd:gust:AVERAGE \
DEF:bb=${wdir}/${location}.rrd:wind:AVERAGE \
CDEF:cdefa=i,0,GE,i,22.5,GE,UNKN,INF,IF,UNKN,IF  \
CDEF:cdefb=i,22.6,GE,i,67.5,GE,UNKN,INF,IF,UNKN,IF  \
CDEF:cdefc=i,67.6,GE,i,112.5,GE,UNKN,INF,IF,UNKN,IF \
CDEF:cdefd=i,112.6,GE,i,157.5,GE,UNKN,INF,IF,UNKN,IF \
CDEF:cdefe=i,157.6,GE,i,202.5,GE,UNKN,INF,IF,UNKN,IF \
CDEF:cdeff=i,202.6,GE,i,247.5,GE,UNKN,INF,IF,UNKN,IF \
CDEF:cdefg=i,247.6,GE,i,292.5,GE,UNKN,INF,IF,UNKN,IF  \
CDEF:cdefh=i,292.6,GE,i,337.5,GE,UNKN,INF,IF,UNKN,IF  \
CDEF:cdefi=i,337.6,GT,i,360.99,GT,UNKN,INF,IF,UNKN,IF \
AREA:cdefa#8D85F3:\"North\" \
AREA:cdefb#9FA4EE:\"North East\"  \
AREA:cdefc#F9FD5F:\"East\" \
AREA:cdefd#EACC00:\"South East\\n\"  \
AREA:cdefe#EAAF00:\"South\"  \
AREA:cdeff#EA8F00:\"South West\"  \
AREA:cdefg#00CF00:\"West\" \
AREA:cdefh#6557D0:\"North West\\n\" \
AREA:cdefi#8D85F3:\"\" \
GPRINT:i:LAST:\"Current Direction in Degrees\:%8.2lf %s\\n\" \
AREA:bb#C0C0C0:\"\" \
LINE2:ba#562B29:\"\" \
LINE1:bb#000000:\"\"
";

 $update_graph = `$update_graph_cmd`;

 if ( $debug ) {
 echo "<p>\n";
 echo "<h2> location = ${location}</h2>\n";
 echo "<h3> url = ${value}</h3>\n";
 echo "<img src=${location}_d.png><br>\n";
 echo "<pre>\n";
 print_r($wind_data);
 echo $update_dir_data_cmd . "<br>";
 echo $update_graph_cmd . "<br>";
 echo "</pre></p><hr>\n";
 }
}
?>

index.php

<?php

$base_path = "/sbwindi/";
?>
<html>
<head>
<!-- render the page for iphones well -->
<meta name="viewport" content="width=device-width,minimum-scale=1.0, initial-scale=1" />
<title>iphone bel air knolls wind graph</title>
<style>
@media screen and (max-device-width: 480px){
/*--- iPhone only CSS here ---*/
body{
 -webkit-text-size-adjust:none;
 /* font-family:Helvetica, Arial, Verdana, sans-serif; */
 margin:0;
 padding:0;
}

}
#menubar ul {
 list-style: none;
 padding: 0;
 margin: 0;
}
#menubar li {
 float: left;
 margin: 0 0em;
}

#menubar li a {
 background: url(css-nav.gif) #fff bottom left repeat-x;
 height: 2em;
 line-height: 2em;
 float: left;
 width: 3.9em;
 display: block;
 border: 0.1em solid #dcdce9;
 color: #0d2474;
 text-decoration: none;
 text-align: center;
}

#content {

}
</style>
</head>
<body>
<div id="header">
 <div id="menubar">
 <ul>
 <li><a href="<?=$_SERVER[PHP_SELF]?>?l=airport">airport</a></li>
 <li><a href="<?=$_SERVER[PHP_SELF]?>?l=ellwood">ellwood</a></li>
 <li><a href="<?=$_SERVER[PHP_SELF]?>?l=belair">belair</a></li>
 <li><a href="<?=$_SERVER[PHP_SELF]?>?l=lacumbre">lacumbre</a></li>
 <li><a href="<?=$_SERVER[PHP_SELF]?>?l=mesa">mesa</a></li>
 </ul>
 </div>
</div>
<p>
<div id="content" align="left">
<?php

function display_wind_graphs($location)
{
 echo "<br><br>\n";
 echo "<img src=\"/sbwindi/xml/${location}_d.png\" width=\"320\" alt=\"${location}\">";
 echo "<br>\n";
 echo "<img src=\"/sbwindi/xml/${location}_h.png\" width=\"320\" alt=\"${location}\">";
}

 $location = $_GET["l"];
 switch ($location) {
 case "airport":
 $loc_name = "Airport";
 //echo '<a href="http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=MKSBA"><img src="http://banners.wunderground.com/cgi-bin/banner/ban/wxBanner?bannertype=pws250&weatherstationcount=MKSBA" width="250" height="150" border="0" alt="Weather Underground PWS MKSBA" /></a>';
 display_wind_graphs($location);
 break;
 case "mesa":
 $loc_name = "Mesa";
 //echo '<a href="http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=MAS714"><img src="http://banners.wunderground.com/cgi-bin/banner/ban/wxBanner?bannertype=pws250&weatherstationcount=MAS714" width="250" height="150" border="0" alt="Weather Underground PWS MAS714" /></a>';
 display_wind_graphs($location);
 break;
 case "ellwood":
 $loc_name = "Mesa";
 //echo '<a href="http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=MSBELL"><img src="http://banners.wunderground.com/cgi-bin/banner/ban/wxBanner?bannertype=pws250&weatherstationcount=MSBELL" width="250" height="150" border="0" alt="Weather Underground PWS MSBELL" /></a>';
 display_wind_graphs($location);
 break;
 case "lacumbre":
 //echo '<a href="http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=MAS303"><img src="http://banners.wunderground.com/cgi-bin/banner/ban/wxBanner?bannertype=pws250&weatherstationcount=MAS303" width="250" height="150" border="0" alt="Weather Underground PWS MAS303" /></a>';
 display_wind_graphs($location);
 break;
 case "belair":
 //echo '<a href="http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=KCASANTA122"><img src="http://banners.wunderground.com/cgi-bin/banner/ban/wxBanner?bannertype=pws250&weatherstationcount=KCASANTA122" width="250" height="150" border="0" alt="Weather Underground PWS KCASANTA122" /></a>';
 display_wind_graphs($location);
 break;
 }

?>
</div>
</body>
</html>

« Previous Entries

Powered by WordPress | Designed by Elegant Themes