summaryrefslogtreecommitdiff
path: root/bin/remailer-states-create
blob: d2c37dc9674288b7f5b4ac464be83f7d4c2295ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/perl -Tw

# $Id: rrd-create,v 1.2 2001/06/29 07:59:51 statkeep Exp $

use strict;
use RRDs;
use Getopt::Long;
#use FindBin qw{ $Bin };

my $RRDTOOL = 'rrdtool';
my $RRD = 'data/remailer-states.rrd';
my $DIR = '.';

my $shorthelp = "Usage: $0 [--verbose] [--force]\n";

my $verbose = 0;
my $force = 0;
Getopt::Long::config('bundling');
unless ( GetOptions(
                    "--verbose"               , \$verbose,
                    "-v"                      , \$verbose,
										"--force"                 , \$force,
										"-f"                      , \$force
                   ) ) {
	print STDERR $shorthelp;
	exit 1;
};


chdir($DIR) || die ("Cannot change to $DIR: $!\n");

die ("$RRD already exists - not creating.\n") if ( -e $RRD && !$force );

my @params = ($RRD);
push @params, qw{ --step 1800
	DS:state1OK:GAUGE:28800:0:U
	DS:state1Warning:GAUGE:28800:0:U
	DS:state1Critical:GAUGE:28800:0:U
	DS:state2OK:GAUGE:28800:0:U
	DS:state2Warning:GAUGE:28800:0:U
	DS:state2Critical:GAUGE:28800:0:U

	RRA:AVERAGE:0.5:1:2880
	RRA:AVERAGE:0.5:48:8760
	RRA:AVERAGE:0.5:192:8760
};

# Keep 30 minute data for 60 days
# Keep 1 day data for 1 year
# Keep 4 day data for 4 years
print "Creating rrd: $RRD...\n" if $verbose;
RRDs::create @params;
my $ERR=RRDs::error;
die "ERROR while creating squid.rrd: $ERR\n" if $ERR;
print "done.\n" if $verbose;

# vim:set ts=2: