+use Getopt::Long qw(:config no_ignore_case bundling pass_through);
+
+my $DIR = "/var/lib/collectd";
+my $HOST = undef;
+my $IMG_FMT = "PNG";
+my $RECURSIVE = 1;
+
+GetOptions (
+ "host=s" => \$HOST,
+ "data-dir=s" => \$DIR,
+ "image-format=s" => \$IMG_FMT,
+ "recursive" => \$RECURSIVE
+);
+
+if (($DIR !~ m/\/rrd\/?$/) && (-d "$DIR/rrd")) {
+ $DIR .= "/rrd";
+}
+
+if (defined($HOST) && ($DIR !~ m/\/$HOST\/?$/) && (-d "$DIR/$HOST")) {
+ $DIR .= "/$HOST";
+}