jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [trunk/] [modules/] [system/] [makerrd] - Rev 31 Go to most recent revision

Compare with Previous - Blame - Download


#!/usr/bin/env sh

. ../../settings
MAXUSERS=500
MAXCPU=5
MAXPROC=U
MAXMEM=U
MAXSWAP=U
MAXLOAD=500

OS_TYPE=`uname`

SECS=`date +%s`

MODNAME=`pwd|sed -e "s/.*\///g" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`

if ! [ "$(echo $1|grep users)" = "" ]; then
  DEV=$1
  echo $SECS $MODNAME: setting up database $DEV.rrd for values [0..$MAXUSERS]
  $BINPATH/rrdtool create rrd/$DEV.rrd --step 10 \
    DS:tty:GAUGE:300:0:$MAXUSERS \
    DS:pty:GAUGE:300:0:$MAXUSERS \
    DS:pts:GAUGE:300:0:$MAXUSERS \
    RRA:AVERAGE:0:1:720 \
    RRA:AVERAGE:0.3:6:2880 \
    RRA:AVERAGE:0.3:60:2016 \
    RRA:AVERAGE:0.3:360:1488 \
    RRA:AVERAGE:0.3:4320:1460 \
    RRA:MIN:0.3:6:2880 \
    RRA:MIN:0.3:60:2016 \
    RRA:MIN:0.3:360:1488 \
    RRA:MIN:0.3:4320:1460 \
    RRA:MAX:0.3:6:2880 \
    RRA:MAX:0.3:60:2016 \
    RRA:MAX:0.3:360:1488 \
    RRA:MAX:0.3:4320:1460
  fi
 
if ! [ "$(echo $1|grep load)" = "" ]; then
  DEV=$1
  echo $SECS $MODNAME: setting up database $DEV.rrd for values [0..$MAXLOAD]
  $BINPATH/rrdtool create rrd/$DEV.rrd --step 10 \
    DS:load15:GAUGE:300:0:$MAXLOAD \
    DS:load5:GAUGE:300:0:$MAXLOAD \
    DS:load1:GAUGE:300:0:$MAXLOAD \
    RRA:AVERAGE:0:1:720 \
    RRA:AVERAGE:0.3:6:2880 \
    RRA:AVERAGE:0.3:60:2016 \
    RRA:AVERAGE:0.3:360:1488 \
    RRA:AVERAGE:0.3:4320:1460 \
    RRA:MIN:0.3:6:2880 \
    RRA:MIN:0.3:60:2016 \
    RRA:MIN:0.3:360:1488 \
    RRA:MIN:0.3:4320:1460 \
    RRA:MAX:0.3:6:2880 \
    RRA:MAX:0.3:60:2016 \
    RRA:MAX:0.3:360:1488 \
    RRA:MAX:0.3:4320:1460
  fi
 
if ! [ "$(echo $1|grep cpu)" = "" ]; then
  DEV=$1
  echo $SECS $MODNAME: setting up database $DEV.rrd for values [0..$MAXCPU]
  if [ $OS_TYPE = "Linux" ] || [ $OS_TYPE = "SunOS" ]; then
    $BINPATH/rrdtool create rrd/$DEV.rrd --step 10 \
      DS:cpuusr:GAUGE:300:0:$MAXCPU \
      DS:cpunic:GAUGE:300:0:$MAXCPU \
      DS:cpusys:GAUGE:300:0:$MAXCPU \
      DS:cpuidl:GAUGE:300:0:$MAXCPU \
      RRA:AVERAGE:0:1:720 \
      RRA:AVERAGE:0.3:6:2880 \
      RRA:AVERAGE:0.3:60:2016 \
      RRA:AVERAGE:0.3:360:1488 \
      RRA:AVERAGE:0.3:4320:1460 \
      RRA:MIN:0.3:6:2880 \
      RRA:MIN:0.3:60:2016 \
      RRA:MIN:0.3:360:1488 \
      RRA:MIN:0.3:4320:1460 \
      RRA:MAX:0.3:6:2880 \
      RRA:MAX:0.3:60:2016 \
      RRA:MAX:0.3:360:1488 \
      RRA:MAX:0.3:4320:1460
    fi
  if [ $OS_TYPE = "FreeBSD" ]; then
    $BINPATH/rrdtool create rrd/$DEV.rrd --step 10 \
      DS:cpuusr:GAUGE:300:0:$MAXCPU \
      DS:cpunic:GAUGE:300:0:$MAXCPU \
      DS:cpusys:GAUGE:300:0:$MAXCPU \
      DS:cpuidl:GAUGE:300:0:$MAXCPU \
      DS:cpuint:GAUGE:300:0:$MAXCPU \
      RRA:AVERAGE:0:1:720 \
      RRA:AVERAGE:0.3:6:2880 \
      RRA:AVERAGE:0.3:60:2016 \
      RRA:AVERAGE:0.3:360:1488 \
      RRA:AVERAGE:0.3:4320:1460 \
      RRA:MIN:0.3:6:2880 \
      RRA:MIN:0.3:60:2016 \
      RRA:MIN:0.3:360:1488 \
      RRA:MIN:0.3:4320:1460 \
      RRA:MAX:0.3:6:2880 \
      RRA:MAX:0.3:60:2016 \
      RRA:MAX:0.3:360:1488 \
      RRA:MAX:0.3:4320:1460
    fi
  if [ $OS_TYPE = "NetBSD" ]; then
    $BINPATH/rrdtool create rrd/$DEV.rrd --step 10 \
      DS:cpuusr:GAUGE:300:0:$MAXCPU \
      DS:cpunic:GAUGE:300:0:$MAXCPU \
      DS:cpusys:GAUGE:300:0:$MAXCPU \
      DS:cpuidl:GAUGE:300:0:$MAXCPU \
      DS:cpuint:GAUGE:300:0:$MAXCPU \
      RRA:AVERAGE:0:1:720 \
      RRA:AVERAGE:0.3:6:2880 \
      RRA:AVERAGE:0.3:60:2016 \
      RRA:AVERAGE:0.3:360:1488 \
      RRA:AVERAGE:0.3:4320:1460 \
      RRA:MIN:0.3:6:2880 \
      RRA:MIN:0.3:60:2016 \
      RRA:MIN:0.3:360:1488 \
      RRA:MIN:0.3:4320:1460 \
      RRA:MAX:0.3:6:2880 \
      RRA:MAX:0.3:60:2016 \
      RRA:MAX:0.3:360:1488 \
      RRA:MAX:0.3:4320:1460
    fi
  fi
 
if ! [ "$(echo $1|grep proc)" = "" ]; then
  DEV=$1
  echo $SECS $MODNAME: setting up database $DEV.rrd for values [0..$MAXPROC]
  $BINPATH/rrdtool create rrd/$DEV.rrd --step 10 \
    DS:procslp:GAUGE:300:0:$MAXPROC \
    DS:procrun:GAUGE:300:0:$MAXPROC \
    DS:proczmb:GAUGE:300:0:$MAXPROC \
    DS:procstp:GAUGE:300:0:$MAXPROC \
    DS:procdsc:GAUGE:300:0:$MAXPROC \
    RRA:AVERAGE:0:1:720 \
    RRA:AVERAGE:0.3:6:2880 \
    RRA:AVERAGE:0.3:60:2016 \
    RRA:AVERAGE:0.3:360:1488 \
    RRA:AVERAGE:0.3:4320:1460 \
    RRA:MIN:0.3:6:2880 \
    RRA:MIN:0.3:60:2016 \
    RRA:MIN:0.3:360:1488 \
    RRA:MIN:0.3:4320:1460 \
    RRA:MAX:0.3:6:2880 \
    RRA:MAX:0.3:60:2016 \
    RRA:MAX:0.3:360:1488 \
    RRA:MAX:0.3:4320:1460
  fi
 
if ! [ "$(echo $1|grep mem)" = "" ]; then
  DEV=$1
  echo $SECS $MODNAME: setting up database $DEV.rrd for values [0..$MAX]
  if [ $OS_TYPE = "Linux" ]; then
    $BINPATH/rrdtool create rrd/$DEV.rrd --step 10 \
      DS:memfre:GAUGE:300:0:$MAXMEM \
      DS:memshr:GAUGE:300:0:$MAXMEM \
      DS:membuf:GAUGE:300:0:$MAXMEM \
      DS:memcac:GAUGE:300:0:$MAXMEM \
      DS:swpfre:GAUGE:300:0:$MAXSWAP \
      DS:swpuse:GAUGE:300:0:$MAXSWAP \
      RRA:AVERAGE:0:1:720 \
      RRA:AVERAGE:0.3:6:2880 \
      RRA:AVERAGE:0.3:60:2016 \
      RRA:AVERAGE:0.3:360:1488 \
      RRA:AVERAGE:0.3:4320:1460 \
      RRA:MIN:0.3:6:2880 \
      RRA:MIN:0.3:60:2016 \
      RRA:MIN:0.3:360:1488 \
      RRA:MIN:0.3:4320:1460 \
      RRA:MAX:0.3:6:2880 \
      RRA:MAX:0.3:60:2016 \
      RRA:MAX:0.3:360:1488 \
      RRA:MAX:0.3:4320:1460
    fi
  if [ $OS_TYPE = "FreeBSD" ]; then
    $BINPATH/rrdtool create rrd/$DEV.rrd --step 10 \
      DS:memfree:GAUGE:300:0:$MAXMEM \
      DS:memwire:GAUGE:300:0:$MAXMEM \
      DS:memactv:GAUGE:300:0:$MAXMEM \
      DS:meminac:GAUGE:300:0:$MAXMEM \
      DS:memcach:GAUGE:300:0:$MAXMEM \
      DS:swpfre:GAUGE:300:0:$MAXSWAP \
      DS:swpuse:GAUGE:300:0:$MAXSWAP \
      RRA:AVERAGE:0:1:720 \
      RRA:AVERAGE:0.3:6:2880 \
      RRA:AVERAGE:0.3:60:2016 \
      RRA:AVERAGE:0.3:360:1488 \
      RRA:AVERAGE:0.3:4320:1460 \
      RRA:MIN:0.3:6:2880 \
      RRA:MIN:0.3:60:2016 \
      RRA:MIN:0.3:360:1488 \
      RRA:MIN:0.3:4320:1460 \
      RRA:MAX:0.3:6:2880 \
      RRA:MAX:0.3:60:2016 \
      RRA:MAX:0.3:360:1488 \
      RRA:MAX:0.3:4320:1460
    fi
  if [ $OS_TYPE = "NetBSD" ]; then
    $BINPATH/rrdtool create rrd/$DEV.rrd --step 10 \
      DS:memfree:GAUGE:300:0:$MAXMEM \
      DS:meminac:GAUGE:300:0:$MAXMEM \
      DS:memacti:GAUGE:300:0:$MAXMEM \
      DS:memwire:GAUGE:300:0:$MAXMEM \
      DS:memcach:GAUGE:300:0:$MAXMEM \
      DS:swpfre:GAUGE:300:0:$MAXSWAP \
      DS:swpuse:GAUGE:300:0:$MAXSWAP \
      RRA:AVERAGE:0:1:720 \
      RRA:AVERAGE:0.3:6:2880 \
      RRA:AVERAGE:0.3:60:2016 \
      RRA:AVERAGE:0.3:360:1488 \
      RRA:AVERAGE:0.3:4320:1460 \
      RRA:MIN:0.3:6:2880 \
      RRA:MIN:0.3:60:2016 \
      RRA:MIN:0.3:360:1488 \
      RRA:MIN:0.3:4320:1460 \
      RRA:MAX:0.3:6:2880 \
      RRA:MAX:0.3:60:2016 \
      RRA:MAX:0.3:360:1488 \
      RRA:MAX:0.3:4320:1460
    fi
  if [ $OS_TYPE = "Darwin" ]; then
    $BINPATH/rrdtool create rrd/$DEV.rrd --step 10 \
      DS:memfree:GAUGE:300:0:$MAXMEM \
      DS:memwire:GAUGE:300:0:$MAXMEM \
      DS:memactv:GAUGE:300:0:$MAXMEM \
      DS:meminac:GAUGE:300:0:$MAXMEM \
      DS:swpfre:GAUGE:300:0:$MAXSWAP \
      DS:swpuse:GAUGE:300:0:$MAXSWAP \
      RRA:AVERAGE:0:1:720 \
      RRA:AVERAGE:0.3:6:2880 \
      RRA:AVERAGE:0.3:60:2016 \
      RRA:AVERAGE:0.3:360:1488 \
      RRA:AVERAGE:0.3:4320:1460 \
      RRA:MIN:0.3:6:2880 \
      RRA:MIN:0.3:60:2016 \
      RRA:MIN:0.3:360:1488 \
      RRA:MIN:0.3:4320:1460 \
      RRA:MAX:0.3:6:2880 \
      RRA:MAX:0.3:60:2016 \
      RRA:MAX:0.3:360:1488 \
      RRA:MAX:0.3:4320:1460
    fi
  if [ $OS_TYPE = "SunOS" ]; then
    $BINPATH/rrdtool create rrd/$DEV.rrd --step 10 \
      DS:memfre:GAUGE:300:0:$MAXMEM \
      DS:memshr:GAUGE:300:0:$MAXMEM \
      DS:membuf:GAUGE:300:0:$MAXMEM \
      DS:memcac:GAUGE:300:0:$MAXMEM \
      DS:swpfre:GAUGE:300:0:$MAXSWAP \
      DS:swpuse:GAUGE:300:0:$MAXSWAP \
      RRA:AVERAGE:0:1:720 \
      RRA:AVERAGE:0.3:6:2880 \
      RRA:AVERAGE:0.3:60:2016 \
      RRA:AVERAGE:0.3:360:1488 \
      RRA:AVERAGE:0.3:4320:1460 \
      RRA:MIN:0.3:6:2880 \
      RRA:MIN:0.3:60:2016 \
      RRA:MIN:0.3:360:1488 \
      RRA:MIN:0.3:4320:1460 \
      RRA:MAX:0.3:6:2880 \
      RRA:MAX:0.3:60:2016 \
      RRA:MAX:0.3:360:1488 \
      RRA:MAX:0.3:4320:1460
    fi
  fi

if [ "$1" = "irq" ]; then
  DEV=irq
  echo $SECS $MODNAME: setting up database $DEV.rrd
  $BINPATH/rrdtool create rrd/$DEV.rrd --step 10 \
    DS:irqall:COUNTER:300:0:U \
    DS:irq00:COUNTER:300:0:U \
    DS:irq01:COUNTER:300:0:U \
    DS:irq02:COUNTER:300:0:U \
    DS:irq03:COUNTER:300:0:U \
    DS:irq04:COUNTER:300:0:U \
    DS:irq05:COUNTER:300:0:U \
    DS:irq06:COUNTER:300:0:U \
    DS:irq07:COUNTER:300:0:U \
    DS:irq08:COUNTER:300:0:U \
    DS:irq09:COUNTER:300:0:U \
    DS:irq10:COUNTER:300:0:U \
    DS:irq11:COUNTER:300:0:U \
    DS:irq12:COUNTER:300:0:U \
    DS:irq13:COUNTER:300:0:U \
    DS:irq14:COUNTER:300:0:U \
    DS:irq15:COUNTER:300:0:U \
    RRA:AVERAGE:0:1:720 \
    RRA:AVERAGE:0.3:6:2880 \
    RRA:AVERAGE:0.3:60:2016 \
    RRA:AVERAGE:0.3:360:1488 \
    RRA:AVERAGE:0.3:4320:1460 \
    RRA:MIN:0.3:6:2880 \
    RRA:MIN:0.3:60:2016 \
    RRA:MIN:0.3:360:1488 \
    RRA:MIN:0.3:4320:1460 \
    RRA:MAX:0.3:6:2880 \
    RRA:MAX:0.3:60:2016 \
    RRA:MAX:0.3:360:1488 \
    RRA:MAX:0.3:4320:1460
  fi


if ! [ "$(echo $1|grep uptime)" = "" ]; then
  DEV=$1
  echo $SECS $MODNAME: setting up database $DEV.rrd
  $BINPATH/rrdtool create rrd/$DEV.rrd --step 10 \
    DS:up:GAUGE:300:0:U \
    DS:idle:GAUGE:300:0:U \
    RRA:AVERAGE:0:1:720 \
    RRA:AVERAGE:0.3:6:2880 \
    RRA:AVERAGE:0.3:60:2016 \
    RRA:AVERAGE:0.3:360:1488 \
    RRA:AVERAGE:0.3:4320:1460 \
    RRA:MAX:0.3:6:2880 \
    RRA:MAX:0.3:60:2016 \
    RRA:MAX:0.3:360:1488 \
    RRA:MAX:0.3:4320:1460
  fi
 
# 2h        -> 720 Werte alle 10sec
# 2d = 48h  -> 2880 Werte alle 1min  (6*10sec)
# 2w = 14d  -> 2016 Werte alle 10min (60*10sec)
# 2m = 62d  -> 1488 Werte alle 1h    (360*10sec)
# 2y = 730d -> 1460 Werte alle 12h   (4320*10sec)


Powered by WebSVN 2.2.1