Code cleanup

This commit is contained in:
Pierre Pronchery 2016-02-04 00:22:03 +01:00
parent 80aa2c0078
commit 4e11fe417c

View File

@ -16,19 +16,30 @@
#variables
PROGNAME="create.sh"
#executables
DATE="date"
MKDIR="mkdir -p"
RRDTOOL="rrdtool"
#functions #functions
#create #create
create() create()
{ {
mkdir -p "$i" i="$1"
rrdtool create "$i/uptime.rrd" --start "`date +%s`" \
$MKDIR -- "$i"
$RRDTOOL create "$i/uptime.rrd" --start "$($DATE +%s)" \
--step 10 \ --step 10 \
DS:uptime:GAUGE:120:0:U \ DS:uptime:GAUGE:120:0:U \
RRA:AVERAGE:0.5:1:360 \ RRA:AVERAGE:0.5:1:360 \
RRA:AVERAGE:0.5:24:360 \ RRA:AVERAGE:0.5:24:360 \
RRA:AVERAGE:0.5:168:360 RRA:AVERAGE:0.5:168:360
rrdtool create "$i/load.rrd" --start "`date +%s`" \ $RRDTOOL create "$i/load.rrd" --start "$($DATE +%s)" \
--step 10 \ --step 10 \
DS:load1:GAUGE:30:0:U \ DS:load1:GAUGE:30:0:U \
DS:load5:GAUGE:30:0:U \ DS:load5:GAUGE:30:0:U \
@ -37,7 +48,7 @@ create()
RRA:AVERAGE:0.5:24:360 \ RRA:AVERAGE:0.5:24:360 \
RRA:AVERAGE:0.5:168:360 RRA:AVERAGE:0.5:168:360
rrdtool create "$i/ram.rrd" --start "`date +%s`" \ $RRDTOOL create "$i/ram.rrd" --start "$($DATE +%s)" \
--step 10 \ --step 10 \
DS:ramtotal:GAUGE:30:0:U \ DS:ramtotal:GAUGE:30:0:U \
DS:ramfree:GAUGE:30:0:U \ DS:ramfree:GAUGE:30:0:U \
@ -47,7 +58,7 @@ create()
RRA:AVERAGE:0.5:24:360 \ RRA:AVERAGE:0.5:24:360 \
RRA:AVERAGE:0.5:168:360 RRA:AVERAGE:0.5:168:360
rrdtool create "$i/swap.rrd" --start "`date +%s`" \ $RRDTOOL create "$i/swap.rrd" --start "$($DATE +%s)" \
--step 10 \ --step 10 \
DS:swaptotal:GAUGE:30:0:U \ DS:swaptotal:GAUGE:30:0:U \
DS:swapfree:GAUGE:30:0:U \ DS:swapfree:GAUGE:30:0:U \
@ -55,21 +66,21 @@ create()
RRA:AVERAGE:0.5:24:360 \ RRA:AVERAGE:0.5:24:360 \
RRA:AVERAGE:0.5:168:360 RRA:AVERAGE:0.5:168:360
rrdtool create "$i/users.rrd" --start "`date +%s`" \ $RRDTOOL create "$i/users.rrd" --start "$($DATE +%s)" \
--step 10 \ --step 10 \
DS:users:GAUGE:30:0:65536 \ DS:users:GAUGE:30:0:65536 \
RRA:AVERAGE:0.5:1:360 \ RRA:AVERAGE:0.5:1:360 \
RRA:AVERAGE:0.5:24:360 \ RRA:AVERAGE:0.5:24:360 \
RRA:AVERAGE:0.5:168:360 RRA:AVERAGE:0.5:168:360
rrdtool create "$i/procs.rrd" --start "`date +%s`" \ $RRDTOOL create "$i/procs.rrd" --start "$($DATE +%s)" \
--step 10 \ --step 10 \
DS:procs:GAUGE:30:0:65536 \ DS:procs:GAUGE:30:0:65536 \
RRA:AVERAGE:0.5:1:360 \ RRA:AVERAGE:0.5:1:360 \
RRA:AVERAGE:0.5:24:360 \ RRA:AVERAGE:0.5:24:360 \
RRA:AVERAGE:0.5:168:360 RRA:AVERAGE:0.5:168:360
rrdtool create "$i/eth0.rrd" --start "`date +%s`" \ $RRDTOOL create "$i/eth0.rrd" --start "$($DATE +%s)" \
--step 10 \ --step 10 \
DS:ifrxbytes:COUNTER:30:0:U \ DS:ifrxbytes:COUNTER:30:0:U \
DS:iftxbytes:COUNTER:30:0:U \ DS:iftxbytes:COUNTER:30:0:U \
@ -82,7 +93,7 @@ create()
#usage #usage
usage() usage()
{ {
echo "Usage: create.sh host..." 1>&2 echo "Usage: $PROGNAME host..." 1>&2
return 1; return 1;
} }