diff --git a/content/post/building-a-freebsd-router.md b/content/post/building-a-freebsd-router.md deleted file mode 100644 index 2bd801f..0000000 --- a/content/post/building-a-freebsd-router.md +++ /dev/null @@ -1,19 +0,0 @@ -+++ -date = "2018-03-07T22:35:34-05:00" -title = "Building a FreeBSD router" -menu = "main" -Categories = ["Administration","Homelab","DIY"] -Tags = ["freebsd","homelab","router"] -Description = "Replace pfSense with an Ansible-managed router" -type = "post" -weight = 1 -draft = true - -+++ - -# Building a FreeBSD router - - -## Assemble the hardware - -The project started with two unused C6100 nodes, which had recently been replaced with upgraded models. I pulled out the second CPU, gave them each 4GB of RAM, and attached each of them to a standard power supply. diff --git a/content/post/custom-power-monitoring.md b/content/post/custom-power-monitoring.md deleted file mode 100644 index d125f95..0000000 --- a/content/post/custom-power-monitoring.md +++ /dev/null @@ -1,213 +0,0 @@ -+++ - -class = "post" -date = "2017-09-25T10:00:00-04:00" -tags = ["diy","homelab","buildlog"] -title = "Build a Custom Power Monitoring PDU" -description = "Building a custom power monitoring PDU for fun and profit" -type = "post" -weight = 1 -draft = true - -+++ - -So you've got a homelab. It runs great, you've got dozens of VMs, and a spiffy storage cluster, and the hardware wasn't cheap. But, unless you live in Québec, you probably also care about another big cost sink: power usage. Here in Ontario I'm paying anywhere from 8¢ to 18¢ per kilowatt-hour (kWh) of energy, and with my rack totaling over 1600W normally, the power usage is substantial. The problem, however, is determining how much each device is using. Sure, the UPS can give me an overall power usage figure, and some (newer) devices can report their own power usage, but with 8 servers, 2 routers, 2 switches, and several other devices of significant age, knowing exactly how much each machine is using helps enable even more granular control and monitoring of the power usage. - -The most obvious solution to this problem is what is usually referred to as a "Metered Per-Port PDU" in marketing-speak. Simply-put, it's a large power bar (a Power Distribution Unit or PDU) that contains a network port and a series of current monitors on each port, allowing you to collect information about per-port power usage via SNMP or a WebUI. Most of the big PDU vendors make one of these devices, though with different names - marketing-speak, after all. However they are not cheap. The lowest cost one I could find that matched my common homelab specs of 120V 20A was from Tripp-Lite at $1200 CAD new. That's a pretty penny to pay for power distribution! So instead, in my always-present DIY mindset, I started thinking about building my own. - -# Part 1 - The Theory - -## The basics of power usage and monitoring - -Determing the power usage in Watts of a device is done using a very simple formula: - -``` -P = V * I -``` - -`P` is your power usage, measured in Watts (W). `V` is the voltage of the circuit in Volts (V), and `I` is the current in Amperes (A). For standard home circuits, the voltage is usually 120v (roughly) so calculating the power usage of a device is as simple as multiplying the current by 120 to get a rough wattage value. So with a current of 1A, the power draw would be 120W at 120V. The actual voltage will vary slighly due to other factors (such as voltage droop with a large current), but for most practical purposes you can use 120V to get a reasonably-accurate value. In my case, my UPS outputs the active voltage across the output circuits so I have an exact value to work with. - -A/C power complicates this ideal formula slightly. A/C power works on a fluctuating voltage in a sine wave, which alternates at a specific frequency. In North America, this is 60Hz (cycles per second). What this means it that every 1/60th of a second, the voltage peaks (120V for a standard household circuit as mentioned), and then dips down to 0V before repeating. And as you know from the formula above, when the voltage is 0, the power usage will also be 0, so the effective power usage also looks like a sine wave with a frequency of 60Hz. While you usually don't notice this fluctuation in your daily life, when trying to measure the power of a circuit, it becomes very important to take this into account. The next section goes over how to create a current monitoring circuit for A/C power. - -## An A/C monitoring circuit - -With the theoretical underpinnings of this project out of the way, we can begin looking at devices to measure the current and voltage of an A/C circuit. This project will use two kinds of sensors: current, and voltage. Current sensors will be installed in-line with every socket, while a single voltage sensor will be installed on each circuit. Given the formula above, we'll be able to do some quick math to get the wattage value from these numbers as well. - -The voltage sensors are the simplest - they feature a ~120V transformer which drops the voltage to a more reasonable number, then an OPAMP circuit to filter, regulate, and process that voltage to give a reading. The ones I use in this project are unbranded as far as I can tell, but can be found on eBay as a "Single-phase Voltage Sensor" under `Business & Industrial > Automation, Motors & Drives > Sensors > Other Sensors`. They also have an adjustable output sensitivity that must be calibrated using a reference voltmeter, which we get to later on during the build. With one sensor per circuit we can know the voltage of any outlet in that circuit. - -The current sensors are more complicated. There's a very easy way to measure the current of a circuit, called the 'Hall effect', which relies on the magnetic field of a powered conductor to generate a reference voltage which can then be mathematically transformed into an amperage value. While the effect is far to complicated to explain here ([Wikipedia is a good source](https://en.wikipedia.org/wiki/Hall_effect)), suffice to say that it gives a very accurate measurement of the current through a conductor at any given time. The Hall effect works equally well with both A/C and D/C power. - -Hall effect sensors come in two main types. The first is a wound core through which the hot wire of the circuit is placed. This is a "non-invasive" Hall sensor, and while it works quite well, it is a lot bulkier than the second type. This second type is an in-line Hall sensor, best exemplified by the ACS712-T sensor based on the Allegro chip. This simple 8-pin chip takes the entire current through four of its pins, and via an internal coil and detector, outputs a variable D/C voltage based on the sensed current. To save space as well as cost, since I'll be building the entire PDU from scratch anyways, I went with these sensor chips instead of the "non-invasive" type. - -The ACS712-T comes in three different varieties, each rated for a different current load: 5A, 20A, and 30A. Each variety outputs a slightly different D/C voltage per Ampere of through current, which allows for varying sensitivity up to 30A. For my purposes, the 20A model was both the lowest I could go (5A would not be enough for the larger servers), while the 30A would be overkill and its extremely small D/C voltage variation would have made "long"-distance measuring of the voltage more problematic. - -Now that we know about the two kinds of sensors we'll need, we can proceed to the parts list. - -# Part 2 - The Parts List - -All the following parts can be found online (sensors, Arduino) or at (Canadian) Home Depo (electrical supplies, tools). No part should be optional for this build to ensure safety and code compliance. - -### The power monitoring components - -2x "Single-phase Voltage Sensor" modules (one per circuit) -20x "ACS712-T Current Sensor" modules (one per outlet socket) -1x Arduino Uno -1x Arduino MUX shield (Mayhew Labs) (provides up to 48 analog inputs, enough for all our sensors) -1x Raspberry Pi (or other Linux-capable system) -10+ft Cat5e cable - -### The A/C electrical components - -1x 2"x4"x4' mounting board -10x NEMA-15 dual-socket outlets (Decora-style) -5x 3-gang plastic stud-mount electrical boxes -3x 2-gang plastic stud-mount electrical boxes -20+ft 120V 15-3 ROMEX wiring -2x Socketless GFCIs -2x Switch + Pilot light units -5x 3-gang Decora faceplates (for outlet boxes) -5x Decora single-outlet blanker (for covering current sensors) -1x 2-gang Decora faceplate (for GFCI box) -1x 2-gang traditional socket faceplate (for switch box) -1x Blank faceplate (for voltage sensor box) -2x lengths of rubber cord for power leads -2x 15-20A plugs for power leads -Wire nuts/Marrettes (Yellow size 4x14ga) -Electrical tape -Small wood screws (for securing the boxes to the board) - -### Tools - -Wire strippers (good, 24ga to 12 ga) -Side cutters -Needle-nose pliers (for manipulating wires) -Pliers (for twisting wires) -Screwdrivers (Phillips 2+ and Flat) - -# Part 3 - The Build - -Now it's time to build your own PDU! This is written as a step-by-step guide on how to complete the PDU, going off my experience and featuring pictures of some completed parts during construction. Note that the voltage sensors were added after the main build was complete and are not shown until their step, along with the proper 2x4. - -## Part 3.1 - Installing the boxes - -1. Begin with the 2"x4", and attach the boxes vertically along the short length of the board using the small wood screws. The box order should be, from top to bottom: Voltage (2-gang), 5x Outlet (3-gang), GFCI (2-gang), Switch (2-gang). - -![Empty boxes attached to board](/images/pdu/boxes.png) - -## Part 3.2 - Preparing the wires - -1. Cut roughly 12-inch pieces of 15-3 wire, one for each point that a circuit traverses two boxes, and several pieces for connecting wires. - -2. Strip the outer coating except for at least 4 inches - this leaves coated wire to bridge the boxes. Your measurement might vary. - -3. Insert each piece of wire into its boxes. This step is quite time-consuming; I recommend pushing the outer coating to one end, feedind that end out one box and into the other, and using screwdrivers to prop open the locking clips. Once fed, the inner wires can be pushed or pulled through further using neetle-nose pliers. - -![Wiring between boxes](/images/pdu/box-outer-wiring.png) - -4. Cut the connecting pieces of wire. These should be between 8cm and 12cm long to lead to the power sensors and sockets. Measure carefully to avoid having too-short wires later! For each outlet, you will need 4 hot leads (2 from trunk to sensor, 2 from sensor to outlet), 1 neutral lead, and 1 ground lead. Set aside the sensor-to-outlet wires for _Part 3.4_. - -5. Begin assembling the box wiring. For the ground and neutral connections, strip and twist together the lead wires from each side of the trunk, and the wire to the socket, then cover with a marrette. For the hot connections, strip and twist together the lead wires from each side of the trunk, and the two wires to the sensors, then cover with a marrette. Push the marretted bundles down towards the bottom of the box. Use the needle-nose pliers to tweak the shape and position of each lead wire to accomodate the sensors and sockets later, and strip off 1cm of insulation from the end of each sensor lead wire. - -![Lead wiring](/images/pdu/box-inner-wiring.png) - -6. Install the GFCI outlets, since these are static. Consult the GFCI documentation for details on the wiring. - -![Installed GFCIs](/images/pdu/gfcis.png) - - -## Part 3.3 - Assembling the sensor modules - -1. Recycle three pieces, each approximately 2 inches in lenght, of ROMEX outer coating to act as insulating buffers between the sensors. - -2. Attach a sensor unit to one side of each insulating piece using Cyanoacrylate glue, and let dry. - -3. Glue each sensor module to the next, and the fourth module to the outside of the last piece, producing a chain of isolated sensors, and let dry. - -![A sensor module](/images/pdu/sensor-module.png) - -## Part 3.4 - Assembling the outlets - -1. Break the hot bridge between the two sockets on the outlet using needle-nose pliers. This isolates the two hot screws and therefore the two sockets from each other, allowing each to be monitored separately. - -2. Attach a piece of hot lead wire to each hot screw of the outlet. Strip 1cm of insulation off the far side, and fold under the socket. - -Note that the lead lengths must vary for the sensor-near and sensor-far outlets. - -![Outlet-side wiring](/images/pdu/outlet-wiring.png) - -## Part 3.5 - Installing the outlets - -1. Begin installing each socket into its box, ensuring the sensor leads are clear of the marretted bundles in each box. The hot leads from the trunk to the sensors should each be on the right of the leads from the switch when the sensor gang is closest to you; use needle-nose pliers to position them correctly before proceeding. - -2. Attach the neutral and ground leads to the outlet. - -3. Screw in the outlet, allowing the hot and neutral leads to compress into the box and ensuring the hot leads remain in position. - -![Installed outlet wiring](/images/pdu/ready-sensor-leads.png) - -## Part 3.6 - Wiring up the sensors - -1. Cut five lengths (one per outlet box) of CAT5e cable to act as sensor leads. Conveniently, with 4 pairs, we have four sensor data wires, two power wires, and a spare pair should one of the others fail, so only a single cable per box is needed. Each length should be shorter, leading to all 5 ending at the same height out the top box. - -2. Feed the cables through the boxes on the sensor side, leaving plenty of slack. Bundle the upper ends together for later. - -![Data cables in the boxes](/images/pdu/data-cables-box.png) - -![Data cables bundled](/images/pdu/data-cables-bundled.png) - -3. Install the sensor modules. Use the needle-nose pliers to ensure everything is aligning correctly, and trim wires as necessary. I found inserting the modules at 45-degrees then gently bending the wires back down was easiest. - -![Single installed sensor module](/images/pdu/installed-sensor-module.png) - -![Several installed sensor modules](/images/pdu/installed-sensor-modules.png) - -4. Wire up female leads to the sensor cables. Connect the + and - power wires to their respective bundles to distribute power to each module. - -![Power leads](/images/pdu/sensor-power-leads.png) - -5. Wire up a lead to each sensor wire, taking careful note of and/or standardizing on your colours; this makes figuring out which lead is which sensor much easier later. Wrap the connections in electrical tape for safety and rigity, then connect the leads to each sensor. - -![Attached leads](/images/pdu/sensor-attached-leads.png) - -6. Cover the sensor gang with a blanker and install the faceplate. - -![Blanker installed](/images/pdu/blanker-installed.png) - -![Faceplate installed](/images/pdu/faceplate-installed.png) - -## Part 3.7 - The lead cables - -This part has no pictures because I forgot to take them! - -1. In the bottom box, wire up the switch and pilot light combo to each circuit. Feed in each length of rubber wiring, and connect it to its respective circuit's switch. Bind together the neutral connections from each pilot light and the two cables, and pass the hot line through the switch. Cover the box. - -2. Wire up the plug to each length of wire to form the source of each circuit. - -## Part 3.8 - The voltage sensors - -After the fact, having built the PDU with support for current readings only, I regretted not adding voltage sensors as well, to provide the full suite of power monitoring and a true wattage value like I set out to do. - -1. Position the incoming wires to allow the module to fit vertically in the box. Strip off 1cm of insulation from each wire. - -y. Install each circuit's voltage sensor between the hot and neutral leads, being careful to keep them as far apart as the sensor allows. - -3. Connect up the voltage sensor leads, similar to the current leads. To exit the box I cut a notch as these wires were short, but they can be fed more cleanly out the back of the box using longer wire lengths. Both ends should be female to connect to the Mux shield pins. - -## Part 3.9 - The Mux shield - -![MuxShield](/images/pdu/mux_shield.png) - -The Mayhew Labs MuxShield provides an additional 48 analog I/O inputs for an Arduino. In this case, I use it to allow all the individual sensors to be read independently, including the voltage sensors. - -1. Connect each lead cable to one of the Analog inputs on the MuxShield. - -# Part 4 - The Software - -## Part 4.1 - The Arduino - -## Part 4.2 - The Raspberry Pi - -## Part 4.3 - Check MK (if you use it) - -# Conclusion - diff --git a/content/post/homeproduction-part-1.md b/content/post/homeproduction-part-1.md deleted file mode 100644 index 7a6a3fa..0000000 --- a/content/post/homeproduction-part-1.md +++ /dev/null @@ -1,90 +0,0 @@ -+++ -class = "post" -date = "2017-04-02T14:47:09-04:00" -tags = [] -title = "Homeproduction, part 1: Hardware" -type = "post" -weight = 1 -draft = true -+++ - -[Part 1](/post/homeproduction-part-1/) - [Part 2](/post/homeproduction-part-2/) - [Part 3](/post/homeproduction-part-3/) -``` -Why do you do this? -Because I want to. - - The Matrix, -ish -``` - -## Homelab? Homeproduction! - -If you're reading this and have no idea what a 'homelab' is, it's a hobby for system administrators whereby we set up our own "lab" environments at home, to play around with and generally learn on. Some are small, just a home server and a switch, and some are basically mini-datacenters. Mine's closer to the latter. - -In my case, I strongly value service independence and control of my own data. I put little trust in large corporate Internet companies, from privacy, security, and reliability perspectives, and would simply rather host my data myself. For this reason, I've spent the last 4 years building up my "homeproduction": a homelab used day-in day-out for my data needs, along with my family and friends. - -This is the first in a series of posts describing my lab as it exists today in April 2017. There will be three sections: Hardware, Storage, and Services. - -## From the bottom up: Power - -The homelab really begins with power - no electricity, no homelab! For optimal efficiency and to prevent overloading, my lab has a dedicated 20A 120V circuit run to it. The story of this circuit is a little funny: my box has a fixed number of fuses, and was full for as long as I could remember. But I never noticed one circuit was dedicated... to the doorbell! Goodbye fixed doorbell, hello homelab circuit! - -![Wall-mounted 20A outlet](/images/homelab/power-wall-plug.png) - -From the surface-mounted 20A plug, the single power input to the rack goes into an APC Smart-UPS 2200 RM XL, which provides 2200VA of protecting for approximately 10 minutes at 2/3 load. With my current contingent of gear this is the perfect size and has kept the system going through several small power outages. - -Power is distributed through the rack on two power bars, which provide A/B power feeds to dual-PSU gear. One of these distribution bars also connects to a second, smaller power bar for wallwarts. The goal with the dual distribution bars would be to eventually obtain a second UPS and provide truly redundant power (from the wall at least - it's a house!), but so far I haven't seen any need to (for the aforementioned reason!) - -![APC Smart-UPS](/images/homelab/power-ups-bars.png) - -All-told, the rack today uses at its peak about 1500W as reported by the UPS, averaging closer to 1300W. - -![Power usage graph, one week](/images/homelab/power-usage-graph.png) - -## The Rack and the Room - -The rack itself is an evolution from a few previous designs, including a large Lack-based setup and a smaller audio rack. In its current form, the rack is made primarily of 2x4s, pannelboard, and angle iron for rails, sitting atop six large castors to allow for easy movement. The whole rack was built in a weekend, and provides space for 2x 4U servers, 4x 2U servers, 2U for the router, and 2x 1U for switches, with patch panels at the very top. - -![Rack bottom](/images/homelab/rack-bottom.png) - -The "rails", made of angle iron, can be easily repositioned with a screwdriver (motorized, or it really hurts) and a level, allowing almost infinite reconfiguration of its 26U of space. At the bottom, the UPS rests on the base. - -![Rack front](/images/homelab/rack-front.png) - -The entire rack is enclosed with panelboard, to keep the heat in and directed up and out. - -![Rack outside](/images/homelab/rack-outside.png) - -At the top rear left of the rack is an opening containin 5x 120mm fans which direct hot air from the back of the case out. The air is then directed into a square duct made of rigid cardboard, running parallel lengthwize to the rack about 1/2 of the length along a wooden shelf. At the end of this duct is a powerful 120mm fan, which exhausts the hot air in one stream back into the room. Directly above the duct and exhaust is a window - in the winter it can be opened slightly to controll the exhaust tempoerature (and hence the room temperature), and in the summer I plan to attch the outlet of the duct to a flexible duct pipe, which can then be cleanly vented out the window. This setup does a fairly good job of keeping the room cool as long as the panels on the rack are shut. - -![Rack exhaust port](/images/homelab/rack-exhaust-port.png) - -![Rack exhaust duct](/images/homelab/rack-exhaust-doct.png) - -The room itself is actually my furnace room - an unfinished floor but finished walls and ceiling. To control the noise, the entire outer wall of the room is covered with egg cartons. While these do not abosrb sound, they reflect high-pitched, irritating frequencies and help cut down the piercing shreek of the smaller fans. While the rack is still noticible in the other room (a din like a table fan), it is not the shrieking sound inside the room, which I consider a success. - -![Egg carton wall](/images/homelab/room-egg-cartons.png) - -## The Gear - Networking - -But enough about the rack, now for the interesting bits! - -The core network consists of a router and two switches. The router is a whitebox server with an Intel E3-1240 CPU, 4GB RAM, a Supermicro X9SCL motherboard, and an ancient WD Raptor, running pfSense 2.3. The router features four Ethernet ports - 2x 1Gbps to the first switch, 1x 1Gbps management port to the second switch, and 1x upstream port to the DSL modem. - -![Router front](/images/homelab/router-front.png) - -![Router back](/images/homelab/router-back.png) - -The first switch is a Quanta LB6M, featuring 24x 10Gbps SFP+ ports, 4x 1Gbps ports, and 2x 1Gbps management ports. This switch connects the router and second switch on the 1G ports, as well as a management port from the second switch. The servers all connect to the SFP+ ports via pairs of bonded links, providing resiliency and slightly better throughput. Dual power supplies also balance the ~130W the switch draws across both power bars. - -![First switch front](/images/homelab/first-switch-front.png) - -The second switch is a D-Link DXS-3227, featuring 24x 1Gbps ports, plus a 10Gbps XFP port that I've never gotten working. The switch connects back to the first switch, and provides all 100Mbps/1Gbps access ports to clients and non-server devices, including the management network. The management ports from the router and first switch both terminate on this switch. - -![Second switch front](/images/homelab/second-switch-front.png) - -## The Gear - Environmental Monitoring - -The rack features a - -## The Gear - Servers - -There are three classes of servers in the cluster: the management and backup server, the hypervisors, and the Ceph storage. diff --git a/content/post/open-core-is-cancer b/content/post/open-core-is-cancer.md similarity index 100% rename from content/post/open-core-is-cancer rename to content/post/open-core-is-cancer.md diff --git a/content/post/post-rot-and-you.md b/content/post/post-rot-and-you.md deleted file mode 100644 index 93f03c5..0000000 --- a/content/post/post-rot-and-you.md +++ /dev/null @@ -1,11 +0,0 @@ -+++ -Categories = ["Philosophy"] -Description = "After 15 years of Google, post-rot abounds the Internet. Here's what I do to help." -Tags = ["x-y problem", "post-rot", "internet"] -date = "2016-11-19T00:54:55-05:00" -menu = "main" -title = "Post-rot and you!" -draft = true - -+++ - diff --git a/content/post/support-vampires.md b/content/post/support-vampires.md deleted file mode 100644 index 1cb23ae..0000000 --- a/content/post/support-vampires.md +++ /dev/null @@ -1,14 +0,0 @@ -+++ -Categories = ["Philosophy", "FLOSS", "Community"] -Description = "Everyone's seen one, but might not know what to call them. Here's what to do." -Tags = ["support vampire", "help vampire", "support", "floss"] -date = "2020-03-24T00:00:00-04:00" -menu = "main" -title = "Support Vampires a.k.a. Help Vampires, and How to Fight Them" -draft = true - -+++ - -## The Psychic Vampire - -