6 $metric_basedir = "/var/log/metriccd";
13 $s =~ s/[""]/sprintf '\\x%02X', ord $&/eg;
20 $REMOTE_HOST = $ENV{'REMOTE_HOST'};
23 my ($hostname, $aliases, $addrtype, $addrlength, @addrs) = gethostbyaddr(inet_aton
($REMOTE_HOST), AF_INET
);
24 $Param{'hostname'} = $hostname if $hostname;
29 if(/^([^\t]+)\t([^\t]+)(?:\t(\d+)|)$/ or /^([^ ]+) ([^ ]+)(?: (\d+)|)$/)
31 my ($metric, $data, $timestamp) = ($1, $2, $3);
32 $timestamp = time unless $timestamp;
36 mkdir $metric_basedir;
37 mkdir "$metric_basedir/by-host";
38 open $FileHandle, '>>', "$metric_basedir/by-host/$REMOTE_HOST";
41 my $params = join '', map {"\t$_=".kvesc
($Param{$_})} keys %Param;
42 print {$FileHandle} "$metric\t$data\t$timestamp$params\n";