# Computing

Just another Chemistry Blogs site
Updated: 2 hours 37 min ago

### When is nothing something?

Thu, 06/08/2017 - 11:00

We use devmon to automatically monitor a variety of things on our network, including our uninterruptible power supplies (UPSs) that ensure our core infrastructure is able to withstand short power outages.

Our UPSs should perform a self-test routine every two weeks, and thus I wanted to have our automated monitoring report on whether or not a self-test had been performed sufficiently recently. The UPSs report the date they were last tested in the format MM/DD/YYYY (i.e. today, the 8th of June 2017, is 06/08/2017), and so I needed to parse dates of that format so I could calculate the number of days since the last self-test.

Ordinarily the advice on performing any sort of date calculation when programming is “use a date library”: date calculations are notoriously difficult to get totally right, and you’re normally better off using a library that someone has written and which has already been thoroughly tested. But that’s not an option inside devmon: one can perform basic mathematical and string manipulation operations, but little else.

I wrote the monitoring report about a week ago, and it had been working fine – but I noticed that it had stopped reporting today. The first step in parsing the date is to take a string like 06/08/2017 and extract characters 1 and 2, then 4 and 5, then 7 to 10 and store them as the month, day and year respectively.

An oft-used convention in programming languages is that numbers that start with a leading zero should be interpreted as octal (base 8) numbers. Thus, in octal, the decimal numbers 1 to 10 are 01, 02, 03, 04, 05, 06, 07, 010, 011, 012.

You might now see the problem: 08 is not a valid octal number, so the underlying code stopped working today! Running devmon in debug mode quickly let me find the reason for the problem:

Illegal octal digit ‘8’ at (eval 13) line 1, at end of line

and so the fix was simply to remove any leading zeroes from the month and day.

### System status

System monitoring page

## Can't find what you're looking for?

Then you might find our A-Z site index useful. Or, you can search the site using the box at the top of the page, or by clicking here.