Racktables 'Free Whole U' patch

Submitted by cjdmax on Mon, 10/03/2011 - 22:16

Racktables is an old-school datacenter rack visualisation script. Doesn't really look like much, but is the (IMHO) most stable solution out there at the moment. The standard rack overview will return the net capacity of a rack, which is not very helpful; we're more interested in how many servers we can add. This function will render how may totally free U are left. The function is modeled on the standard 'getRSUforRack' in functions.php, and is integrated into the racktables interface.php in the same places.

function getFreeUforRack ($data)
        $counter = 0;

        for ($unit_no = $data['height']; $unit_no > 0; $unit_no--) {

                if (    $data[$unit_no][0]['state'] == 'F' &&
                        $data[$unit_no][1]['state'] == 'F' &&
                        $data[$unit_no][2]['state'] == 'F' ) {
        $counter = $data['height'] - $counter;
        return $counter / $data['height'];

At some point I'll probably do some more hacking, and eventually maybe send in a patch (*gasp*)!