rblog

The Mini Bottle Gallery

Yesterday at a work seminar held at the Mini Bottle Gallery. Interesting topics, and also fun afterwards to spend some time wandering around in the gallery.

The brothel theme room. As we where told, Nevada being the only state in the U.S where brothels are allowed, each place having its own mini bottle (seems to be a fact http://www.figuralminibottles.net/dug%20nevada/dug%20nevada.shtml)

And then the farmer theme, a John Deere and an International

Using grep to match lines not containing a word

My case was: Match all lines with key purgepolicy, but not containing the word Entirepool


purgePolicy=EntirePool
purgePolicy=FailingConnectionOnly

First I tried to use the ! operator in the regex, but that only causes the error

bash: !": event not found

Solution was to first find all lines with purgepolicy then pipe the result and exclude all results with EntirePool

grep "purgePolicy=" myfile.props | grep -v "EntirePool"

Solution found at http://www.thegeekstuff.com/2011/10/grep-or-and-not-operators/

A good day for regex

^\b(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|-)\s(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b|-)\s(\[.*\])\s"(\w{3,})\s([^.+].+(?=\sHTTP))\s([^\s]+)\s(\d{3})\s(\d+|-)\s(.)\s(\d.)


Extracting a custom Apache log file format. Test it at http://rubular.com/ using

99.99.99.999 88.88.88.88 [12/Jan/2014:09:04:06 +0100] "HEAD /blog/index.php?blog=6 HTTP/1.1" 200 - + 0 myserver.mydomain.local

Blog upgraded

Some advantages of having children waking me up early in the morning, I get to do stuff while they are watching tv. I have now applied the latest patch for B2Evolution. All done in less than ten minutes, download the patch and upload the changed files, smooth!

Windows – Search for files using WQL

Needed a script that searches a the entire disk for Java dump files (core, snap, heap, javacore). In addition the files should not be older than X days to limit the search results. Since I have decided that all scripts I create that is related to server maintenance should be written in Powershell I just had to roll up my sleeves and head on to Google to be inspired. Below you can see the result.


param (
    [string]$logFile = $(throw "******************************`n" + 
			"Custom error:`nMissing required parameter -logFile." +
			"`nSpecify name without full path`n******************************`n`n")    
)
### Uncomment line below to enable debug
#$DebugPreference = "Continue"

# The script will search the d-drive by default
# If d does not exist it will search the c drive 
$drive = "d:"
If (!(Test-Path d:))
{
	$drive = "c:"
	If (!(Test-Path c:)) {
		throw "Did not find d or c-drive, script will cannot continue"
	}
}
$fullLogFile = Join-Path "$drive\temp\" "$logFile";
Start-Transcript $fullLogFile;


####
# Fixed variables
####
$notOlderThanDays = -7 # Change this to whatever amount of time you are looking for

$wmiQuery = "Select * from CIM_DataFile where Drive='$drive' AND FileName Like '{0}' AND Extension='{1}' AND CreationDate >= '{2}'"

# E.g core.20131030.052140.5448.0002.dmp
$core = "core%"
$coreExt = "dmp"

# E.g Snap.20131030.052140.5448.0001.trc
$snap = "Snap%"
$snapExt = "trc"

# E.g heapdump.20131030.052140.5448.0004.phd
$heap = "heapdump%"
$heapExt = "phd"

# javacore.20131030.052140.5448.0003.txt
$javacore = "javacore%"
$javacoreExt = "txt"

$date = Get-Date # Current time
$date = $date.AddDays($notOlderThanDays) 
$creationdate = Get-Date $date -Format G # This format is the format that the WMI commandlet likes

#####
# Start the fun
#####

# Corefiles
$runQuery = [String]::format($wmiQuery,$core,$coreExt,$creationdate)
Write-Debug "Start searching for core files"
Write-Debug $runQuery
Get-WmiObject -Query $runQuery | select Name

# Snapfiles
$runQuery = [String]::format($wmiQuery,$snap,$snapExt,$creationdate)
Write-Debug "Start searching for snap files"
Write-Debug $runQuery
Get-WmiObject -Query $runQuery

# Heapdumps
$runQuery = [String]::format($wmiQuery,$heap,$heapExt,$creationdate)
Write-Debug "Start searching for heap files"
Write-Debug $runQuery
Get-WmiObject -Query $runQuery

# Javacore
$runQuery = [String]::format($wmiQuery,$javacore,$javacoreExt,$creationdate)
Write-Debug "Start searching for javacore files"
Write-Debug $runQuery
Get-WmiObject -Query $runQuery

Stop-Transcript 

How can I return a 503 status in apache without invoking external scripts

This blog post How can I return a 503 status in apache without invoking external scripts basically explains it all, but I had to struggle a bit before I completely understood the needed arguments. So now I have the following lines at the end of the httpd.conf file (not for this domain but a server at work 🙂 ).

Redirect 503 /test503
Redirect 404 /test404
Redirect 501 /test501
Redirect 504 /test504
Redirect 505 /test505
Redirect 502 /test502
Redirect 506 /test506

Note that you have to make sure that mod_alias is enabled

Blog upgraded

Now upgraded from 4.x to 5.0.5. Did not spend much time doing it, easy as always. Need to spend some more time to get the skin up and running as I would like, apart from that all was straightforward.