#!/usr/bin/env perl

use strict;
use warnings;
use Inca::Reporter::SimpleUnit;

my $reporter = new Inca::Reporter::SimpleUnit(
  name => 'grid.curl.unit',
  version => 8,
  description => 'Reports whether curl can download a web page',
  url => 'http://inca.ucsd.edu',
  unit_name => 'curl'
);
$reporter->addArg('page', 'web page url to download', 'http://cnn.com/index.html');
$reporter->addArg('curlArgs', 'curl arguments', '');
$reporter->processArgv(@ARGV);
my $page = $reporter->argValue('page');
my $args = $reporter->argValue('curlArgs');

my $curlCmd = "curl $args -o /dev/null $page";
my $output = $reporter->loggedCommand($curlCmd);
if($? || ($output !~ "Received")) {
  my $err = "curl command failed: $output $!";
  $err =~ s/--\d{2}:\d{2}:\d{2}--/--xx:xx:xx--/g;
  $reporter->unitFailure($err);
} else {
  $reporter->unitSuccess();
}
$reporter->print();


Click here to see help information for the grid.curl.unit reporter.