I take a lot of pictures and little is more important to me than making sure that all my photos are kept in safe storage. For this purpose, I use the online backup service from CrashPlan. With the CrashPlan backup client being written in Java, it is supported on many platforms, including GNU/Linux, and it even allows you to configure your CrashPlan server via SSH.
CrashPlan is a great “bang for buck”, costing only as little as $4/month (if you buy a 4 year subscription) and top you have unlimited online storage. What is the catch you ask? Well, if you ask me the main catch is that with the “Home” edition (for $4/month), you are not able to access its API. This is important to me as I use Nagios to monitor all my servers and also important services that I need to know is up and running 24/7.
I figured out a way to accomplish this as the CrashPlan server application produces a history log of whatever it is doing, called “history.log.0”. This file typically looks something like this:
I 04/12/14 03:00AM [Standard] Scanning for files to back up
I 04/12/14 03:01AM [Standard] Scanning for files completed in < 1 minute: 36,575 files (201.70GB) found
I 04/12/14 05:10PM [Standard] Starting backup to CrashPlan Central: 68 files (50.70KB) to back up
I 04/12/14 05:10PM [Standard] Completed backup to CrashPlan Central in < 1 minute: 68 files (50.70KB) backed up, 12.90KB encrypted and sent @ 48 bps
I 04/12/14 05:48PM [Standard] Starting backup to CrashPlan Central: 7 files (2KB) to back up
I 04/12/14 05:48PM [Standard] Completed backup to CrashPlan Central in < 1 minute: 7 files (2KB) backed up, 1.70KB encrypted and sent @ 112 bps
I 04/13/14 03:00AM [Standard] Scanning for files to back up
I 04/13/14 03:01AM [Standard] Scanning for files completed in < 1 minute: 36,649 files (201.70GB) found
I 04/13/14 03:01AM [Standard] Starting backup to CrashPlan Central: 2 files (1KB) to back up
I 04/13/14 03:01AM [Standard] Completed backup to CrashPlan Central in < 1 minute: 2 files (1KB) backed up, 1KB encrypted and sent @ 32 bps
I 04/13/14 09:14PM [Standard] Starting backup to CrashPlan Central: 57 files (771.70MB) to back up
I 04/13/14 09:30PM [Standard] Completed backup to CrashPlan Central in 15 minutes: 57 files (771.70MB) backed up, 743.60MB encrypted and sent @ 7.3Mbps
I 04/13/14 10:26PM [Standard] Starting backup to CrashPlan Central: 12 files (15.70MB) to back up
I 04/13/14 10:26PM [Standard] Completed backup to CrashPlan Central in < 1 minute: 12 files (15.70MB) backed up, 14.30MB encrypted and sent @ 3.6Mbps (Effective rate: 8.2Mbps)
I 04/14/14 03:00AM [Standard] Scanning for files to back up
I 04/14/14 03:00AM [Standard] Scanning for files completed in < 1 minute: 36,718 files (202.50GB) found
I 04/15/14 03:00AM [Standard] Scanning for files to back up
I 04/15/14 03:00AM [Standard] Scanning for files completed in < 1 minute: 36,718 files (202.50GB) found
In brief, there are three important data types we need to parse:
The timestamp
When the backup (or scan) job started
When the backup (or scan) job completed
If you are used to parsing text and recognizing patterns, you can easily write some regular expressions to extract the types of text that this log contains. I wrote a small application in Python (crashplan-log-parser) that does exactly this, and allows you to print the latest job that finished, statistics and also the number of hours passed since the last job was completed.
The above screenshot shows the command line options of logparser.py. The below screenshot however, shows the statistics command in use. Of a total of 110 jobs (found in the log file), 76 are scan jobs and 34 are backup jobs. The last backup was completed this morning 03:00 AM Norwegian time.
Finally, for integration in Nagios, the following command is also available. This prints the number of hours since the last backup or scan job was completed (integer value).
With this information, one could easily write a Nagios monitor script for polling this e.g. once per 30 minutes. e.g.
Nagios passive check script: for monitoring CrashPlan Home
function ok
{
echo -e “haugland.at\tBACKUP\t0\tOK – $1\n” > /tmp/nagios_crashplan_hours
send
}
function warning
{
echo -e “haugland.at\tBACKUP\t0\tWARNING – $1\n” > /tmp/nagios_crashplan_hours
send
}
function critical
{
echo -e “haugland.at\tBACKUP\t0\tCRITICAL – $1\n” > /tmp/nagios_crashplan_hours
send
}
function send
{
send_nsca -H v3gard.com -c /etc/nagios/send_nsca.cfg < /tmp/nagios_crashplan_hours
}
HOURS=$( logparser )
if [ $HOURS -gt $CRITLEVEL ]; then
critical “$HOURS h since last job”
elif [ $HOURS -gt $WARNLEVEL ]; then
warning “$HOURS h since last job”
else
ok “$HOURS h since last job”
fi