diff options
Diffstat (limited to '')
-rw-r--r-- | sca-cpp/trunk/components/log/Makefile.am | 2 | ||||
-rw-r--r-- | sca-cpp/trunk/components/log/scribe-cat.cpp | 36 | ||||
-rwxr-xr-x | sca-cpp/trunk/components/log/scribe-tail-start | 3 | ||||
-rwxr-xr-x | sca-cpp/trunk/components/log/scribed-central-conf | 7 | ||||
-rwxr-xr-x | sca-cpp/trunk/components/log/scribed-central-firehose-conf | 125 | ||||
-rwxr-xr-x | sca-cpp/trunk/components/log/scribed-central-mkfirehose | 34 |
6 files changed, 187 insertions, 20 deletions
diff --git a/sca-cpp/trunk/components/log/Makefile.am b/sca-cpp/trunk/components/log/Makefile.am index 5d685babec..0e96be5697 100644 --- a/sca-cpp/trunk/components/log/Makefile.am +++ b/sca-cpp/trunk/components/log/Makefile.am @@ -22,7 +22,7 @@ INCLUDES = -I${THRIFT_INCLUDE} -I${FB303_INCLUDE} incl_HEADERS = *.hpp incldir = $(prefix)/include/components/log -dist_comp_SCRIPTS = scribed-central-conf scribed-client-conf scribed-central-start scribed-central-stop scribed-client-start scribed-client-stop scribe-tail-start scribe-tail-stop +dist_comp_SCRIPTS = scribed-central-conf scribed-central-firehose-conf scribed-central-mkfirehose scribed-client-conf scribed-central-start scribed-central-stop scribed-client-start scribed-client-stop scribe-tail-start scribe-tail-stop compdir=$(prefix)/components/log comp_DATA = scribe.prefix thrift.prefix diff --git a/sca-cpp/trunk/components/log/scribe-cat.cpp b/sca-cpp/trunk/components/log/scribe-cat.cpp index 77011e8b12..7f48ddb59b 100644 --- a/sca-cpp/trunk/components/log/scribe-cat.cpp +++ b/sca-cpp/trunk/components/log/scribe-cat.cpp @@ -36,33 +36,35 @@ namespace tuscany { namespace scribecat { -int cat(const string& category, const string& type) { +int cat(const string& host, const string& category, const string& type) { // Connect to Scribe scribe::Scribe& sc = *(new (gc_new<scribe::Scribe>()) scribe::Scribe("localhost", 1464)); // Read lines from stdin and log them - char buf[8192]; + char buf[8193]; for (;;) { - const char* s = fgets(buf, 8192, stdin); + gc_scoped_pool(); + + // Write line prefix + ostringstream os; + os << "[" << host << "] "; + if (length(type) != 0) + os << "[" << logTime() << "] [" << type << "] "; + const string prefix = str(os); + const int pl = length(prefix); + strcpy(buf, c_str(prefix)); + + // Read log line + const char* s = fgets(buf + pl, 8192 - pl, stdin); if (s == NULL) return 0; const size_t l = strlen(s); if (l < 2) return 0; - buf[l - 1] = '\0'; + buf[pl + l - 1] = '\0'; - // Log each line as is - if (length(type) == 0) { - const failable<bool> val = scribe::log(buf, category, sc); - if (!hasContent(val)) - return 1; - continue; - } - - // Log each line prefixed with time and a type tag - ostringstream os; - os << "[" << logTime() << "] [" << type << "] " << buf; - const failable<bool> val = scribe::log(c_str(str(os)), category, sc); + // Log the line + const failable<bool> val = scribe::log(buf, category, sc); if (!hasContent(val)) return 1; } @@ -72,6 +74,6 @@ int cat(const string& category, const string& type) { } int main(const int argc, const char** argv) { - return tuscany::scribecat::cat(argc < 2? "default" : argv[1], argc < 3? "" : argv[2]); + return tuscany::scribecat::cat(argc < 2? "localhost" : argv[1], argc < 3? "default" : argv[2], argc < 4? "" : argv[3]); } diff --git a/sca-cpp/trunk/components/log/scribe-tail-start b/sca-cpp/trunk/components/log/scribe-tail-start index 22f5101053..fc469b5488 100755 --- a/sca-cpp/trunk/components/log/scribe-tail-start +++ b/sca-cpp/trunk/components/log/scribe-tail-start @@ -35,10 +35,11 @@ else file=$1 fi fi +host=`hostname` mkdir -p `dirname $file` touch $file file=`echo "import os; print os.path.realpath('$file')" | python` -tail -f -n 0 $file | $here/scribe-cat $category $type & +tail -f -n 0 $file | $here/scribe-cat $host $category $type & diff --git a/sca-cpp/trunk/components/log/scribed-central-conf b/sca-cpp/trunk/components/log/scribed-central-conf index d8d008623d..066dad4add 100755 --- a/sca-cpp/trunk/components/log/scribed-central-conf +++ b/sca-cpp/trunk/components/log/scribed-central-conf @@ -42,7 +42,6 @@ check_interval=3 <store> category=default type=buffer - target_write_size=20480 max_write_interval=1 buffer_send_rate=2 @@ -50,7 +49,10 @@ retry_interval=30 retry_interval_range=10 <primary> +category=default type=file +target_write_size=20480 +max_write_interval=1 fs_type=std file_path=$root/scribe/logs/central base_filename=central @@ -62,7 +64,10 @@ rotate_minute=10 </primary> <secondary> +category=default type=file +target_write_size=20480 +max_write_interval=1 fs_type=std file_path=$root/scribe/logs/central-secondary base_filename=central diff --git a/sca-cpp/trunk/components/log/scribed-central-firehose-conf b/sca-cpp/trunk/components/log/scribed-central-firehose-conf new file mode 100755 index 0000000000..660cf7820a --- /dev/null +++ b/sca-cpp/trunk/components/log/scribed-central-firehose-conf @@ -0,0 +1,125 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Generate a Scribe central conf +here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here` +mkdir -p $1 +root=`echo "import os; print os.path.realpath('$1')" | python` + +port=$2 +if [ "$port" = "" ]; then + port="1463" +fi + +mkdir -p $root/scribe/conf +mkdir -p $root/scribe/logs/central +mkdir -p $root/scribe/logs/central-secondary +mkdir -p $root/scribe/logs/firehose +mkdir -p $root/scribe/logs/firehose-secondary + +cat >$root/scribe/conf/scribe-central.conf <<EOF +# Generated by: scribed-central-conf $* +# Scribe central configuration +port=$port +max_msg_per_second=2000000 +check_interval=3 + +# Log store configuration +<store> +category=default +type=multi +target_write_size=20480 +max_write_interval=1 + +<store0> +category=default +type=buffer +target_write_size=20480 +max_write_interval=1 +buffer_send_rate=2 +retry_interval=30 +retry_interval_range=10 + +<primary> +category=default +type=file +target_write_size=20480 +max_write_interval=1 +fs_type=std +file_path=$root/scribe/logs/central +base_filename=central +max_size=1000000 +add_newlines=1 +rotate_period=daily +rotate_hour=0 +rotate_minute=10 +</primary> + +<secondary> +category=default +type=file +target_write_size=20480 +max_write_interval=1 +fs_type=std +file_path=$root/scribe/logs/central-secondary +base_filename=central +max_size=3000000 +</secondary> + +</store0> + +<store1> +category=default +type=buffer +target_write_size=20480 +max_write_interval=1 +buffer_send_rate=2 +retry_interval=30 +retry_interval_range=10 + +<primary> +category=default +type=file +target_write_size=20480 +max_write_interval=1 +fs_type=std +file_path=$root/scribe/logs/firehose +base_filename=central +max_size=1000000 +add_newlines=1 +write_stats=no +create_symlink=no +</primary> + +<secondary> +category=default +type=file +target_write_size=20480 +max_write_interval=1 +fs_type=std +file_path=$root/scribe/logs/firehose-secondary +base_filename=central +max_size=3000000 +</secondary> + +</store1> + +</store> + +EOF diff --git a/sca-cpp/trunk/components/log/scribed-central-mkfirehose b/sca-cpp/trunk/components/log/scribed-central-mkfirehose new file mode 100755 index 0000000000..9b02305d1d --- /dev/null +++ b/sca-cpp/trunk/components/log/scribed-central-mkfirehose @@ -0,0 +1,34 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Create a firehose fifo pipe for a log category +here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here` +mkdir -p $1 +root=`echo "import os; print os.path.realpath('$1')" | python` + +category=$2 +if [ "$category" = "" ]; then + category="default" +fi + +mkdir -p $root/scribe/logs/firehose/$category +if [ ! -e "$root/scribe/logs/firehose/$category/$category""_00000" ]; then + mkfifo "$root/scribe/logs/firehose/$category/$category""_00000" +fi + |