TheGeekery

The Usual Tech Ramblings

More Scripting to save your day job...

Another issue where scripting easily helps your day job is handling the copious amounts of log files. I handle about 15 web servers in our production environment (that I remember off the top of my head), and quite a few in our dev/stage/qa environments. These generate a lot of log files. Our production environment is the one that is most critical. If the logs fill the drive, the site stops working, something we don’t like happening, and has happened on two separate occasions.

Done...

I think I’m done working today. I’ve got so many projects going on, my brain has shut down. I have 65 tasks in my inbox waiting to be delt with, that doesn’t count the projects I am actively working on, like server consolidation, or an application upgrade. Nor does it count any day-to-day tasks, or the pending phone, switch, and network upgrades. I picked up a new book called Time Management for System Administrators last weekend, so I’m hoping it might help clear some of my pile up, and give me a better handle on all my projects and tasks. That’s something that has always been on my reviews. I’ve at least started tracking where my time is going again using David Seah’s PCEO series.

Oh well… lets see if I can get this thing back in gear… grind crunch grind grind crunch

Code Escape...

As some might have noticed, a few of my recent posts have had weird extra slashes in them (here, and here). I attribute this to my recent upgrade on WP from 2.1 to 2.2, and the autoescape. I’ve managed to reproduce the issue in my development environment, so I’m working on a bug fix for it. As it stands now, if you see a slash in front of a ‘ or a \ or a “, then ignore it (if you plan on copying the code that is).

Update…

I figured out the cause was actually the markdown plugin. Not sure if it was that plugin in specific, or if it was the upgrades to WPs filtering that might have caused it. On lines 88, and 89 in wp-content/plugins/markdown.php it shows the following:

remove_filter('content_save_pre','balanceTags',50);
remove_filter('excerpt_save_pre','balanceTags',50);

I simply removed the ,50 off the function call, and it started working.

Quick Windows Scripting

We have a small issue in one of our products, which will be fixed in the next release. When you login, it generates an “overview” chart (4 of them actually), and writes them to disk, and displays them to the user. The problem comes when they don’t clean up. Because the code first checks if the file exists before writing it, it scans the directory. This would normally be okay, on a physical server, with fast disks. However, these are virtual boxes, with “fake” disks. I/O is terrible on virtual servers, so when there are about 6,000 images in that folder, the box dies a slow and painful death every time somebody logs in. So I had to figure an easy way around it. Linux would have made this task a one-liner.

find . -type f -iname '*.jpg' -amin +1 -exec rm {} \;

This code finds all files with a jpg extension, that was last accessed over a minute ago, then deletes it. Windows on the other hand doesn’t have a nice shell command like this, so I got stuck with vbs, and WMI. I ended up with the following script:

Option Explicit
dim oFileSys, dir, oFiles, oFile, dCreated, fDateInfo, iAge, oFolder

dir = "D:\<folder>\Charts\"

 
Set oFileSys = CreateObject("Scripting.FileSystemObject")
set oFolder = oFileSys.GetFolder(dir)
set oFiles = oFolder.Files

for each oFile in oFiles
  Set fDateInfo = oFileSys.GetFile(oFile)
  dCreated = fDateInfo.DateCreated
  iAge = DateDiff("n", dCreated, Now)
  if iAge > 1 then
    oFile.Delete
  End If
Next

So windows takes my one-liner linux code, and makes it 14 lines (not counting blank lines). I’ve now got this setup to run once a minute, and it cleans up the older images in that folder.

The real definition of Irony

Brought to us this week by Dark Reading’s Firewalled, the real meaning of irony…

Robert Maynard, founder of identity theft protection service LifeLock, has resigned from the company because of allegations that he stole identities… including his dad’s

Further adding to this, he managed to charge $150,000 on a credit card he took out in his father’s name.

Even more irony coming… LifeLock’s method of advertising involves some of their top guys giving out their social security number on billboards, and national television commercials. Here is where more irony kicks in… CEO Todd Davis admits being a victim of identity theft last week when somebody used his social security number from a billboard and got a $500 loan.

Bork Bork

Even the best break every now and again. Earlier today, I gave myself a heart attack by adding a new feed to Google Reader, only to find as I hit the add, that the rest of my feeds vanished. Fortunately, it appeared to not have been just me, as many people hit up the google groups. Google’s official word

basically one group of machines couldn’t get data from another group of machines

I sure hate it when that happens. Looks like they posted the initial outage start at 4:37pm, and had everything back up by about 4:57pm.

Monty Python Backups

I had to chuckle at this. Those that like Monty Python might get a kick out of it. Probably one of the few sales pitches that contains little in the way of a sales pitch. Original discovery was over at Dark Reading’s Firewalled.