Sunday, January 27, 2008

Using Google Calendar to Monitor Software, Part 2

I've been keeping track of cron jobs with a shell script that posts calendar events. Here's the README file.


# $Id: cal_event_notes 5853 2007-04-02 16:46:01Z jhaemer $

Setting Up Your Google Calendar to Track Scheduled Events for Dummies

First, create a calendar to play with.

- Log in to If you don't have an account, follow the instructions and create one. Remember your login and password.

If you already have a Google calendar, you can use it, but I suggest setting up a separate account.

- On the left-hand-side, find the list of Calendars, then follow your nose, like this:

Calendars -> Manage calendars -> My Calendars -> Add calendar

- Start out by creating a calendar called "Frog", to convince yourself this all works. Don't bother to fill in the details: just take the defaults, including "Do not share this calendar with anyone." When you create a calendar to hold real events, you'll fill this stuff in. This is just a test.

- Click on "Create Calendar" and you'll be taken back to the main, calendar page. You should see "Frog" over on the left, in your list of calendars.

Make sure it's checked, so events in the Frog calendar actually display.

- Now go here:
Calendars -> Manage calendars -> My Calendars -> Frog
This time, you'll see calendar details. You want this:
Private Address -> HTML
gCal will put up a little pop-up with an amazingly long URL that the "cal_event" program needs. It'll start with "http://"

- Put your cursor on the URL, and right-click (on a Mac, control-click) to get a context menu, and select "Copy Link Location".

When you've copied it, go ahead and click "Okay" to get rid of the popup, and click on the "Google" logo, in the northwest part of the page, to return to the main calendar.

- Edit "" and insert that URL into the %url hash, like this:
%url = (
frog =>
All the punctuation is important, but you'll have a different URL.

- Now edit "" and put in your login where it says to:
our $login = '';
our $passwd = "foobarmumble!";
If you don't want anyone to see these, change the permissions of so only you have permission to read it.
chmod 600
For programmers:

Admittedly, you could put the login and password into environment variables, and use statements like this
our $login = $ENV{CAL_LOGIN};
our $passwd = $ENV{CAL_PASSWD};
but that just pushes back the problem. Where will you set those? You can also prompt for the password, but that makes running cal_entry from scripts impossible, and negates the whole point of having this script.

- Try (at last!) running the calendar notification program, "cal_event" like this
cal_event frog A sample event
In a moment, you should see the event appear on your Frog calendar.

That's it. Now, go back and add as many real calendars as you want to this account, and then post events to them to your heart's content. They'll all display in the same place, and the different calendars will be in different colors. To look at or hide individual calendars, just check or uncheck boxes over on the left.

I tend to use the month view, and to drill down, I click the Day view tab.

If you've done this in a separate account from your own calendar, you can share the calendar with yourself, and watch the events from the comfort of your own calendar page. Go here:
Calendars -> Manage calendars -> My Calendars -> Frog -> Calendar Address -> Change sharing settings -> Share with specific people
and share it with your normal calendar account.

The calendars are searchable (Google's a search company), so I put enough information in the description to let me search. For example, if my dump script fails, it calls
cal_event dumps "FAIL: dumps"
then, I can search for FAIL to find all failures or "dumps FAIL" to list all dump failures.

I keep my entries pretty spartan, but you can put more in if you like. See the man page for Simon Wistow's Net::Google::Calendar. You'll need to modify cal_event, which is a Perl program. If you don't program in Perl, go make friends with someone who does. You can always use more friends.

No comments: