Menu

Using GNU Recutils to Track Car Maintenance History

Oct 24, 2018

I have an older car that needs regular maintenance.
My maintenance history is stored on a pile of crumpled papers in the glovebox.
This makes it hard to get a holistic picture of my car’s maintenance history.
It’s good to know what you’ve had done when the service department is making recommendations.

There are services like Carfax that will provide a detailed history for a little money,
but the value of something like Carfax is to see maintenance records for a used car before you buy it,
not to track maintenance on a vehicle you already own.
Plus, I already have two years of maintenance data sitting in the glovebox.

What information to track?
I’ve created a class diagram to help me think through this.

So we have a Car that represents my Honda,
a Provider like Jiffy Lube,
an Activity representing a visit to the shop,
and Service items that represent specific things that were done to the car,
like an oil change.

I’m going to change this a bit when I implement it in recutils.

I only have one car, so I’m not going to associate data with a car.

I’m going to merge the Activity and Service objects. There will be some duplication of data, but it will be easier to manage.

I’ll be doing all my reporting from the Service type, so that’s where I’ll store all the foreign keys.

Here is my recfile with all the field properties.
You could, of course, do much of this in a spreadsheet, sacrificing some flexibility.

Now, I’ve gone through the nominally laborious task of translating my service invoices into recfiles.
I had to summarize some of the line items on the invoices.
I did this in an editor,
but you could also use recins, possibly within a script.

It would be pretty neat to see how many miles had elapsed between oil changes.
I think awk would be a good tool for this.
First, we need to transform these vertical records into linewise records.
There are probably a number of ways to do this.
Here’s an awk script that does the job.

awk '/./ {ln = ln $0 "\t"}; /^$/ {print ln; ln = ""};'

You could also do it in sed like this:

sed -ne '/./ H;/^$/ {x;s/^\n//;s/\n/\t/g;p};${g;s/^\n//;s/\n/\t/g;p}'

One more thing we need to do is strip the field labels from the output of recsel.
This is easily done by changing the -p option to -P.
So, to get tabular output, we pipe the output of recsel into awk.

My guess is I lost a service record for an oil change somewhere during June 2017.
I could check my credit card statements during that period to see if I can find a payment to an auto shop.
I like to think that I’m diligent about oil changes,
but I can see I have some room for improvement.

More ideas:

Add an Exhibit Number to each Service record so that you can quickly find the specific paper maintenance record that it came from.

Use a plotting tool like GNUplot or Google Charts to plot mileage or expense over time.

Track maintenance expenses against the market value of the car to help you decide when to replace it.