Add Missions completed

This commit is contained in:
Vincent Riquer 2014-11-26 11:24:25 +01:00
parent 86f243f15b
commit 963faf4627
6 changed files with 104 additions and 24 deletions

14
add
View File

@ -59,6 +59,20 @@ else
exit
fi
while read ds junk
do
ds="${ds//ds[/}"
ds="${ds//]*/}"
datasets+=("$ds")
done < <(rrdtool info ingress.rrd |grep index)
for ds in ${dsnames[@]}
do
if [[ ! ${datasets[@]} =~ $ds ]]
then
cp -f ingress.rrd ingress.rrd.bak_add_$ds
./dsaddtor.pl ingress.rrd $ds GAUGE $((48*60*60)) 0 NaN
fi
done
data=N
for dsname in "${dsnames[@]}"
do

View File

@ -67,6 +67,7 @@ then
DS:Link_Length_x_Days:GAUGE:$((48*60*60)):0:NaN \
DS:Field_Held:GAUGE:$((48*60*60)):0:NaN \
DS:Field_x_Days:GAUGE:$((48*60*60)):0:NaN \
DS:Mercenary:GAUGE:$((48*60*60)):0:NaN \
RRA:HWPREDICT:8760:8e-1:8e-1:$((24)) \
RRA:AVERAGE:99e-2:1:$((24*15)) \
RRA:MAX:99e-2:1:$((24*15)) \

59
dsaddtor.pl Executable file
View File

@ -0,0 +1,59 @@
#!/usr/bin/perl
# dsaddtor.pl, Program to add datasources to an existing RRD
#
# Copyright (C) 2010 R. Sandevoir remi.sandevoir(at)gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
use strict;
use warnings;
use RRD::Simple ();
my $rrdfile = shift || &Usage;
if ($rrdfile eq '-h') {
&Usage;
exit 0;
}
my $name = shift || &Usage;
my $type = shift || 'COUNTER';
my $heartbeat = shift || '600';
my $min = shift || 'NaN';
my $max = shift || 'NaN';
my $rrd = RRD::Simple->new(
file => $rrdfile,
rrdtool => "/usr/bin/rrdtool",
);
print "Adding DS $name on $rrdfile\n";
$rrd->add_source($rrdfile, $name => $type);
print "Heartbeat : $heartbeat\nMinimum value : $min\nMaximum value : $max\n";
RRDs::tune ($rrdfile, "-h","$name:$heartbeat");
RRDs::tune ($rrdfile, "-i","$name:$min");
RRDs::tune ($rrdfile, "-a","$name:$max");
sub Usage {
print "dsaddtor.pl <file.rrd> <ds_name> [type] [heartbeat] [rrdmin] [rrdmax]\n";
print "\t<file.rrd>\tSource RRD file\n";
print "\t<ds_name>\tDatasource name to add\n";
print "\t[type]\t\tType of datasource (i.e. COUNTER, GAUGE...). Default : COUNTER\n";
print "\t[heartbeat]\tLength of time in seconds before RRD thinks your DS is dead. Default : 600\n";
print "\t[rrdmin]\tMinimum value allowed for each datasource. Default : NaN\n";
print "\t[rrdmax]\tMax value allowed for each datasource. Default : NaN\n";
exit 0
}

25
index
View File

@ -331,30 +331,7 @@ then
if (( show_all ))
then
stats=(
AP
Explorer
Seer
XM
Hacker
Builder
Connector
Mind_Controller
MU
Longest_Link
Largest_Field
Recharger
Liberator
Pioneer
Purifier
Neutralized
Links_Destroyed
Fields_Destroyed
Walked
Guardian
Link_Maintained
Link_Length_x_Days
Field_Held
Field_x_Days
"${dsnames[@]}"
)
else
stats=(

View File

@ -34,3 +34,30 @@ declare \
start \
end \
want_ds=(
AP
Explorer
Seer
XM
Hacker
Builder
Connector
Mind_Controller
MU
Longest_Link
Largest_Field
Recharger
Liberator
Pioneer
Purifier
Neutralized
Links_Destroyed
Fields_Destroyed
Walked
Guardian
Link_Maintained
Link_Length_x_Days
Field_Held
Field_x_Days
Mercenary
)

View File

@ -60,6 +60,7 @@ uinames=(
"Max Link Length x Days"
"Max Time Field Held"
"Largest Field MUs x Days"
"Unique missions completed"
)
dsnames=(
AP
@ -86,6 +87,7 @@ dsnames=(
Link_Length_x_Days
Field_Held
Field_x_Days
Mercenary
)
medals=(
Explorer