Nagios – Checking DHCP Leases with Ubiquiti EdgeRouter

Here’s a small script I threw together to check the number of DHCP leases on an Ubiquiti EdgeRouter. It’s made for use with Nagios.

It basically connects to the router via SSH, executes show dhcp leases and returns OK, WARNING, or CRITICAL depending on how many leases exist. See the comments for a little bit of documentation.


Continue reading Nagios – Checking DHCP Leases with Ubiquiti EdgeRouter

PVC Irrigation For Raised Garden Bed

Summer is upon us here in Denver and it’s time to start planting vegetables.

This year, Niki and I decided to try out a raised garden bed. I decided to go with a simple, 3 foot by 8 foot box, made out of 2″x8″ lumber. Below is the quick plan I drew up:

Raised Bed Plan

This is just a simple garden box that allows 8ish inches deep of soil. Lag screws hold the sides together, and the soil will keep the box from moving.

Next up, we needed an easy way to water the plants. Denver is in an arid climate, and we don’t want to waste water. The best thing to do is to get the water right to the roots of your plants. For that, we turn to a system developed in Utah.

Jeffrey Banks, out of Juab County in Utah, put together a wonderful document detailing a system they’ve been using. The system is inexpensive and very flexible.

Bed With PVC

The ingredients:

  • 7 feet of 3/4″ PVC
  • 21 feet of 1/2″ PVC
  • Six 3/4″x3/4″x1/2″ Tee fittings
  • 3/4″x1/2″ Elbow
  • Seven 1/2″ caps
  • Two 3/4″ PVC Street Elbows
  • 3/4″ Ball Valve
  • 3/4″ PVC to Hose fitting

The 3/4″ PVC runs along one of the long sides of the box. I cut it into seven 12″ sections. The 3/4″x1/2″ elbow is glued on the very end, with each section separated by the tee fittings. These fittings are glued. At the far end, a pair of street elbows are attached to a ball valve and a garden hose fitting.

Valve + Hose

The ball valve helps control the rate of flow. Eventually, as more beds are added, they will be interconnected and the ball valves can control where water goes as needed.

The short pipes are called laterals, and are made from the 1/2″ PVC. One pipe is usually sufficient to water two rows. I follows the directions from the Juab County system document, and drilled 1/16″ holes every 6 inches for rows beans and other stuff. For the squash, I grouped three holes together, 2 inches apart right next to the mounds. Since these are spread further apart, only one later is used for each row.Water Holes

Controlling the flow rate is essential. This is where the ball valve comes in really handy. I can fully open the spigot at the house, then use the ball valve to restrict the flow going into the pipes. As you can see above, the system is less drip and more trickle irrigation.

Time will tell how well the system works. Based on the results seen in Juab county though, I have a good feeling that it will work well.

HP MSM Access Points and Cacti

I love graphs. Just ask my wife. Any sort of metric I can get my hands on, I try to graph and display visually.

One of my favorite tools for graphing data is Cacti. As such, if it can be queried via SNMP, I want it on Cacti.

I have an HP MSM430 access point that I use in our home. It presents quite a bit of data via SNMP. I’ve developed some Cacti templates that can be used to graph average SNR for a station (a station is an SSID on an individual radio), as well as the number of users connected to a station.

Find it on github:

avg-snr num-users

Comcast IPv6 with Ubiquiti EdgeRouter

With the latest release of firmware (1.6) for Ubiquiti EdgeRouter devices, you can now use DHCPv6-PD with only modifying the device config.

It works with Comcast’s IPv6. Here’s my config to get you going:


Universal Media Server, Headless, on CentOS 7

Universal Media Server originally started as a fork of PS3 Media Server. It is a great DLNA server for Linux. It has a large device support among other features. In our home, it is used to stream from our media server in the basement to the PS3 in the living room.

The following steps will get it installed in a headless fashion on CentOS 7. They should also be easily adapted for any recent versions of Fedora. The biggest difference from this guide and others I’ve seen is I provide a service file for systemd.

Install Prerequisites

  1. Install EPEL’s and Nux’s repositories. Visit each project’s website for the latest release, but the following should work:
  2. Install programs needed for transcoding:
  3. Install Java. You have two choices here. Install the appropriate openjdk package, or get the latest RPM from Oracle’s website. I’ve found Oracle’s java release works best with UMS.

Install the files for UMS

  1. Download a tarball of the latest version from UMS’ website to your home directory.
  2. Extract the tarball, and move it to /opt. Create a symlink from /opt/ums-#.#.# to /opt/ums. This allows you to add new versions and just replace the symlink, preserving the old installs if you want.
  3. Copy the config files to /etc/ums. This makes more sense than keeping them with the UMS files.
  4. Create a user, ums, to run the UMS application under. This user will need permissions to read the media files, as well as write permissions to the folder for the config files and the application files. Don’t set a password, use /opt/ums for the home directory, and use /sbin/nologin for the shell.
  5. Now, open up /etc/ums/UMS.conf in your text editor. Go through and adjust the parameters as necessary for your setup.

Systemd configuration

Systemd is the init system in CentOS 7 and the more recent versions of Fedora. It will be utilized to start UMS on startup, as well as provide easy logging of events.

  1. Create the file /etc/systemd/system/ums.service. This gives systemd information about how to start UMS. It should have the following contents:
  2. Next, instruct systemctl reload its configuration, then enable, and start the service:
  3. Provided everything started fine, there should be no output from systemctl after starting it. You can utilize systemctl to verify everything started correctly:
  4. Systemd captures all the output from UMS and stores it in its logs. You can access all that information with journalctl. This is extremely useful if there are problems. To view all messages from UMS, you could use the command: sudo journalctl _SYSTEMD_UNIT=ums.service

Open the firewall

Unless you’ve already mucked with the defaults, the CentOS firewall should be up and running, and likely only allowing port 22/tcp in. You will need to open some holes in the firewall.

Let’s first look at the ports that UMS uses:

Unless you’ve changed anything, by default, those are 5001/tcp, 9001/tcp and 1900/udp. Port 9001/tcp is optional. Enable it if you want to browse your media via a web browser. Let’s utilize the firewall-cmd utility to poke the holes:

  1. Determine the active zone for your network interface. In the command below, the zone in use is internal. Yours will likely be the default, which is public. Notate it, and use it for the next commands:
  2. Open the ports on the zone, and reload the firewall:
  3. Verify the ports are open:

Congrats! You’re done! Launch your DLNA client (or PS3 as it were) and make sure things are working. Utilize journalctl to gather diagnostic information if things aren’t working right.

Update: I’ve made some changes in the systemctl setup and noted that port 9001 is optional. These were at the advice of Vallimar on the UMS forums. Thanks!

Ride Diary: Saturday 10/19

Weather started out cool. Wore my new long sleeved Novara jersey for the first time and needed my full fingered gloves.

Headed west via 26th Avenue and 32nd Avenue. Passed and was passed by many cyclists. Lots of groups out. I rode by a rather large one gathering at a church at 32nd Ave and McIntyre St. As I went by the Coor’s brewery, they went past me in a rather spirited fashion. They looked like they were having fun and ready to climb Lookout Mountain (I’ll do that one of these days).

Got to Vanover park in Golden. The leaves were falling on a couple of trees and presented an excellent photo op.

Autumn Ride

After a brief rest, turned my bike back around and went up Clear Creek. According the RideWithGPS app on my phone, I reached 37.5 MPH on a downhill section of this. If that’s true, I think that’s my record on a bicycle. Fortunately, the trail was completed devoid of other humans at that time.

Once I reached the I-70 underpass along the Clear Creek trail, I took a moment to debate if I wanted to keep heading up it, or head back home on the roads. I took the road option.

Turned down the Youngfield Service Rd and headed back east on 32nd Ave. At some point I ended up on 26th Ave and headed home.

Here’s my ride from the RideWithGPS app.

Bike Lock Strategies: The Ring Lock

Leave your bicycle unattended anywhere, and you’re going to worry about someone walking away with it. It’s important to have a good strategy for locking bicycles.

Many locking strategies often consist of carrying multiple items to lock your bike, such as multiple locks, or supplementing your lock(s) with cables. This is necessary because parts on modern bicycles are made to be easily removed, which is the opposite of what you want if you need to leave your bike unattended.

The ring lock, or frame lock, is not seen very often in the United States. Very common in Europe, the ring lock usually attaches to the seat stays, and immobilizes the bike by placing a metal rod through the wheel’s spokes. My primary commuter bicycle is equipped with one, and it is my favorite lock ever.

Ring Lock & Purple Tektro CantileverWhat’s great about the ring lock, the lock is always with my bicycle. I can put my key in it and immediately immobilize my bicycle. Great for quick trips.

Also, many ring locks like the ABUS Amparo pictured above have cables and chains you can plug into the side. This allows you to secure your bicycle to a stationary object such as a bike rack. Combine it with anti-theft skewers (such as Velo Orange’s) and you have a pretty decent bicycle theft prevention system.

Unfortunately, these are pretty difficult to obtain in the states.

Stop de Kindermoord (Stop the Child Murder)

Most cyclists in America are aware that the Netherlands is a cycling country. So much so, that nationwide, 27% of all trips in the Netherlands are by bicycle. Digest that statistic for a moment. That means, over one quarter of all trips in the Netherlands are by bicycle. So how’d the Dutch arrive there?

A lot of articles on the subject point to a movement in the 1970s calls “Stop de Kindermoord” which literally translates to English as “Stop the Child Murder.” The following is a quote from David Hembrow on a blog post of his:

1973 was also the year that the pressure group “Stop de Kindermoord” (“Stop the Child Murder”) started. The object of this group was to point out the number of deaths caused to children and to campaign to reduce them. They successfully influenced the Dutch government to re-emphasize building of segregated cycle paths, and to make money available to pay for them. This resulted in both a rise in cycling and a reduction in cyclist deaths, reversing the previous trend. It has been a success not only for child cyclists, but for all cyclists, and indeed for the population as a whole.

In my opinion, campaigning for children is the best way to make progress in America. People for Bikes has recently taken this idea and started their own campaign: Build it for Isabella. It’s a simple concept: “Every new bike project should strive to be usable by a 12-year old.”

Here’s Isabella:


When considering current designs of infrastructure in the Denver area, I have a hard time imagining Isabella riding on most of our infrastructure.

For example, can you envision her sharing the road when sharrows are involved?

Denver Sharrows on Sherman St

What about even buffered bike lanes like this?

Champa St Bike Lane

Or is this more like it?

Bannock Cycle Track

The above looks like something Isabella could safely ride on, if she’s heading toward the photo. But what about the bike lane for those riding away from the photo?

I would also like to point out that protected tracks like pictured above are not enough. Protected intersections are also necessary. The Bannock cycle track posted above abruptly ends, leaving Isabella on the sidewalk, mixing with pedestrians and riding through crosswalks. (The sign in the photo below cautioning cyclists to slow has since been removed.) There is no clear indication of where she can safely ride from here.

Bannock Cycle Track Ends

We even have here in Denver, the first of what cycling advocates are calling a protected lane in the form of the 15th Street Bikeway. It has many positive design elements, such as:

  1. A protected buffer from the rest of traffic (done with plastic sticks bollards).
  2. Intersection treatments, like green zebra strips.
  3. Bicycle signals at the end of the track.

Here again though, the design has serious deficiencies that would keep Isabella’s parents from considering it safe for her:

  1. “Mixing zones” where cars need to turn left across the bike lane.

  2. A lack of interconnected routes.
  3. Abrupt ending of the lane where cyclists must merge back in with traffic.

Denver can and should do better. If we ever want to cycling to reach double digits modal share, or to see our children cycling like the Dutch we need to do better. This video is something that I think we can achieve in American cities: