Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5351610
  • 博文数量: 1144
  • 博客积分: 11974
  • 博客等级: 上将
  • 技术积分: 12312
  • 用 户 组: 普通用户
  • 注册时间: 2005-04-13 20:06
文章存档

2017年(2)

2016年(14)

2015年(10)

2014年(28)

2013年(23)

2012年(29)

2011年(53)

2010年(86)

2009年(83)

2008年(43)

2007年(153)

2006年(575)

2005年(45)

分类: LINUX

2007-09-10 01:03:09

[root@mailgw libexec]# cat dcc-stats-collect
#! /bin/sh
# collect spam statistics in .rrd files
#   [-x]            debugging
#   [-q]            quiet
#   [-S]            read `cdcc stats` from stdin
#   [-h dcc_homedir]
#   [-D data-dir]   where to put the graphs and rrdtool files
#   [-s stats-file] save raw `cdcc stats` output in stats-file
#   [-t time]       seconds since the Epoch
#   [-T /usr/local/bin/rrdtool]
#                   see
#                       or the FreeBSD package.
#   [-O rrdopts]    "--heartbeat X" or "--step Y"
#   [-i client-ID]  that DCC servers will accept
#   [-p password]   that DCC servers will accept
#   host1, host2, ... servers to ask for data

# Copyright (c) 2006 by Rhyolite Software, LLC
#
# This agreement is not applicable to any entity which sells anti-spam
# solutions to others or provides an anti-spam solution as part of a
# security solution sold to other entities, or to a private network
# which employs the DCC or uses data provided by operation of the DCC
# but does not provide corresponding data to other users.
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# Parties not eligible to receive a license under this agreement can
# obtain a commercial license to use DCC and permission to use
# U.S. Patent 6,330,590 by contacting Commtouch at
# or by email to .
#
# A commercial license would be for Distributed Checksum and Reputation
# Clearinghouse software.  That software includes additional features.  This
# free license for Distributed ChecksumClearinghouse Software does not in any
# way grant permision to use Distributed Checksum and Reputation Clearinghouse
# software
#
# THE SOFTWARE IS PROVIDED "AS IS" AND RHYOLITE SOFTWARE, LLC DISCLAIMS ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL RHYOLITE SOFTWARE, LLC
# BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
# SOFTWARE.
#       Rhyolite Software DCC 1.3.59-1.25 $Revision$
#       Generated automatically from dcc-stats-collect.in by configure.
DCC_HOMEDIR=/var/dcc
DEBUG=
# check the args once to get the home directory
while getopts "xqSh:D:s:t:T:O:i:p:" c; do
    case $c in
        x) set -x; DEBUG=-x;;
        h) DCC_HOMEDIR="$OPTARG";;
        *) ;;
    esac
done
. $DCC_HOMEDIR/dcc_conf
QUIET=
GET_ARGS=
DATADIR=$DCC_HOMEDIR/stats
STATSFILE=/dev/null
TS=N
RRDTOOL=/usr/local/bin/rrdtool
RRDOPTS=
CLNT_ID="1"
PASSWD=""
USAGE="`basename $0`: [-xqS] [-h homedir] [-D data-dir] [-s stats-file] [-t time]
    [-T rrdtool] [-O rrdopts] [-i client-ID] [-p password] host1 host2 ..."
OPTIND=1
while getopts "xqSh:D:s:t:T:O:i:p:" c; do
    case $c in
        x) ;;
        q) QUIET="-q";;
        S) GET_ARGS="$GET_ARGS -S";;
        h) ;;
        D) DATADIR="$OPTARG";;
        s) STATSFILE="$OPTARG";;
        t) TS="$OPTARG";;
        T) RRDTOOL="$OPTARG";;
        O) RRDOPTS="$RRDOPTS $OPTARG";;
        i) CLNT_ID="$OPTARG";;
        p) PASSWD="$OPTARG;";;
        *) echo "$USAGE" 1>&2; exit 1;;
    esac
done
shift `expr $OPTIND - 1 || true`
if test "$#" -eq 0; then
    echo "$USAGE" 1>&2
    exit 1
fi
cd $DATADIR
for HOST in $*; do
    HOST="`basename $HOST .rrd`"
    eval XSTATSFILE="$STATSFILE"
    if test "$PASSWD" != ""; then
        LINE=`$DCC_LIBEXEC/stats-get $GET_ARGS $DEBUG $QUIET            \
            -s$XSTATSFILE -i$CLNT_ID -p "$PASSWD" $HOST`
    else
        LINE=`$DCC_LIBEXEC/stats-get $GET_ARGS $DEBUG $QUIET            \
            -s$XSTATSFILE -i$CLNT_ID $HOST`
    fi
    FILE="$HOST.rrd"
#opt    # update RRD file to include maximums
#opt    if test -z "`$RRDTOOL info $FILE 2>/dev/null                    \
#opt                | grep '^rra.*cf = .MAX.'`"; then
#opt    mv "$FILE" "$FILE.old"
#opt    $RRDTOOL dump "$FILE.old" | sed -e '$d' >"$FILE.xml"
#opt    $RRDTOOL dump "$FILE.old"                                       \
#opt        | sed -e > MIN @ MAX @p'           \
#opt            -e '1,/ MAX <.cf>/d'                                \
#opt            -e > [0-9.+e]* @ NaN @g' >>"$FILE.xml"
#opt    $RRDTOOL restore "$FILE.xml" "$FILE"
#opt    rm "$FILE.xml"
#opt    fi
    if test -n "$LINE"; then
        # create the RRD file if it does not exist
        if test ! -s "$FILE"; then
            $DCC_LIBEXEC/dcc-stats-init $QUIET $DEBUG -h$DCC_HOMEDIR    \
                -D$DATADIR -T "$RRDTOOL" -O "$RRDOPTS" "$FILE"
        fi
        # do not add flood checksum counts to new database
        if test -z "`$RRDTOOL info $FILE | grep '^ds.flooded.*DERIVE'`"; then
            LINE=`expr "$LINE" : '\(.*\):[0-9]*$'`
        fi
        $RRDTOOL update "$FILE" "$TS:$LINE"
    fi
done
阅读(2122) | 评论(0) | 转发(0) |
0

上一篇:start-dccm

下一篇:使用bacula備份

给主人留下些什么吧!~~