Find the LDAP Server

Dig is the roxen

<code>

dig _ldap._tcp.search.domain

</code>

This is handy if you’re trying to figure out what the directory server for exchange is if you’re configuring entourage on the mac.

Da Web, TechJunk

America: Eleutherophobians unite!

http://techpresident.com/blog-entry/birthers-nation-how-obama-birth-certificate-issue-playing-online

The news that American southerners are the most likely to question whether President Obama is actually a native-born citizen got a lot of attention last Friday, when a Research2000 survey on that question was released by DailyKos. Eleven percent of all Americans apparently do not believe Obama was born in the United States, but 23% of southerners (compared to roughly 5% of people from the other regions of the country) share that belief. I thought it would be interesting to see what various trend-culling tools might add to this picture.

A look at Google Trends is certainly illuminating. The top ten states where people are searching on the phrase "Obama birth certificate" are:
1. Louisiana
2. Mississippi
3. Colorado
4. Oklahoma
5. Alabama
6. Tennessee
7. Arkansas
8. Missouri
9. South Carolina
10. North Carolina

Geez people… And to think two states on this list are places I’ve considered living or have lived previously…

Get it together America!

The Standard Biz

Finding Replacing Filenames & text inside files using perl

A few “Bash Tricks” for the peeps

First up:

Find & replace filenames

This finds file that match Somethinghtml.html and renames to Something.html (HTTP Track users will recognize these two examples as fixes to common naming problems when scraping a site.) Note you can change the mask of files searched by changing the find mask at the end of the line.

<code>

perl -p -i -e ’s/(.*)html\.html/\1.html/g;’ `find ./ -name ‘*.html’`

</code>

Then Find & Replace text inside of files:

This finds things that have been incorrectly prefixed with dev.mistcat.com and removes that prefix so that this 2112.js file can load from a remote domain correctly.  Note you can change the find mask at the beginning to restrict or un-restrict your searched files for text replacement.

<code>

find . -name ‘*.html’ | perl -pi -e ’s/http:\/\/dev\.mistcat\.com\/(www\.dwin1\.com\/2112\.js)/http:\/\/\
1/g;’

</code>

Coding, Linux / Unix / CLI

Ubuntu Apache Tuning

So I recently needed to do a little quick performance tuning at work on one of our ubuntu server installs.  I’ve been using some of the wisdom found here to refresh myself on the basics, and I wrote a quick little one line awk script to give me the total amount of memory being used by apache at any given time, and the average process size for apache at that moment as well.  I figured someone else might get some use out of it and decided to post it: (the following should all be on one line, but hey)

<code>

ps -ylC apache2 –sort:rss | awk ‘{x += $8;y += 1} END {print "Apache Memory Usage (MB): "x/1024; pr
int "Average Process Size (MB): "x/(y*1024)}’

</code>

 

So the command ‘PS’ is going to give us process information for any process containing the apache2 text, I’m going to sort it by the physical/resident memory that process is taking up.  I then feed that data into Awk and on Ubuntu, the 8th column in is the memory info.  I then total that up in my x variable and total the number of processes in my y variable and then print those out nicely out to the terminal.  (Incidentally you could use this in a cron job to create a sort of very ghetto/basic apache historical tracking if you wanted to see apache memory usage over time)

So as I understand it, your MaxClients setting in apache should follow this formula:

MaxClients ≈ (RAM – size_all_other_processes)/(size_apache_process)

So with my handy script you now have the size_apache_process variable, you probably know your boxes total ram, (‘free –m’ will tell you if you don’t know) and I’ve been estimating ‘size_all_other_processes’ as about 20% of total ram.  It occurs to me that I could probably write a script to total up the size of all other processes as well, but I’ll have to investigate that a little bit…  Anyhow it’s pretty quick to figure out a good MaxClients setting using this script!

Linux / Unix / CLI, TechJunk, The Standard Biz