perl howto push a hash onto an array

This could also be called how to make an arrays of hashes. The basic idea is to create a list of items that when iterated, returns individual hashes.

use Data::Dumper;
my @array;
push @array, {'key1' => 'value1', 'key2' => 'value2'};
push @array, {'key1' => 'value1', 'key2' => 'value2'};
push @array, {'key1' => 'value1', 'key2' => 'value2'};
print Dumper(@array);

Will give you:

$VAR1 = {
'key2' => 'value2',
'key1' => 'value1'
};
$VAR2 = {
'key2' => 'value2',
'key1' => 'value1'
};
$VAR3 = {
'key2' => 'value2',
'key1' => 'value1'
};

Snazzy!

Did you find this post useful or have questions or comments?  Please let me know!

Posted in How Tos, perl, Programming | 2 Comments

calculate server btu output

This post was updated on 8/29/2008 to clarify a few things

This is a heavily viewed page. Please leave me a comment if this was helpful or if something is missing or confusing.  I would like it to be more comprehensive.

I posted a simplified Watt-to-BTU post if you are not looking for server-specific information

Shouts to Lavrik for getting this started.

To calculate heat output (BTU) of your systems, you need to remember (or read below) your high school electrical class. There are three questions to answer.

  1. How much power am I going to draw?
  2. How much heat will that power useage generate?
  3. How much cooling do I need for that heat?

How much power am I going to draw?

Power is measured in Watts and used in math as the letter ‘P’. The formula for calculating power requires Volts (How much juice you can provide) and Amperes (How hard you suck on the straw).

Power in Watts (P) = Volts (V) * Current in Amperes (I) or:

P = V * I

If you know how many Watts your power supplies can feed and you know how much voltage you have, you can figure out your Amperes.

Take a simple server:

– A server with a 1000 Watt power supply.
– 208 Volt service.
– Running at theoretical maximum load.

P = 1000
V = 208
I = ?

I = P/V or 1000/208 = 4.8 Amperes

So now that you know how much you’re tugging on the grid, find out how much heat that will produce.

How much heat will that power usage generate?

BTUs or British Thermal Units are heat measurements. Generally measured in per-hour increments. In common usage 12,000 BTU/h is considered a Ton. This is important because we cool and heat over time so we need to know how much cooling to throw in to the room per hour.

1 Watt will produce 3.412 BTU per hour

To calculate the BTU/heat output of a system, substitute BTUs for Watts and use the following equation:

BTU/h = (V * I) * 3.412

Using the example server above running full blast in a sealed room with no air moving in and out and no heat loss through the walls you can do the math:

BTU/h = 3.412 x 1000 = 3412BTU/h

How much cooling do I need for that heat?

About 1/3 Ton of cooling is required to cool this system. However, your actual requirements will probably be lower because we can assume you won’t run the equipment at full capacity and there is some energy loss through the walls, ceiling and floors.

Using the techniques above, you can make a simple worksheet to calculate your total theoretical maximum cooling requirements. Don’t forget to take in to account other sources of heat. Ambient building temperature (do you have hot walls from the boiler in the next room?), lights, cooling compressor (it should list it’s heat output) and other equipment.

You can probably undercut your requirements if your equipment does not run at full capacity, but be sure you leave enough room to grow and to keep up in case a cooling unit fails or you experience a period of heavy load and you do use your gear at capacity.

Did you find this post useful or have questions or comments?  Please let me know!

Posted in How Tos | Tagged , , | 18 Comments

Word Press problem Unknown: Releasing SysV semaphore

If you have WordPress installed you may run in to an error that constantly prints something like this:

Warning: Unknown: Releasing SysV semaphore id 58 key 0x152b in request cleanup in Unknown on line 0

This is not an error from WordPress, but from the WP Super Cache Plugin you forgot you installed. The error comes when from the cache directory is not writable.

Change the permissions on the wp-content/cache directory to allow the web user to write and the error will disappear.

The solution is obvious if you check the source code on the page when the error appears. WP Super Cache spits out the error, but it is hidden in HTML comment tags. Your source code will look something like this:

<!-- Dynamic Page Served (once) in 0.297 seconds -->
<!-- File not cached! Super Cache Couldn't write to: wp-content/cache/wp-cache-2876abde8ce3a2aa817c8289ea85486e.html -->

87
<br />
<b>Warning</b>: Unknown: Releasing SysV semaphore id 58 key 0x152b in request cleanup in <b>Unknown</b> on line <b>0</b><br />

Posted in Apache, blogging, How Tos, offsiteHowTo, Software, wordpress | 1 Comment