Archive for April, 2009

In praise of JSLint

Short post here, just wanted to give some praise to the JSLint website for offering an incredibly useful tool. I recently saved me a lot of time debugging some ExtJS code, so next time you can’t find that missing comma or extra semi-colon in your minified JS code, give it a shot. http://www.jslint.com

Tags:

Change control generator

Perhaps you have found yourself in the middle of planning a large maintenance that involves many servers and many clients and all of the work is the same and you noticed that you don’t want to write a change control document for each client or each server.

Well, here’s some code that will write one for you. Just fill in your array of clients/hosts and then the content of the change control document – then run the file with PHP and you’ll have your change control docs all ready to go.

Note that all blank lines have been removed because wordpress’ code tag sucks and breaks on empty lines in code

< ?php
function write_cr($content,$client,$hostname,$today) {
$FULLPATH="/tmp";
$filename=("$FULLPATH/cr/$client.$hostname.$today.txt");
if (!file_exists("$filename")) { touch("$filename");}
if (is_writable($filename)) {
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
else {
if (fwrite($handle, $content) === FALSE) {
echo "Cannot write to file [$filename]";
exit;
}
}
fclose($handle);
}
else {
echo "The file [$filename] is not writable.";
}
}
function crfile($client,$hostname,$today) {
$contents="
CHANGE CONTROL DOCUMENT FOR: $client-$hostname-$today
Date: $today
Name: $client
Phone:
Email:
Downtime Required:
Summary of Changes:
Reason for change:
Testing done prior to change:
Reveral plan:
Triggers for reversal:
Reversal plan time requirement:
Test Plan:
Who will test the changes:
Who will sign off on the changes:
";
write_cr($contents,$client,$hostname,$today);
}
$today = date('d');
$list = array(
"client1" => "hostname1",
"client2" => "hostname2");
foreach($list as $k => $v) {
$client = $k;
$hostname = $v;
crfile($client,$hostname,$today);
}
?>

Tags: ,

A quick rundown of per-thread buffers

I saw something interesting today when helping out someone on the #mysql IRC channel. It was a cnf file that was designed to destroy a server. Before I get into the why-not, here are the goods:

...snip...
read_buffer = 128M
join_buffer = 128M
key_buffer = 512M
max_allowed_packet = 200M
thread_stack = 192K
thread_concurrency = 8
thread_cache_size = 64
query_cache_limit = 256M
query_cache_size = 256M
table_cache = 8192
query_cache_type = 1
sort_buffer = 128M
record_buffer = 128M
myisam_sort_buffer_size = 128M
thread_cache = 64
max_user_connections = 500
wait_timeout = 200
max_connections = 4096
tmp_table_size = 1000M
max_heap_table_size = 1000M
...snip...

Now, you may ask why these settings are bad. I will tell you. First, an equation for calculating per-thread buffer memory usage.

total per-thread buffer usage = (read_buffer_size + read_rnd_buffer_size + sort_buffer_size + thread_stack + join_buffer_size + binlog_cache_size) * max_connections

So in this case we have the following memory usage in per-thread buffers. Any buffers or settings not specifically mentioned above take the MySQL defaults.

1537GB = ( 128M + 256K + 128M + 192K + 128M + 32K) * 4096

Yes, you read that correctly. This server is setup to allow 1537GB of ram usage on the per-thread buffer level. This server only has 4GB of ram. You tell me what would happen if 4096 connections were made and all of them, or even just a few of them, tried to max out their available buffer space. So folks, remember to always check your per-thread variables and make sure you’re not over allocating your memory resources.

Tags: , ,

Note to Oracle on MySQL

Simple and short: Please do not screw things up. We like MySQL, millions of people like MySQL. Keep it alive and healthy and we’ll love you for it. That is all.

Tags: ,

Monitoring MySQL with SNMP

A nice write up here: http://www.masterzen.fr/2009/04/13/introducing-mysql-snmp/ “It’s a Net-SNMP perl subagent that connects to your MySQL server, and reports various statistics (from show status or show innodb status, or even replication) through SNMP.”

This might find its way into Kontrollbase soon…

Tags: , ,

NPR helps out with Kontrollbase

Shain Miley from NPR has recently become a contributor to the Kontrollbase project. He’s been knocking out some of the bugs in the last release and adding good features as well – socket support for the client, server state checks, and many other nice additions. His code will be included with the next release, but if you’re impatient you can grab the latest release from subversion here: http://code.google.com/p/kontrollbase/source/checkout

Tags: ,

Why be vendor specific?

I just read about the release of Honey Monitor for MySQL. I read through the features. I looked at the screenshots. Then I read about the licensing. Then I read about the fact that it only runs on windows XP or Vista. So, my questions for the ages…

1. Why, in this age of multiple OSes battling each other for market share, would you write an application that is OS specific? Every app should run in a vendor neutral web browser unless there’s a really really good reason. Monitoring software, are you kidding? Monitoring software must be vendor neutral and web-based. I will never use anything that ties me to windows or linux or osx, it has to be cross platform. End of story.
2. Why, when MySQL is so heavily used on Linux and Solaris, would you write an application for MySQL that can only be run on Windows? Every MySQL DBA that I know uses either OSX or Linux or OpenSolaris for a desktop. Making a MySQL related application use windows seems like a slap in the face to me.
3. Why, in the age of Open Source, would you create a product with so many different tiers of licensing? Call me an obnoxious open-source advocate, but I firmly believe that ALL software should be free. If you use MySQL and you use Linux – you best be contributing back with 100% free code. To do otherwise, in my eyes, is selfish. It also drives away possible users and testers that might have helped make your product a success.

All of that ranting aside, I think Honey Monitor looks like a great product. The features are impressive and the screenshots look great. The problem is that I’ll never get to use anything other than the free version – and then not even that because it’s for windows and I am not using windows. However, if you don’t care about the points I just mentioned, go ahead and try out the app and let me know what you think. I would actually be interested to know.

Tags: , ,

Kontrollbase is back on Google Code

Due to a large amount of hassle for simple things like adding new group members, I’ve moved the codebase back to Google Code. I really liked to the features of Fedora Hosted but I prefer to have the management tools simple and fast. Here’s the link: http://code.google.com/p/kontrollbase/

Tags: ,

Kontrollbase 2.0.1-beta revision 21 is available

You can see the change list here: https://fedorahosted.org/kontrollbase/timeline
You can download the new version here: http://kontrollsoft.com/software-downloads

Tags: