Add Scroogle to your search area in Firefox 2.0 Install the 'Scroogle Scraper' search plugin.

September 2010


FusionChart’s FusionMaps product allows remote updates but when the map gets new data, it flickers due to a complete redraw. Lame. The forums say we should just live with it, but that’s lazy and stupid. Here’s my solution, first with some javascript in the head:

var underMap="map2Id";
 function updateMap(){
         var mapObj = getMapFromId(underMap);
         mapObj.setDataURL("Data.xml.php?hud="+(new Date()).getTime());
         if (underMap=="map2Id")
         	underMap="map1Id";
         else
         	underMap="map2Id";
      }
function UpdateThenToggle()
 {
 	updateMap();
        setTimeout(function(){toggleLayers();}, 7000);
 }
 
 function toggleLayers()
 {
 	var underlayer=document.getElementById("map1div").style;
	if (underlayer.zIndex == 3)
	{
		underlayer.zIndex=1;
	}
	else
	{
		underlayer.zIndex=3;
	}
	UpdateThenToggle();
 }
 
function doRedirect(){
setTimeout(function(){UpdateThenToggle();}, 1000);
}

and then in the body:

<body onLoad="javascript:doRedirect();" >
...
		<div style="height:400px;width:750px">
		<div id='map1div' style="position: absolute;z-index:3;" >
		</div>
		<div id='map2div' style="position: absolute;z-index:2;" >
		</div>
		</div>
		  <script language="JavaScript">
		      var map1 = new FusionMaps("Maps/FCMap_USA.swf", "map1Id", "750", "400", "0", "1");
		      map1.setDataURL("Data.xml.php");
		      map1.render("map1div");
			  var map2 = new FusionMaps("Maps/FCMap_USA.swf", "map2Id", "750", "400", "0", "1");
			  map2.setDataURL("Data.xml.php");
			  map2.render("map2div");
 
		   </script>

Maybe you have some backup job on a Windows box that creates a full backup file (.bak) as well as incremental backups (.diff). Every time you create a new .bak file, you can delete the previous .bak files as well as the previous .diff files. It would be nice if your backup job just emptied the directory before creating the new .bak file, but if that’s not an option, the following vbscript will do the job:

objStartFolder = "G:\SQLMaint\backup"
Set WshShell = WScript.CreateObject("Wscript.Shell")
Set FSO = Createobject("Scripting.FileSystemobject")
Set folder = FSO.getfolder(objStartFolder)
Set files = folder.files
lastCreationDate="12/12/1912 12:12:12 PM"
mostRecentCreationDate=lastCreationDate
mostRecentFilename=""
 
'Find most recent .bak file
For Each file In files
	If LCase(Right(file.Name, 3)) = "bak" then 
		if DateDiff("d",lastCreationDate,file.DateCreated) > 1 Then
			mostRecentCreationDate = file.DateCreated
			mostRecentFilename=file.Name
		End If
		lastCreationDate=creationDate
	End if
Next
 
Wscript.Echo "The most recent .BAK file is: "& mostRecentFilename & " created on " & mostRecentCreationDate
Wscript.Echo
Wscript.Echo "You can delete anything older than the most recent .BAK file, including .DIFFs"
Wscript.Echo
Wscript.Echo "Deleting files older than the most recent BAK: "
Wscript.Echo
For Each file In files
	if DateValue(mostRecentCreationDate) > DateValue(file.DateCreated) Then
		Wscript.Echo file.name & " created on "& file.DateCreated
		FSO.DeleteFile(objStartFolder & "\" & file.name)
	Else
		Wscript.Echo "NOT: " & file.name & " created " & file.DateCreated
	End If
Next

check_nt says you can check Disk Usage through the following:

Syntax: check_nt -H  -p  -v USEDDISKSPACE -l  [-w  ] [-c ]

    * drive letter should be only one character.
    *  and  : thresholds between 1 and 100.

Example:
./check_nt -H 192.168.1.1 -p 1248 -v USEDDISKSPACE -l C -w 80 -c 90

Here’s how I’m using it:

/usr/lib/nagios/plugins/check_nt -H 10.1.1.101 -p 4711 -v USEDDISKSPACE -l G -w 70 -c 80
G:\ - total: 1397.12 Gb - used: 1013.97 Gb (73%) - free 383.15 Gb (27%) | 'G:\ Used Space'=1013.97Gb;977.99;1117.70;0.00;1397.12

Do you see that it’s not working? the G drive is 73% full, and I specified it warn me at 70%. That’s lame. I coded up a BASH wrapper script to check the % used and warn or return critical as needed:

/usr/lib/nagios/plugins/wrap_check_nt.sh -H 10.1.1.101 -p 4711 -v USEDDISKSPACE -l G -w 70 -c 80
WARNING - G:\ - total: 1397.12 Gb - used: 1014.08 Gb (73%) - free 383.04 Gb (27%) | 'G:\ Used Space'=1014.08Gb;0.00;0.00;0.00;1397.12
#!/bin/bash
 
while getopts ':H:p:v:l:w:c:' OPT; do
  case $OPT in
    H)  HOST=$OPTARG;;
    p)  PORT=$OPTARG;;
    v)  REMOTECOMMAND=$OPTARG;;
    l)  DRIVELETTER=$OPTARG;;
    w)  WARNING=$OPTARG;;
    c)  CRITICAL=$OPTARG;;
  esac
done
 
REMOTE=`/usr/lib/nagios/plugins/check_nt -H $HOST -p $PORT -v $REMOTECOMMAND -l $DRIVELETTER`
REMOTEVALUE=`echo $REMOTE|awk '{print $10}'|perl -p -e 's/[\(\)%]//g'`
 
  err=0
  if (( $REMOTEVALUE >= $CRITICAL )); then
    err=2
  elif (( $REMOTEVALUE >= $WARNING )); then
    err=1
  fi
 
  if (( $err == 0 )); then
      echo -n "OK - $REMOTE"
      exit "$err"
  elif (( $err == 2 )); then
      echo -n "CRITICAL - $REMOTE"
      exit "$err"
  elif (( $err == 1 )); then
      echo -n "WARNING - $REMOTE"
      exit "$err"
  fi

Send to a friend * Print this page * Join the club * Talk with my robot * Advertise here * Search this Site * Donate * Link to me


Web hosting by Utah Hub *  Powered by CreativeTap *  In association with Segomo
Unless otherwise noted, Copyright 2004-2013, Ryan Byrd. All Rights Reserved.
Ryan Byrd dot net -- probably the coolest site in Utah