Blame contrib/gentcucci-1.0.0/gentcucci

Packit 667938
#!/bin/bash
Packit 667938
Packit 667938
###############################################################################
Packit 667938
# gentcucci - Generate Total Control User Count (and temp) Config and Index
Packit 667938
#             (pronounced like Gent Cookie) an MRTG Tool
Packit 667938
#
Packit 667938
# Version 1.0.0
Packit 667938
#
Packit 667938
# Copyright and written by Kevin Benton, 1999.
Packit 667938
#
Packit 667938
# Please be sure that if you choose to use this code that you let Tobi or
Packit 667938
# myself know that it's useful to you.  Tobi - thanks for writing MRTG and
Packit 667938
# making it freely available to those of us who weren't quite so creative.
Packit 667938
#
Packit 667938
# NOTE 1 - At the time of this writing, we've been using this script for over
Packit 667938
# a year and it's worked like a champ.  Don't let the version number fool
Packit 667938
# you - this stuff is tried and tested.
Packit 667938
#
Packit 667938
# NOTE 2 - Please be sure to pick the target method below.  Look for
Packit 667938
# "INTENTIONAL ERROR" in this file, uncomment the appropriate line and delete
Packit 667938
# the two "error" lines as directed.
Packit 667938
#
Packit 667938
# NOTE 3 - This could have been written in Perl to make it a lot faster, but at
Packit 667938
# the time I wrote it, I didn't know enough Perl to do it.  I certainly didn't
Packit 667938
# feel like spending the time to write it in C.  I may soon rewrite this
Packit 667938
# entire script in Perl not only to make it faster, but to clean things as far
Packit 667938
# as temp files go and what not.
Packit 667938
#
Packit 667938
# NOTE 4 - tcf2mrtg returns the number of users on-line for a particular
Packit 667938
# target.  This works on both ARCs and NetServers and gives us the ability to
Packit 667938
# split apart DSP's.  It can of course be adapted to whatever your platform
Packit 667938
# needs require.  If you only need data for the HARC aggregated together, use
Packit 667938
# the MIB .1.3.6.1.4.1.429.4.2.1.10.0 or whatever is current for the HARC code
Packit 667938
# you're using.
Packit 667938
###############################################################################
Packit 667938
Packit 667938
###############################################################################
Packit 667938
# store in users index file
Packit 667938
Packit 667938
stf() {
Packit 667938
  echo "$1" >>$TEMP_FILE
Packit 667938
}
Packit 667938
Packit 667938
###############################################################################
Packit 667938
# store in temperature index file
Packit 667938
Packit 667938
stfd() {
Packit 667938
  echo "$1" >>$TEMP_FILE2
Packit 667938
}
Packit 667938
Packit 667938
###############################################################################
Packit 667938
# store in temperature config
Packit 667938
Packit 667938
stod() {
Packit 667938
  echo "$1" >>$degree_file
Packit 667938
}
Packit 667938
Packit 667938
###############################################################################
Packit 667938
# store in users config
Packit 667938
Packit 667938
stou() {
Packit 667938
  echo "$1" >>$output_file
Packit 667938
}
Packit 667938
Packit 667938
###############################################################################
Packit 667938
Packit 667938
########################## CONFIGURATION PARAMETERS ###########################
Packit 667938
#    output_dir is where MRTG will be storing configs.  A directory www should
Packit 667938
#    exist under that with the directories tcusercount and tcdegree below that.
Packit 667938
export output_dir=/usr/local/mrtg-2.8.12/local-config
Packit 667938
#    output_file is the MRTG user count config file.
Packit 667938
export output_file=$output_dir/mrtg.tcusercount.cfg
Packit 667938
#    degree_file is the MRTG chassis temperature config file.
Packit 667938
export degree_file=$output_dir/mrtg.tcdegree.cfg
Packit 667938
#    ro_comm is the read only SNMP community to use to grab data with.
Packit 667938
export ro_comm=public
Packit 667938
########################## CONFIGURATION PARAMETERS ###########################
Packit 667938
Packit 667938
export TEMP_FILE=/tmp/gentcuc.$$
Packit 667938
export TEMP_FILE2=/tmp/gentcuc.$$.2
Packit 667938
rm -f $TEMP_FILE 2>/dev/null >/dev/null
Packit 667938
trap "rm -f $TEMP_FILE $TEMP_FILE2 2>/dev/null >/dev/null ; exit" 1 2 15
Packit 667938
touch $TEMP_FILE
Packit 667938
Packit 667938
index=${output_dir}/www/tcusercount/index.htm
Packit 667938
bigindex=${output_dir}/www/tcusercount/bigindex.htm
Packit 667938
degreeindex=${output_dir}/www/tcdegree/index.htm
Packit 667938
bigdegreeindex=${output_dir}/www/tcdegree/bigindex.htm
Packit 667938
Packit 667938
# Create mrtg.tcusercount.cfg header
Packit 667938
cat >$output_file <
Packit 667938
##################################################################
Packit 667938
# CAUTION: This file is automatically generated.  Do not edit.   #
Packit 667938
#	   Changes should be made in gwcs.list only.             #
Packit 667938
##################################################################
Packit 667938
Packit 667938
Workdir:    $output_dir
Packit 667938
Refresh:      300
Packit 667938
Interval:     5
Packit 667938
WriteExpires: Yes
Packit 667938
Packit 667938
Directory[^]: www/tcusercount/
Packit 667938
PageTop[^]: 

Packit 667938
PageTop[\$]: Total Control Chassis User Count
Packit 667938
Options[^]: gauge noinfo
Packit 667938
YLegend[^]: Users On
Packit 667938
ShortLegend[^]: Users
Packit 667938
Title[$]: Total Control Chassis User Count
Packit 667938
XZoom[^]: 2.0
Packit 667938
YZoom[^]: 2.0
Packit 667938
Packit 667938
SH_EOF1
Packit 667938
Packit 667938
# Create mrtg.tcdegree.cfg header
Packit 667938
cat >$degree_file <
Packit 667938
##################################################################
Packit 667938
# CAUTION: This file is automatically generated.  Do not edit.   #
Packit 667938
#	   Changes should be made in nmcs.list only.             #
Packit 667938
##################################################################
Packit 667938
Packit 667938
Workdir:    $output_dir
Packit 667938
Refresh:      300
Packit 667938
Interval:     5
Packit 667938
WriteExpires: Yes
Packit 667938
Directory[^]: www/tcdegree/
Packit 667938
PageTop[^]: 

Packit 667938
PageTop[\$]: Total Control Chassis Temperature
Packit 667938
Options[^]: gauge noinfo nopercent
Packit 667938
YLegend[^]: Fahrenheit
Packit 667938
ShortLegend[^]: Temp
Packit 667938
Title[$]: Total Control Chassis Temperature
Packit 667938
XZoom[^]: 2.0
Packit 667938
YZoom[^]: 2.0
Packit 667938
Packit 667938
SH_EOF2
Packit 667938
Packit 667938
# Create master index temp file
Packit 667938
stf "<HTML>"
Packit 667938
stf "<HEAD><TITLE>Total Control SED_REPLACE_WITH_NAME</TITLE></HEAD>"
Packit 667938
stf "<BODY BGCOLOR=WHITE>"
Packit 667938
stf "

Total Control SED_REPLACE_WITH_NAME

"
Packit 667938
stf "Updated `date`

"

Packit 667938
stf "Click here for SED_REPLACE_WITH_SIZE size images
"
Packit 667938
stf ""
Packit 667938
Packit 667938
# Process into mrtg.tcusercount.cfg and master user count index from gwcs.list
Packit 667938
while read line
Packit 667938
do
Packit 667938
  if echo "$line" | egrep '^#' >/dev/null 2>/dev/null
Packit 667938
  then
Packit 667938
    continue
Packit 667938
  fi
Packit 667938
  if [ -z "$line" ]
Packit 667938
  then
Packit 667938
    continue
Packit 667938
  fi
Packit 667938
  target="`echo \"$line\" | cut -d: -f1 | sed -e 's/+/ /g'`"
Packit 667938
  tag="`echo \"$line\" |         \
Packit 667938
        cut -d: -f1 |            \
Packit 667938
        sed -e 's/+/_/g' |       \
Packit 667938
        sed -e 's/\_.*\@/_/g' |  \
Packit 667938
        cut -d@ -f2`"
Packit 667938
  title="`echo \"$line\" | cut -d: -f2`"
Packit 667938
  maxb="`echo \"$line\" | cut -d: -f3`"
Packit 667938
  absm="`echo \"$line\" | cut -d: -f4`"
Packit 667938
INTENTIONAL ERROR: YOU MUST PICK 1 OF THE 2 TARGETS BELOW AND DELETE THIS LINE
Packit 667938
#  stou "Target[$tag]: \`/usr/local/mrtg-2.8.12/local-config/tcf2mrtg \"$target\"\`"
Packit 667938
#  stou "Target[$tag]: .1.3.6.1.4.1.429.4.2.1.10.0:${ro_comm}@$target"
Packit 667938
INTENTIONAL ERROR: YOU MUST PICK ONE OF THE TARGETS ABOVE AND DELETE THIS LINE
Packit 667938
  stou "Title[$tag]: $title"
Packit 667938
  stou "PageTop[$tag]: $title"
Packit 667938
  if [ ! "$absm" = "0" ]
Packit 667938
  then
Packit 667938
    stou "AbsMax[$tag]: $absm"
Packit 667938
  fi
Packit 667938
  stou "MaxBytes[$tag]: $maxb"
Packit 667938
  stou "WithPeak[$tag]: ymwd"
Packit 667938
  stou ""
Packit 667938
  stf "  "
Packit 667938
  stf "    "
Packit 667938
  stf "        <CENTER>$title
"
Packit 667938
  stf "        `/home/httpd/cgi-bin/tcnowstat \"$tag\" \"$maxb\"`
"
Packit 667938
  stf "         Potential Users: $maxb</CENTER>"
Packit 667938
  stf "    Today
5 Min"
Packit 667938
  stf "    "
Packit 667938
  stf "      "
Packit 667938
  stf "    "
Packit 667938
  stf "  "
Packit 667938
  stf "  "
Packit 667938
  stf "    This Week
30 Min"
Packit 667938
  stf "    "
Packit 667938
  stf "      "
Packit 667938
  stf "    "
Packit 667938
  stf "  "
Packit 667938
done 
Packit 667938
Packit 667938
stfd "<HTML>"
Packit 667938
stfd "<HEAD><TITLE>Total Control SED_REPLACE_WITH_NAME</TITLE></HEAD>"
Packit 667938
stfd "<BODY BGCOLOR=WHITE>"
Packit 667938
stfd "

Total Control SED_REPLACE_WITH_NAME

"
Packit 667938
stfd "Updated `date`

"

Packit 667938
stfd "Click here for SED_REPLACE_WITH_SIZE size images
"
Packit 667938
stfd ""
Packit 667938
Packit 667938
# Process into mrtg.tcusercount.cfg and master user count index from gwcs.list
Packit 667938
while read line
Packit 667938
do
Packit 667938
  if echo "$line" | egrep '^#' >/dev/null 2>/dev/null
Packit 667938
  then
Packit 667938
    continue
Packit 667938
  fi
Packit 667938
  if [ -z "$line" ]
Packit 667938
  then
Packit 667938
    continue
Packit 667938
  fi
Packit 667938
  name="`echo \"$line\" | cut -d: -f1 | sed -e 's/+/ /g'`"
Packit 667938
  tag="`echo \"$line\" | cut -d: -f1 | sed -e s/+/_/g`"
Packit 667938
  title="`echo \"$line\" | cut -d: -f2`"
Packit 667938
  stod "##################################################################"
Packit 667938
  stod "Target[$tag]: .1.3.6.1.4.1.429.1.2.2.5.0&.1.3.6.1.4.1.429.1.2.2.5.0:public@$name * 1.8 + 32"
Packit 667938
  stod "Title[$tag]: $title"
Packit 667938
  stod "PageTop[$tag]: $title"
Packit 667938
  stod "MaxBytes[$tag]: 200"
Packit 667938
  stfd "    "
Packit 667938
  stfd "        <CENTER>$title
"
Packit 667938
  stfd "        `/home/httpd/cgi-bin/tcnowtemp \"$tag\"`</CENTER>"
Packit 667938
  stfd "    Today
5 Min"
Packit 667938
  stfd "    "
Packit 667938
  stfd "      "
Packit 667938
  stfd "    "
Packit 667938
  stfd "  "
Packit 667938
  stfd "  "
Packit 667938
  stfd "    This Week
30 Min"
Packit 667938
  stfd "    "
Packit 667938
  stfd "      "
Packit 667938
  stfd "    "
Packit 667938
  stfd "  "
Packit 667938
done 
Packit 667938
Packit 667938
# close the indexes up tight
Packit 667938
stf "</BODY></HTML>"
Packit 667938
stfd "</BODY></HTML>"
Packit 667938
Packit 667938
# create normal and big indexes for user count and temperature.
Packit 667938
cat $TEMP_FILE | sed -e 's/SED_REPLACE_WITH_INDEX.HTM/bigindex.htm/g'   | \
Packit 667938
                 sed -e 's/SED_REPLACE_WITH_SIZE/double/g'              | \
Packit 667938
                 sed -e 's/SED_REPLACE_WITH_NAME/User Count Analysis/g' | \
Packit 667938
                 sed -e 's/SED_REPLACE_WITH_PICSIZE//g' >$index
Packit 667938
cat $TEMP_FILE | sed -e 's/SED_REPLACE_WITH_INDEX.HTM/index.htm/g'      | \
Packit 667938
                 sed -e 's/SED_REPLACE_WITH_SIZE/normal/g'              | \
Packit 667938
                 sed -e 's/SED_REPLACE_WITH_NAME/User Count Analysis/g' | \
Packit 667938
         sed -e 's/SED_REPLACE_WITH_PICSIZE/WIDTH=1000 HEIGHT=270/g' >$bigindex
Packit 667938
cat $TEMP_FILE2 | sed -e 's/SED_REPLACE_WITH_INDEX.HTM/bigindex.htm/g'   | \
Packit 667938
                  sed -e 's/SED_REPLACE_WITH_SIZE/double/g'              | \
Packit 667938
                  sed -e 's/SED_REPLACE_WITH_NAME/Chassis Temperature/g' | \
Packit 667938
                  sed -e 's/SED_REPLACE_WITH_PICSIZE//g' >$degreeindex
Packit 667938
cat $TEMP_FILE2 | sed -e 's/SED_REPLACE_WITH_INDEX.HTM/index.htm/g'      | \
Packit 667938
                  sed -e 's/SED_REPLACE_WITH_SIZE/normal/g'              | \
Packit 667938
                  sed -e 's/SED_REPLACE_WITH_NAME/Chassis Temperature/g' | \
Packit 667938
   sed -e 's/SED_REPLACE_WITH_PICSIZE/WIDTH=1000 HEIGHT=270/g' >$bigdegreeindex
Packit 667938
rm $TEMP_FILE $TEMP_FILE2