diff options
| author | beatrice <beatrice@dangofactory.net> | 2026-11-22 20:00:14 +0900 |
|---|---|---|
| committer | beatrice <beatrice@dangofactory.net> | 2026-11-22 20:00:14 +0900 |
| commit | 8f68d02045982da8f00a559835b500caf3a1967d (patch) | |
| tree | c8d0e92969b92e1b6559a0e032b6aa710a8ae2d9 /contrib/mrtgmk | |
| parent | bb5ff95073e5001be7dbf58ffce80d7926deff0b (diff) | |
| download | mrtg-master.tar.gz mrtg-master.zip | |
Diffstat (limited to 'contrib/mrtgmk')
37 files changed, 2590 insertions, 0 deletions
diff --git a/contrib/mrtgmk/cfg/192.168.10.1.cfg b/contrib/mrtgmk/cfg/192.168.10.1.cfg new file mode 100644 index 0000000..236f079 --- /dev/null +++ b/contrib/mrtgmk/cfg/192.168.10.1.cfg @@ -0,0 +1,79 @@ + +Target[192.168.10.1.1]: 1:public@192.168.10.1 +MaxBytes[192.168.10.1.1]: 1250000 +Title[192.168.10.1.1]: : Serial0 +PageTop[192.168.10.1.1]: <H1>Traffic Analysis for Serial0 + </H1> + <TABLE> + <TR><TD>System:</TD><TD>local-gw in </TD></TR> + <TR><TD>Maintainer:</TD><TD></TD></TR> + <TR><TD>Interface:</TD><TD>Serial0 (1)</TD></TR> + <TR><TD>IP:</TD><TD>local-gw (192.168.10.1)</TD></TR> + <TR><TD>Max Speed:</TD> + <TD>1250.0 kBytes/s</TD></TR> + </TABLE> + +#---------------------------------------------------------------------- + +Target[192.168.10.1.2]: 2:public@192.168.10.1 +MaxBytes[192.168.10.1.2]: 1250000 +Title[192.168.10.1.2]: : Serial1 +PageTop[192.168.10.1.2]: <H1>Traffic Analysis for Serial1 + </H1> + <TABLE> + <TR><TD>System:</TD><TD>local-gw in </TD></TR> + <TR><TD>Maintainer:</TD><TD></TD></TR> + <TR><TD>Interface:</TD><TD>Serial1 (2)</TD></TR> + <TR><TD>IP:</TD><TD>local-gw (192.168.10.1)</TD></TR> + <TR><TD>Max Speed:</TD> + <TD>1250.0 kBytes/s</TD></TR> + </TABLE> + +#---------------------------------------------------------------------- + +Target[192.168.10.1.3]: 3:public@192.168.10.1 +MaxBytes[192.168.10.1.3]: 1250000 +Title[192.168.10.1.3]: : Serial2 +PageTop[192.168.10.1.3]: <H1>Traffic Analysis for Serial2 + </H1> + <TABLE> + <TR><TD>System:</TD><TD>local-gw in </TD></TR> + <TR><TD>Maintainer:</TD><TD></TD></TR> + <TR><TD>Interface:</TD><TD>Serial2 (3)</TD></TR> + <TR><TD>IP:</TD><TD>local-gw (192.168.10.1)</TD></TR> + <TR><TD>Max Speed:</TD> + <TD>1250.0 kBytes/s</TD></TR> + </TABLE> + +#---------------------------------------------------------------------- + +Target[192.168.10.1.4]: 4:public@192.168.10.1 +MaxBytes[192.168.10.1.4]: 1250000 +Title[192.168.10.1.4]: : Serial3 +PageTop[192.168.10.1.4]: <H1>Traffic Analysis for Serial3 + </H1> + <TABLE> + <TR><TD>System:</TD><TD>local-gw in </TD></TR> + <TR><TD>Maintainer:</TD><TD></TD></TR> + <TR><TD>Interface:</TD><TD>Serial0 (1)</TD></TR> + <TR><TD>IP:</TD><TD>local-gw (192.168.10.1)</TD></TR> + <TR><TD>Max Speed:</TD> + <TD>1250.0 kBytes/s</TD></TR> + </TABLE> + +#---------------------------------------------------------------------- + +Target[192.168.10.1.5]: 5:public@192.168.10.1 +MaxBytes[192.168.10.1.5]: 1250000 +Title[192.168.10.1.5]: : Serial4 +PageTop[192.168.10.1.5]: <H1>Traffic Analysis for Serial4 + </H1> + <TABLE> + <TR><TD>System:</TD><TD>local-gw in </TD></TR> + <TR><TD>Maintainer:</TD><TD></TD></TR> + <TR><TD>Interface:</TD><TD>Serial4 (5)</TD></TR> + <TR><TD>IP:</TD><TD>local-gw (192.168.10.1)</TD></TR> + <TR><TD>Max Speed:</TD> + <TD>1250.0 kBytes/s</TD></TR> + </TABLE> + diff --git a/contrib/mrtgmk/cfg/EXAMPLE1 b/contrib/mrtgmk/cfg/EXAMPLE1 new file mode 100755 index 0000000..012d94a --- /dev/null +++ b/contrib/mrtgmk/cfg/EXAMPLE1 @@ -0,0 +1,3 @@ +#!/bin/bash + +../mrtgmk convert.cfg diff --git a/contrib/mrtgmk/cfg/a.cfg b/contrib/mrtgmk/cfg/a.cfg new file mode 100644 index 0000000..36a6b23 --- /dev/null +++ b/contrib/mrtgmk/cfg/a.cfg @@ -0,0 +1,21 @@ +# We have here cfg/ appended in front of each file path because +# all this files are relative to the directory from where we +# start the mrtgmk. + +0 MRTG.CFG cfg/mrtg.cfg cfg/mrtg_cfg +0 INCLUDE cfg/alias.cfg +0 INCLUDE cfg/misc.cfg +0 MKD 192.168.10.1.cfg cfg/today.html +0 INCLUDE cfg/hosts.cfg + +0 MSG +0 MSG I create the thml pages +0 INCLUDE cfg/page1.cfg +0 INCLUDE cfg/page2.cfg + +0 MSG +0 MSG I create a special directory in cfg, +0 MSG with links through pcn's graphs for admin of pcn +0 INCLUDE cfg/links.cfg + +0 MSG diff --git a/contrib/mrtgmk/cfg/alias.cfg b/contrib/mrtgmk/cfg/alias.cfg new file mode 100644 index 0000000..b361c3e --- /dev/null +++ b/contrib/mrtgmk/cfg/alias.cfg @@ -0,0 +1,4 @@ +0 CHECK4ALIAS yes +0 ALIAS date 07/12/1999 +0 ALIAS time 12:25 am +0 ALIAS author Iulian Radu (iulian_r@starnets.ro)
\ No newline at end of file diff --git a/contrib/mrtgmk/cfg/convert.cfg b/contrib/mrtgmk/cfg/convert.cfg new file mode 100644 index 0000000..5bf5806 --- /dev/null +++ b/contrib/mrtgmk/cfg/convert.cfg @@ -0,0 +1,11 @@ +# We have here cfg/ appended in front of each file path because +# all this files are relative to the directory from where we +# start the mrtgmk. + +0 MRTG.CFG mrtg.cfg mrtg_cfg +0 MSG +0 MSG I change the files name +0 CONVIP2NAME /usr/tardis/pub/www/stats/mrtg/ +0 CHNGTRGNAME yes +0 INCLUDE hosts.cfg +0 MSG diff --git a/contrib/mrtgmk/cfg/hosts.cfg b/contrib/mrtgmk/cfg/hosts.cfg new file mode 100644 index 0000000..831bc46 --- /dev/null +++ b/contrib/mrtgmk/cfg/hosts.cfg @@ -0,0 +1,4 @@ +0 CFGDIR cfg +0 DEFHOST pc1 192.168.10.1.cfg serial0 +0 DEFHOST pc2 192.168.10.1.cfg serial2 +0 DEFHOST pc3 192.168.10.1.cfg serial3 diff --git a/contrib/mrtgmk/cfg/links.cfg b/contrib/mrtgmk/cfg/links.cfg new file mode 100644 index 0000000..a26e37a --- /dev/null +++ b/contrib/mrtgmk/cfg/links.cfg @@ -0,0 +1,4 @@ +# use the same directory like the one defined in mrtg_cfg +0 MKLINK cfg/link_pc1 pc1 /usr/tardis/pub/www/stats/mrtg +0 MKLINK cfg/link_pc2 pc2 /usr/tardis/pub/www/stats/mrtg +0 MKLINK cfg/link_pc3 pc3 /usr/tardis/pub/www/stats/mrtg diff --git a/contrib/mrtgmk/cfg/misc.cfg b/contrib/mrtgmk/cfg/misc.cfg new file mode 100644 index 0000000..005e95e --- /dev/null +++ b/contrib/mrtgmk/cfg/misc.cfg @@ -0,0 +1,6 @@ +0 MSG cfg file made by %author% +0 BASE traffic.isp.ro + +0 MSG pc1 is %HOST_pc1% +0 MSG pc2 is %HOST_pc2% +0 MSG pc3 is %HOST_pc3% diff --git a/contrib/mrtgmk/cfg/mrtg.cfg b/contrib/mrtgmk/cfg/mrtg.cfg new file mode 100644 index 0000000..5a471bd --- /dev/null +++ b/contrib/mrtgmk/cfg/mrtg.cfg @@ -0,0 +1,583 @@ +###################################################################### +# Multi Router Traffic Grapher -- Example Configuration File +###################################################################### +# +# * copy this file to ../run and call it mrtg.cfg +# * consider using ../run/cfgmaker to build your initial mrtg.cfg file +# +# This file is for use with mrtg-2.x +# +# Note: +# +# * Keywords must start at the begin of a line. +# +# * Lines which follow a keyword line which do start +# with a blank are appended to the keyword line +# +# * Empty Lines are ignored +# +# * Lines starting with a # sign are comments. + + +# #################### +# Global Configuration +# #################### + +# Where should the logfiles, and webpages be created? + +WorkDir: /usr/tardis/pub/www/stats/mrtg +Options[_]: growright,bits + +# -------------------------- +# Optional Global Parameters +# -------------------------- + +# How many seconds apart should the browser (Netscape) be +# instructed to reload the page? If this is not defined, the +# default is 300 seconds (5 minutes). + +# Refresh: 600 + +# How often do you call mrtg? The default is 5 minutes. If +# you call it less often, you should specify it here. This +# does two things: + +# a) the generated HTML page does contain the right +# information about the calling interval ... + +# b) a META header in the generated HTML page will instruct +# caches about the time to live of this page ..... + +# In this example we tell mrtg that we will be calling it +# every 10 minutes. If you are calling mrtg every 5 +# minutes, you can leave this line commented out. + +# Interval: 10 + +# With this switch mrtg will generate .meta files for CERN +# and Apache servers which contain Expiration tags for the +# html and gif files. The *.meta files will be created in +# the same directory as the other files, so you might have +# to set "MetaDir ." in your srm.conf file for this to work +# +# NOTE: If you are running Apache-1.2 you can use the mod_expire +# to achieve the same effect ... see the file htaccess-dist + +#WriteExpires: Yes + + +# If you want to keep the mrtg icons in some place other than the +# working directory, use the IconDir varibale to give its url. + +# IconDir: /mrtgicons/ + + +# ################################################# +# Configuration for each Target you want to monitor +# ################################################# + +# The configuration keywords "Target" must be followed by a +# unique name. This will also be the name used for the +# webpages, logfiles and gifs created for that target. + +# Note that the "Target" sections can be auto-generated with +# the cfgmaker tool. Check readme.html for instructions. +# ======== + +## +## Target ---------------------------------------- +## + +# With the "Target" keyword you tell mrtg what it should +# monitor. The "Target" keyword takes arguments in a wide +# range of formats: + +# * The most basic format is "port:community@router" +# This will generate a traffic graph for port 'port' +# of the router 'router' and it will use the community +# 'community' for the snmp query. + +# Target[ezwf]: 2:public@wellfleet-fddi.ethz.ch + +# * Sometimes you are sitting on the wrong side of the +# link. And you would like to have mrtg report Incoming +# traffic as outgoing and visa versa. This can be achieved +# by adding the '-' sign in front of the "Target" +# description. It flips the in and outgoing traffic rates. + +# Target[ezci]: -1:public@ezci-ether.ethz.ch + +# * You can also explicitly define the OID to query by using the +# following syntax 'OID_1&OID_2:community@router' +# The following example will retrieve error input and output +# octets/sec on interface 1. MRTG needs to graph two values, so +# you need to specify two OID's such as temperature and humidity +# or error input and error output. + +# Target[ezwf]: 1.3.6.1.2.1.2.2.1.14.1&1.3.6.1.2.1.2.2.1.20.1:public@myrouter + +# * mrtg knows a number of symbolical SNMP variable +# names. See the file mibhelp.txt for a list of known +# names. One example are the ifInErrors and and ifOutErrors +# names. This means you can specify the above as: + +# Target[ezwf]: ifInErrors.1&ifOutErrors.1:public@myrouter + +# * if you want to monitor something which does not provide +# data via snmp you can use some external program to do +# the data gathering. + +# +# The external command must return 4 lines of output: +# Line 1 : current state of the 'incoming bytes counter' +# Line 2 : current state of the 'outgoing bytes counter' +# Line 3 : string, telling the uptime of the target. +# Line 4 : string, telling the name of the target. + +# Depending on the type of data your script returns you +# might want to use the 'gauge' or 'absolute' arguments +# for the "Options" keyword. + +# Target[ezwf]: `/usr/local/bin/df2mrtg /dev/dsk/c0t2d0s0` + +# * You can also use several statements in a mathematical +# expression. This could be used to aggregate both B channels +# in an ISDN connection or multiple T1's that are aggregated +# into a single channel for greater bandwidth. +# Note the whitespace arround the target definitions. + +# Target[ezwf]: 2:public@wellfleetA + 1:public@wellfleetA +# * 4:public@ciscoF + +## +## RouterUptime --------------------------------------- +## +# +# In cases where you calculate the used bandwidth from +# several interfaces you normaly don't get the routeruptime +# and routername displayed on the web page. +# If this interface are on the same router and the uptime and +# name should be displayed nevertheless you have to specify +# its community and address again with the RouterUptime keyword. + +# Target[kacisco]: 1:public@194.64.66.250 + 2:public@194.64.66.250 +# RouterUptime[kacisco]: public@194.64.66.250 + +## +## RouterName ----------------------------------------- +## +# + +# If the default name of the router is incorrect/uninformative, +# you can use RouterName to specify a different OID on either the +# same or a different host. + +# Use 1.3.6.1.4.1.4779.1.1.3.0 on the same host: +# RouterName[kacisco]: 1.3.6.1.4.1.4779.1.1.3.0 + +# Use 1.3.6.1.4.1.4779.1.1.3.0 on a differnet host (194.64.66.251): +# RouterName[kacisco]: 1.3.6.1.4.1.4779.1.1.3.0:public@194.64.66.251 + + +## +## MaxBytes ------------------------------------------- +## + +# How many bytes per second can this port carry. Since most +# links are rated in bits per second, you need to divide +# their maximum bandwidth (in bits) by eight (8) in order to get +# bytes per second. This is very important to make your +# unscaled graphs display realistic information. +# T1 = 193000, 56K = 7000, Ethernet = 1250000. The "MaxBytes" +# value will be used by mrtg to decide whether it got a +# valid response from the router. If a number higher than +# "MaxBytes" is returned, it is ignored. Also read the section +# on AbsMax for further info. + +# MaxBytes[ezwf]: 1250000 + +## +## Title ----------------------------------------------- +## + +# Title for the HTML page which gets generated for the graph. + +# Title[ezwf]: Traffic Analysis for ETZ C 95.1 + +## +## PageTop --------------------------------------------- +## + +# Things to add to the top of the generated HTML page. Note +# that you can have several lines of text as long as the +# first column is empty. +# Note that the continuation lines will all end up on the same +# line in the html page. If you want linebreaks in the generated +# html use the '\n' sequence. + +# PageTop[ezwf]: <H1>Traffic Analysis for ETZ C95.1</H1> +# Our Campus Backbone runs over an FDDI line\n +# with a maximum transfer rate of 12.5 Mega Bytes per +# Second. + +## +## PageFoot --------------------------------------------- +## + +# Things to add at the very end of the mrtg generated html page + +# PageFoot[ezwf]: <HR size=2 noshade>This page is managed by Blubber + +# -------------------------------------------------- +# Optional Target Configuration Tags +# -------------------------------------------------- + +## +## AddHead ----------------------------------------- +## + +# Use this tag like the PageTop header, but its contents +# will be added between </TITLE> and </HEAD>. + +# AddHead[ezwf]: <!-- Just a comment for fun --> + +## +## AbsMax ------------------------------------------ +## + +# If you are monitoring a link which can handle more traffic +# than the MaxBytes value. Eg, a line which uses compression +# or some frame relay link, you can use the AbsMax keyword +# to give the absolute maximum value ever to be reached. We +# need to know this in order to sort out unrealistic values +# returned by the routers. If you do not set absmax, rateup +# will ignore values higher then MaxBytes. + +# AbsMax[ezwf]: 2500000 + +## +## Unscaled ------------------------------------------ +## + +# By default each graph is scaled vertically to make the +# actual data visible even when it is much lower than +# MaxBytes. With the "Unscaled" variable you can suppress +# this. It's argument is a string, containing one letter +# for each graph you don't want to be scaled: d=day w=week +# m=month y=year. In the example I suppress scaling for the +# yearly and the monthly graph. + +# Unscaled[ezwf]: ym + +## +## WithPeak ------------------------------------------ +## + +# By default the graphs only contain the average transfer +# rates for incoming and outgoing traffic. The +# following option instructs mrtg to display the peak +# 5 minute transfer rates in the [w]eekly, [m]onthly and +# [y]early graph. In the example we define the monthly +# and the yearly graph to contain peak as well as average +# values. + +# WithPeak[ezwf]: ym + +## +## Supress ------------------------------------------ +## + +# By Default mrtg produces 4 graphs. With this option you +# can suppress the generation of selected graphs. The format +# is analog to the above option. In this example we suppress +# the yearly graph as it is quite empty in the beginning. + +# Suppress[ezwf]: y + +## +## Directory +## + +# By default, mrtg puts all the files that it generates for each +# router (the GIFs, the HTML page, the log file, etc.) in WorkDir. +# If the "Directory" option is specified, the files are instead put +# into a directory under WorkDir. (For example, given the options in +# this mrtg.cfg-dist file, the "Directory" option below would cause all +# the ezwf files to be put into /usr/tardis/pub/www/stats/mrtg/ezwf .) +# +# The directory must already exist; mrtg will not create it. + +# Directory[ezwf]: ezwf + +## +## XSize and YSize ------------------------------------------ +## + +# By Default mrtgs graphs are 100 by 400 pixels wide (plus +# some more for the labels. In the example we get almost +# square graphs ... +# Note: XSize must be between 20 and 600 +# YSize must be larger than 20 + +# XSize[ezwf]: 300 +# YSize[ezwf]: 300 + +## +## XZoom YZoom ------------------------------------------------- +## + +# If you want your graphs to have larger pixels, you can +# "Zoom" them. + +#XZoom[ezwf]: 2.0 +#YZoom[ezwf]: 2.0 + +## +## XScale YScale ------------------------------------------------- +## + +# If you want your graphs to be actually scaled use XScale +# and YScale. (Beware while this works, the results look ugly +# (to be frank) so if someone wants fix this: patches are +# welcome. + +# XScale[ezwf]: 1.5 +# YScale[ezwf]: 1.5 + + +## +## Step ----------------------------------------------------------- +## + +# Change the default step with from 5 * 60 seconds to +# something else I have not tested this well ... + +# Step[ezwf]: 60 + +## +## Options ------------------------------------------ +## + +# The "Options" Keyword allows you to set some boolean +# switches: +# +# growright - The graph grows to the left by default. +# +# bits - All the numbers printed are in bits instead +# of bytes ... looks much more impressive :-) +# +# noinfo - Supress the information about uptime and +# device name in the generated webpage. +# +# absolute - This is for data sources which reset their +# value when they are read. This means that +# rateup has not to build the difference between +# this and the last value read from the data +# source. Useful for external data gatherers. +# +# gauge - Treat the values gathered from target as absolute +# and not as counters. This would be useful to +# monitor things like diskspace, load and so +# on .... +# +# nopercent Don't print usage percentages +# +# integer Print only integers in the summary +# below the graph (No Kilo, Mega, Gigas) ... +# + +# Options[ezwf]: growright, bits + +## +## Colours ------------------------------------------ +## + +# The "Colours" tag allows you to override the default colour +# scheme. Note: All 4 of the required colours must be +# specified here The colour name ('Colourx' below) is the +# legend name displayed, while the RGB value is the real +# colour used for the display, both on the graph and n the +# html doc. + +# Format is: Colour1#RRGGBB,Colour2#RRGGBB,Colour3#RRGGBB,Colour4#RRGGBB +# where: Colour1 = Input on default graph +# Colour2 = Output on default graph +# Colour3 = Max input +# Colour4 = Max output +# RRGGBB = 2 digit hex values for Red, Green and Blue + +# Colours[ezwf]: GREEN#00eb0c,BLUE#1000ff,DARK GREEN#006600,VIOLET#ff00ff + +## +## Background ------------------------------------------ +## + +# With the "Background" tag you can configure the background +# colour of the generated HTML page + +# Background[ezwf]: #a0a0a0a + +## +## YLegend, ShortLegend, Legend[1234] ------------------ +## + +# The following keywords allow you to override the text +# displayed for the various legends of the graph and in the +# HTML document +# +# * YLegend : The Y-Axis of the graph +# * ShortLegend: The 'b/s' string used for Max, Average and Current +# * Legend[1234IO]: The strings for the colour legend +# +#YLegend[ezwf]: Bits per Second +#ShortLegend[ezwf]: b/s +#Legend1[ezwf]: Incoming Traffic in Bits per Second +#Legend2[ezwf]: Outgoing Traffic in Bits per Second +#Legend3[ezwf]: Maximal 5 Minute Incoming Traffic +#Legend4[ezwf]: Maximal 5 Minute Outgoing Traffic +#LegendI[ezwf]: In: +#LegendO[ezwf]: Out: +# Note, if LegendI or LegendO are set to an empty string with +# LegendO[ezwf]: +# The corresponding line below the graph will not be printed at all. + +# If you live in an international world, you might want to +# generate the graphs in different timezones. This is set in the +# TZ variable. Under certain operating systems like Solaris, +# this will provoke the localtime call to giv the time in +# the selected timezone ... + +# Timezone[ezwf]: Japan + +# The Timezone is the standard Solaris timezone, ie Japan, Hongkong, +# GMT, GMT+1 etc etc. + +# By default, mrtg (actually rateup) uses the strftime(3) '%W' option +# to format week numbers in the monthly graphs. The exact semantics +# of this format option vary between systems. If you find that the +# week numbers are wrong, and your system's strftime(3) routine +# supports it, you can try another format option. The POSIX '%V' +# option seems to correspond to a widely used week numbering +# convention. The week format character should be specified as a +# single letter; either W, V, or U. + +# Weekformat[ezwf]: V + +# ############################# +# Two very special Target names +# ############################# + +# To save yourself some typing you can define a target +# called '^'. The text of every Keyword you define for this +# target will be PREPENDED to the corresponding Keyword of +# all the targets defined below this line. The same goes for +# a Target called '$' but its options will be APPENDED. +# +# The example will make mrtg use a common header and a +# common contact person in all the pages generated from +# targets defined later in this file. +# +#PageTop[^]: <H1>NoWhere Unis Traffic Stats</H1><HR> +#PageTop[$]: Contact Peter Norton if you have any questions<HR> + + +################################################################## +################################################################## +################################################################## +# +# Now some example mrtg.cfg files +# +################################################################## +################################################################## +################################################################## + +# Minimal mrtg.cfg +#-------------------- + +#WorkDir: /usr/tardis/pub/www/stats/mrtg +#Target[r1]: 2:public@myrouter.somplace.edu +#MaxBytes[r1]: 64000 +#Title[r1]: Traffic Analysis ISDN +#PageTop[r1]: <H1>Stats for our ISDN Line</H1> + + +# Minimal Cfg for several Routers. +#--------------------------------- +#WorkDir: /usr/tardis/pub/www/stats/mrtg +# +#Title[^]: Traffic Analysis for +#PageTop[^]: <H1>Stats for our +#PageTop[$]: Contact The Chief if you notice anybody<HR> +# +#Title[isdn]: our ISDN Line +#PageTop[isdn]: our ISDN Line </H1> +#Target[isdn]: 2:public@router.somplace.edu +#MaxBytes[isdn]: 64000 +# +#Title[backb]: our Campus Backbone +#PageTop[backb]: our Campus Backbone </H1> +#Target[backb]: 1:public@router.somplace.edu +#MaxBytes[backb]: 1250000 + +# the following line removes the default prepend value +# defined above +#Title[^]: +#Title[isdn2]: Traffic for the Backup ISDN Line +#PageTop[isdn2]: our ISDN Line </H1> +#Target[isdn2]: 3:public@router.somplace.edu +#MaxBytes[isdn2]: 64000 +#---------------------------------------------------------------------- + +#host pc1, cfgfile cfg/192.168.10.1.cfg, port serial0 + +Target[192.168.10.1.1]: 1:public@192.168.10.1 +MaxBytes[192.168.10.1.1]: 1250000 +Title[192.168.10.1.1]: : Serial0 +PageTop[192.168.10.1.1]: <H1>Traffic Analysis for Serial0 + </H1> + <TABLE> + <TR><TD>System:</TD><TD>local-gw in </TD></TR> + <TR><TD>Maintainer:</TD><TD></TD></TR> + <TR><TD>Interface:</TD><TD>Serial0 (1)</TD></TR> + <TR><TD>IP:</TD><TD>local-gw (192.168.10.1)</TD></TR> + <TR><TD>Max Speed:</TD> + <TD>1250.0 kBytes/s</TD></TR> + </TABLE> + +#---------------------------------------------------------------------- + +#host pc2, cfgfile cfg/192.168.10.1.cfg, port serial2 + +Target[192.168.10.1.3]: 3:public@192.168.10.1 +MaxBytes[192.168.10.1.3]: 1250000 +Title[192.168.10.1.3]: : Serial2 +PageTop[192.168.10.1.3]: <H1>Traffic Analysis for Serial2 + </H1> + <TABLE> + <TR><TD>System:</TD><TD>local-gw in </TD></TR> + <TR><TD>Maintainer:</TD><TD></TD></TR> + <TR><TD>Interface:</TD><TD>Serial2 (3)</TD></TR> + <TR><TD>IP:</TD><TD>local-gw (192.168.10.1)</TD></TR> + <TR><TD>Max Speed:</TD> + <TD>1250.0 kBytes/s</TD></TR> + </TABLE> + +#---------------------------------------------------------------------- + +#host pc3, cfgfile cfg/192.168.10.1.cfg, port serial3 + +Target[192.168.10.1.4]: 4:public@192.168.10.1 +MaxBytes[192.168.10.1.4]: 1250000 +Title[192.168.10.1.4]: : Serial3 +PageTop[192.168.10.1.4]: <H1>Traffic Analysis for Serial3 + </H1> + <TABLE> + <TR><TD>System:</TD><TD>local-gw in </TD></TR> + <TR><TD>Maintainer:</TD><TD></TD></TR> + <TR><TD>Interface:</TD><TD>Serial0 (1)</TD></TR> + <TR><TD>IP:</TD><TD>local-gw (192.168.10.1)</TD></TR> + <TR><TD>Max Speed:</TD> + <TD>1250.0 kBytes/s</TD></TR> + </TABLE> + +#---------------------------------------------------------------------- diff --git a/contrib/mrtgmk/cfg/mrtg_cfg b/contrib/mrtgmk/cfg/mrtg_cfg new file mode 100644 index 0000000..ba0a137 --- /dev/null +++ b/contrib/mrtgmk/cfg/mrtg_cfg @@ -0,0 +1,512 @@ +###################################################################### +# Multi Router Traffic Grapher -- Example Configuration File +###################################################################### +# +# * copy this file to ../run and call it mrtg.cfg +# * consider using ../run/cfgmaker to build your initial mrtg.cfg file +# +# This file is for use with mrtg-2.x +# +# Note: +# +# * Keywords must start at the begin of a line. +# +# * Lines which follow a keyword line which do start +# with a blank are appended to the keyword line +# +# * Empty Lines are ignored +# +# * Lines starting with a # sign are comments. + + +# #################### +# Global Configuration +# #################### + +# Where should the logfiles, and webpages be created? + +WorkDir: /usr/tardis/pub/www/stats/mrtg +Options[_]: growright,bits + +# -------------------------- +# Optional Global Parameters +# -------------------------- + +# How many seconds apart should the browser (Netscape) be +# instructed to reload the page? If this is not defined, the +# default is 300 seconds (5 minutes). + +# Refresh: 600 + +# How often do you call mrtg? The default is 5 minutes. If +# you call it less often, you should specify it here. This +# does two things: + +# a) the generated HTML page does contain the right +# information about the calling interval ... + +# b) a META header in the generated HTML page will instruct +# caches about the time to live of this page ..... + +# In this example we tell mrtg that we will be calling it +# every 10 minutes. If you are calling mrtg every 5 +# minutes, you can leave this line commented out. + +# Interval: 10 + +# With this switch mrtg will generate .meta files for CERN +# and Apache servers which contain Expiration tags for the +# html and gif files. The *.meta files will be created in +# the same directory as the other files, so you might have +# to set "MetaDir ." in your srm.conf file for this to work +# +# NOTE: If you are running Apache-1.2 you can use the mod_expire +# to achieve the same effect ... see the file htaccess-dist + +#WriteExpires: Yes + + +# If you want to keep the mrtg icons in some place other than the +# working directory, use the IconDir varibale to give its url. + +# IconDir: /mrtgicons/ + + +# ################################################# +# Configuration for each Target you want to monitor +# ################################################# + +# The configuration keywords "Target" must be followed by a +# unique name. This will also be the name used for the +# webpages, logfiles and gifs created for that target. + +# Note that the "Target" sections can be auto-generated with +# the cfgmaker tool. Check readme.html for instructions. +# ======== + +## +## Target ---------------------------------------- +## + +# With the "Target" keyword you tell mrtg what it should +# monitor. The "Target" keyword takes arguments in a wide +# range of formats: + +# * The most basic format is "port:community@router" +# This will generate a traffic graph for port 'port' +# of the router 'router' and it will use the community +# 'community' for the snmp query. + +# Target[ezwf]: 2:public@wellfleet-fddi.ethz.ch + +# * Sometimes you are sitting on the wrong side of the +# link. And you would like to have mrtg report Incoming +# traffic as outgoing and visa versa. This can be achieved +# by adding the '-' sign in front of the "Target" +# description. It flips the in and outgoing traffic rates. + +# Target[ezci]: -1:public@ezci-ether.ethz.ch + +# * You can also explicitly define the OID to query by using the +# following syntax 'OID_1&OID_2:community@router' +# The following example will retrieve error input and output +# octets/sec on interface 1. MRTG needs to graph two values, so +# you need to specify two OID's such as temperature and humidity +# or error input and error output. + +# Target[ezwf]: 1.3.6.1.2.1.2.2.1.14.1&1.3.6.1.2.1.2.2.1.20.1:public@myrouter + +# * mrtg knows a number of symbolical SNMP variable +# names. See the file mibhelp.txt for a list of known +# names. One example are the ifInErrors and and ifOutErrors +# names. This means you can specify the above as: + +# Target[ezwf]: ifInErrors.1&ifOutErrors.1:public@myrouter + +# * if you want to monitor something which does not provide +# data via snmp you can use some external program to do +# the data gathering. + +# +# The external command must return 4 lines of output: +# Line 1 : current state of the 'incoming bytes counter' +# Line 2 : current state of the 'outgoing bytes counter' +# Line 3 : string, telling the uptime of the target. +# Line 4 : string, telling the name of the target. + +# Depending on the type of data your script returns you +# might want to use the 'gauge' or 'absolute' arguments +# for the "Options" keyword. + +# Target[ezwf]: `/usr/local/bin/df2mrtg /dev/dsk/c0t2d0s0` + +# * You can also use several statements in a mathematical +# expression. This could be used to aggregate both B channels +# in an ISDN connection or multiple T1's that are aggregated +# into a single channel for greater bandwidth. +# Note the whitespace arround the target definitions. + +# Target[ezwf]: 2:public@wellfleetA + 1:public@wellfleetA +# * 4:public@ciscoF + +## +## RouterUptime --------------------------------------- +## +# +# In cases where you calculate the used bandwidth from +# several interfaces you normaly don't get the routeruptime +# and routername displayed on the web page. +# If this interface are on the same router and the uptime and +# name should be displayed nevertheless you have to specify +# its community and address again with the RouterUptime keyword. + +# Target[kacisco]: 1:public@194.64.66.250 + 2:public@194.64.66.250 +# RouterUptime[kacisco]: public@194.64.66.250 + +## +## MaxBytes ------------------------------------------- +## + +# How many bytes per second can this port carry. Since most +# links are rated in bits per second, you need to divide +# their maximum bandwidth (in bits) by eight (8) in order to get +# bytes per second. This is very important to make your +# unscaled graphs display realistic information. +# T1 = 193000, 56K = 7000, Ethernet = 1250000. The "MaxBytes" +# value will be used by mrtg to decide whether it got a +# valid response from the router. If a number higher than +# "MaxBytes" is returned, it is ignored. Also read the section +# on AbsMax for further info. + +# MaxBytes[ezwf]: 1250000 + +## +## Title ----------------------------------------------- +## + +# Title for the HTML page which gets generated for the graph. + +# Title[ezwf]: Traffic Analysis for ETZ C 95.1 + +## +## PageTop --------------------------------------------- +## + +# Things to add to the top of the generated HTML page. Note +# that you can have several lines of text as long as the +# first column is empty. +# Note that the continuation lines will all end up on the same +# line in the html page. If you want linebreaks in the generated +# html use the '\n' sequence. + +# PageTop[ezwf]: <H1>Traffic Analysis for ETZ C95.1</H1> +# Our Campus Backbone runs over an FDDI line\n +# with a maximum transfer rate of 12.5 Mega Bytes per +# Second. + +## +## PageFoot --------------------------------------------- +## + +# Things to add at the very end of the mrtg generated html page + +# PageFoot[ezwf]: <HR size=2 noshade>This page is managed by Blubber + +# -------------------------------------------------- +# Optional Target Configuration Tags +# -------------------------------------------------- + +## +## AddHead ----------------------------------------- +## + +# Use this tag like the PageTop header, but its contents +# will be added between </TITLE> and </HEAD>. + +# AddHead[ezwf]: <!-- Just a comment for fun --> + +## +## AbsMax ------------------------------------------ +## + +# If you are monitoring a link which can handle more traffic +# than the MaxBytes value. Eg, a line which uses compression +# or some frame relay link, you can use the AbsMax keyword +# to give the absolute maximum value ever to be reached. We +# need to know this in order to sort out unrealistic values +# returned by the routers. If you do not set absmax, rateup +# will ignore values higher then MaxBytes. + +# AbsMax[ezwf]: 2500000 + +## +## Unscaled ------------------------------------------ +## + +# By default each graph is scaled vertically to make the +# actual data visible even when it is much lower than +# MaxBytes. With the "Unscaled" variable you can suppress +# this. It's argument is a string, containing one letter +# for each graph you don't want to be scaled: d=day w=week +# m=month y=year. In the example I suppress scaling for the +# yearly and the monthly graph. + +# Unscaled[ezwf]: ym + +## +## WithPeak ------------------------------------------ +## + +# By default the graphs only contain the average transfer +# rates for incoming and outgoing traffic. The +# following option instructs mrtg to display the peak +# 5 minute transfer rates in the [w]eekly, [m]onthly and +# [y]early graph. In the example we define the monthly +# and the yearly graph to contain peak as well as average +# values. + +# WithPeak[ezwf]: ym + +## +## Supress ------------------------------------------ +## + +# By Default mrtg produces 4 graphs. With this option you +# can suppress the generation of selected graphs. The format +# is analog to the above option. In this example we suppress +# the yearly graph as it is quite empty in the beginning. + +# Suppress[ezwf]: y + +## +## Directory +## + +# By default, mrtg puts all the files that it generates for each +# router (the GIFs, the HTML page, the log file, etc.) in WorkDir. +# If the "Directory" option is specified, the files are instead put +# into a directory under WorkDir. (For example, given the options in +# this mrtg.cfg-dist file, the "Directory" option below would cause all +# the ezwf files to be put into /usr/tardis/pub/www/stats/mrtg/ezwf .) +# +# The directory must already exist; mrtg will not create it. + +# Directory[ezwf]: ezwf + +## +## XSize and YSize ------------------------------------------ +## + +# By Default mrtgs graphs are 100 by 400 pixels wide (plus +# some more for the labels. In the example we get almost +# square graphs ... +# Note: XSize must be between 20 and 600 +# YSize must be larger than 20 + +# XSize[ezwf]: 300 +# YSize[ezwf]: 300 + +## +## XZoom YZoom ------------------------------------------------- +## + +# If you want your graphs to have larger pixels, you can +# "Zoom" them. + +#XZoom[ezwf]: 2.0 +#YZoom[ezwf]: 2.0 + +## +## XScale YScale ------------------------------------------------- +## + +# If you want your graphs to be actually scaled use XScale +# and YScale. (Beware while this works, the results look ugly +# (to be frank) so if someone wants fix this: patches are +# welcome. + +# XScale[ezwf]: 1.5 +# YScale[ezwf]: 1.5 + + +## +## Step ----------------------------------------------------------- +## + +# Change the default step with from 5 * 60 seconds to +# something else I have not tested this well ... + +# Step[ezwf]: 60 + +## +## Options ------------------------------------------ +## + +# The "Options" Keyword allows you to set some boolean +# switches: +# +# growright - The graph grows to the left by default. +# +# bits - All the numbers printed are in bits instead +# of bytes ... looks much more impressive :-) +# +# noinfo - Supress the information about uptime and +# device name in the generated webpage. +# +# absolute - This is for data sources which reset their +# value when they are read. This means that +# rateup has not to build the difference between +# this and the last value read from the data +# source. Useful for external data gatherers. +# +# gauge - Treat the values gathered from target as absolute +# and not as counters. This would be useful to +# monitor things like diskspace, load and so +# on .... +# +# nopercent Don't print usage percentages +# +# integer Print only integers in the summary +# below the graph (No Kilo, Mega, Gigas) ... +# + +# Options[ezwf]: growright, bits + +## +## Colours ------------------------------------------ +## + +# The "Colours" tag allows you to override the default colour +# scheme. Note: All 4 of the required colours must be +# specified here The colour name ('Colourx' below) is the +# legend name displayed, while the RGB value is the real +# colour used for the display, both on the graph and n the +# html doc. + +# Format is: Colour1#RRGGBB,Colour2#RRGGBB,Colour3#RRGGBB,Colour4#RRGGBB +# where: Colour1 = Input on default graph +# Colour2 = Output on default graph +# Colour3 = Max input +# Colour4 = Max output +# RRGGBB = 2 digit hex values for Red, Green and Blue + +# Colours[ezwf]: GREEN#00eb0c,BLUE#1000ff,DARK GREEN#006600,VIOLET#ff00ff + +## +## Background ------------------------------------------ +## + +# With the "Background" tag you can configure the background +# colour of the generated HTML page + +# Background[ezwf]: #a0a0a0a + +## +## YLegend, ShortLegend, Legend[1234] ------------------ +## + +# The following keywords allow you to override the text +# displayed for the various legends of the graph and in the +# HTML document +# +# * YLegend : The Y-Axis of the graph +# * ShortLegend: The 'b/s' string used for Max, Average and Current +# * Legend[1234IO]: The strings for the colour legend +# +#YLegend[ezwf]: Bits per Second +#ShortLegend[ezwf]: b/s +#Legend1[ezwf]: Incoming Traffic in Bits per Second +#Legend2[ezwf]: Outgoing Traffic in Bits per Second +#Legend3[ezwf]: Maximal 5 Minute Incoming Traffic +#Legend4[ezwf]: Maximal 5 Minute Outgoing Traffic +#LegendI[ezwf]: In: +#LegendO[ezwf]: Out: +# Note, if LegendI or LegendO are set to an empty string with +# LegendO[ezwf]: +# The corresponding line below the graph will not be printed at all. + +# If you live in an international world, you might want to +# generate the graphs in different timezones. This is set in the +# TZ variable. Under certain operating systems like Solaris, +# this will provoke the localtime call to giv the time in +# the selected timezone ... + +# Timezone[ezwf]: Japan + +# The Timezone is the standard Solaris timezone, ie Japan, Hongkong, +# GMT, GMT+1 etc etc. + +# By default, mrtg (actually rateup) uses the strftime(3) '%W' option +# to format week numbers in the monthly graphs. The exact semantics +# of this format option vary between systems. If you find that the +# week numbers are wrong, and your system's strftime(3) routine +# supports it, you can try another format option. The POSIX '%V' +# option seems to correspond to a widely used week numbering +# convention. The week format character should be specified as a +# single letter; either W, V, or U. + +# Weekformat[ezwf]: V + +# ############################# +# Two very special Target names +# ############################# + +# To save yourself some typing you can define a target +# called '^'. The text of every Keyword you define for this +# target will be PREPENDED to the corresponding Keyword of +# all the targets defined below this line. The same goes for +# a Target called '$' but its options will be APPENDED. +# +# The example will make mrtg use a common header and a +# common contact person in all the pages generated from +# targets defined later in this file. +# +#PageTop[^]: <H1>NoWhere Unis Traffic Stats</H1><HR> +#PageTop[$]: Contact Peter Norton if you have any questions<HR> + + +################################################################## +################################################################## +################################################################## +# +# Now some example mrtg.cfg files +# +################################################################## +################################################################## +################################################################## + +# Minimal mrtg.cfg +#-------------------- + +#WorkDir: /usr/tardis/pub/www/stats/mrtg +#Target[r1]: 2:public@myrouter.somplace.edu +#MaxBytes[r1]: 64000 +#Title[r1]: Traffic Analysis ISDN +#PageTop[r1]: <H1>Stats for our ISDN Line</H1> + + +# Minimal Cfg for several Routers. +#--------------------------------- +#WorkDir: /usr/tardis/pub/www/stats/mrtg +# +#Title[^]: Traffic Analysis for +#PageTop[^]: <H1>Stats for our +#PageTop[$]: Contact The Chief if you notice anybody<HR> +# +#Title[isdn]: our ISDN Line +#PageTop[isdn]: our ISDN Line </H1> +#Target[isdn]: 2:public@router.somplace.edu +#MaxBytes[isdn]: 64000 +# +#Title[backb]: our Campus Backbone +#PageTop[backb]: our Campus Backbone </H1> +#Target[backb]: 1:public@router.somplace.edu +#MaxBytes[backb]: 1250000 + +# the following line removes the default prepend value +# defined above +#Title[^]: +#Title[isdn2]: Traffic for the Backup ISDN Line +#PageTop[isdn2]: our ISDN Line </H1> +#Target[isdn2]: 3:public@router.somplace.edu +#MaxBytes[isdn2]: 64000 diff --git a/contrib/mrtgmk/cfg/page1.cfg b/contrib/mrtgmk/cfg/page1.cfg new file mode 100644 index 0000000..6deda91 --- /dev/null +++ b/contrib/mrtgmk/cfg/page1.cfg @@ -0,0 +1,5 @@ +0 HTMLFILE cfg/page1.html +1 HTMLCODE <H1>PC from local network - links</H1> +1 DATA pc1 PC1 Trafic analyses +1 DATA pc2 PC2 Trafic analyses +1 DATA pc3 PC3 Trafic analyses diff --git a/contrib/mrtgmk/cfg/page1.html b/contrib/mrtgmk/cfg/page1.html new file mode 100644 index 0000000..053a835 --- /dev/null +++ b/contrib/mrtgmk/cfg/page1.html @@ -0,0 +1,14 @@ +<HTML> +<HEADER> +<TITLE> +Traffic analyses</TITLE> +</HEADER> +<BODY> +<UL TYPE="disc"> + <LI><H1>PC from local network - links</H1></LI> + <LI><A HREF="http://traffic.isp.ro/192.168.10.1.1.html">PC1 Trafic analyses</A></LI> + <LI><A HREF="http://traffic.isp.ro/192.168.10.1.3.html">PC2 Trafic analyses</A></LI> + <LI><A HREF="http://traffic.isp.ro/192.168.10.1.4.html">PC3 Trafic analyses</A></LI> +</UL> +</BODY> +</HTML> diff --git a/contrib/mrtgmk/cfg/page2.cfg b/contrib/mrtgmk/cfg/page2.cfg new file mode 100644 index 0000000..e8fb36f --- /dev/null +++ b/contrib/mrtgmk/cfg/page2.cfg @@ -0,0 +1,11 @@ +0 HTMLFILE cfg/page2.html +0 HTMLCODE <H1>PC from local network - overview</H1> +0 HTMLCODE PC1 Trafic analyses<BR> +0 GIFD # pc1 +0 HTMLCODE <BR><HR> +0 HTMLCODE PC2 Trafic analyses<BR> +0 GIFD # pc2 +0 HTMLCODE <BR><HR> +0 HTMLCODE PC3 Trafic analyses<BR> +0 GIFD # pc3 +0 HTMLCODE <BR><HR> diff --git a/contrib/mrtgmk/cfg/page2.html b/contrib/mrtgmk/cfg/page2.html new file mode 100644 index 0000000..ef75845 --- /dev/null +++ b/contrib/mrtgmk/cfg/page2.html @@ -0,0 +1,18 @@ +<HTML> +<HEADER> +<TITLE> +Traffic analyses</TITLE> +</HEADER> +<BODY> +<H1>PC from local network - overview</H1> +PC1 Trafic analyses<BR> +<A HREF="http://traffic.isp.ro/192.168.10.1.1.html"><IMG SRC="http://traffic.isp.ro/192.168.10.1.1-day.gif"></IMG></A> +<BR><HR> +PC2 Trafic analyses<BR> +<A HREF="http://traffic.isp.ro/192.168.10.1.3.html"><IMG SRC="http://traffic.isp.ro/192.168.10.1.3-day.gif"></IMG></A> +<BR><HR> +PC3 Trafic analyses<BR> +<A HREF="http://traffic.isp.ro/192.168.10.1.4.html"><IMG SRC="http://traffic.isp.ro/192.168.10.1.4-day.gif"></IMG></A> +<BR><HR> +</BODY> +</HTML> diff --git a/contrib/mrtgmk/cfg/today.html b/contrib/mrtgmk/cfg/today.html new file mode 100644 index 0000000..7d8af11 --- /dev/null +++ b/contrib/mrtgmk/cfg/today.html @@ -0,0 +1,15 @@ +<HTML> +<HEADER> +<TITLE> +Traffic analyses - day</TITLE> +</HEADER> +<BODY> +<H1>day .gifs for hosts in the .cfg file 192.168.10.1.cfg</H1><P> +<HR><BR><H1>Traffic analysis for pc1</H1><BR> +<A HREF="http://traffic.isp.ro/192.168.10.1.1.html"><IMG SRC="http://traffic.isp.ro/192.168.10.1.1-day.gif"></IMG></A><BR> +<HR><BR><H1>Traffic analysis for pc2</H1><BR> +<A HREF="http://traffic.isp.ro/192.168.10.1.3.html"><IMG SRC="http://traffic.isp.ro/192.168.10.1.3-day.gif"></IMG></A><BR> +<HR><BR><H1>Traffic analysis for pc3</H1><BR> +<A HREF="http://traffic.isp.ro/192.168.10.1.4.html"><IMG SRC="http://traffic.isp.ro/192.168.10.1.4-day.gif"></IMG></A><BR> +</BODY> +</HTML> diff --git a/contrib/mrtgmk/doc/commands b/contrib/mrtgmk/doc/commands new file mode 100644 index 0000000..396d275 --- /dev/null +++ b/contrib/mrtgmk/doc/commands @@ -0,0 +1,56 @@ +0 COMMENT +0 ENDCOMMENT + +0 XDEBUG on|off + +0 INCLUDE cfgfile + +0 DEFHOST hostname fcfgname port + +0 MRTG.CFG cfgpathdst cfgpathsrc +0 HTMLFILE filepath + +0 HTMLCODE code inserted in html +0 HTMLLINK link text +0 LINK2DH host text +0 MRTGTEXT text inserted in mrtg.cfg + +0 CFGDIR cfg_path + +0 TITLE txt + +0 BODY body arguments +0 NOBODY + +0 BASE url +0 NOBASE + +0 EXEC cmd + +link = # or RealLink +0 GIFD link host +0 GIFW link host +0 GIFM link host +0 GIFY link host + +0 ALIAS alias_name alias_body +0 DELALIAS alias_name +0 CHECK4ALIAS yes|no + +0 MSG msg + +0 MKLINK dir host path + +0 MKD fcfg htmlfilename +0 MKW fcfg htmlfilename +0 MKM fcfg htmlfilename +0 MKY fcfg htmlfilename + +0 CHNGTRGNAME yes|no +0 CONVIP2NAME mrtg_out_path +0 CONVNAME2IP mrtg_out_path + +n HTMLCODE html code +n HTMLLINK link text +n LINK2DH host text +n DATA host text diff --git a/contrib/mrtgmk/doc/readme.1st b/contrib/mrtgmk/doc/readme.1st new file mode 100644 index 0000000..19c6390 --- /dev/null +++ b/contrib/mrtgmk/doc/readme.1st @@ -0,0 +1,138 @@ +"mrtgmk" by Iulian Radu (iulian_r@starnets.ro) [v2.0] + +"mrtgmk" is giftware. It is my contribution to mrtg package. + +"mrtgmk" is a program that scan a .cfg file and generate a mrtg.cfg +style file + a .html file with links to the .html files generated +by mrtg. + +You can use the sources for your inspiration, can change them, BUT +you are not allowed to sell them. + +Cfg file structure: +------------------- +The .cfg file can contain any of the next row types. n meens any +integer positive (>0): + +0 COMMENT - mark a block of rows as a comment, /**/ c like :) +0 ENDCOMMENT + +0 XDEBUG on|off - print/don't print the line readed and executed from + cfgfile + +0 INCLUDE cfgfile - execute de commands from the cfgfile + +0 DEFHOST hostname fcfgname port - define a name 'hostname' for the pair + 'fcfgname port'. 'fcfgname' is the name of a file + precedently generated by cfgmaker. The resolved + name for a defined host can be get from HOST_hostname + alias when CHECK4ALIAS is on. + +0 MRTG.CFG cfgpathdst cfgpathsrc - define the name of a generated mrtg.cfg + (cfgpathdst) and the name of a source mrtg.cfg. If + the two names are the same, then all the new entries + in 'cfgpathdst' will be appended, else will be created + a new mrtg.cfg file with the initial contains took + from 'cfgpathsrc' +0 HTMLFILE filepath - where will be write the html code + +0 HTMLCODE code inserted in html - insert code in the generated html file; + not <BR> nor <P> added +0 HTMLLINK link text - insert a link in the html page, making no identation; + not <BR> nor <P> added +0 LINK2DH host text - insert a link in the html page, making no identation; + not <BR> nor <P> added + +0 MRTGTEXT text inserted in mrtg.cfg - insert text in the generated mrtg.cfg + +0 CFGDIR cfg_path - append cfg_path in the front of .cfg files generated + by cfgmaker +0 NOCFGDIR - not any more cfg_path used + +0 TITLE txt - text used between TITLE tags + +0 BODY body arguments - define the arguments inserted with BODY tag in the + html code +0 NOBODY - erase all arguments for BODY tag + +0 BASE url - append this url in front of all references at html + pages and gifs +0 NOBASE - use what the user has been wrote in .cfg file + +0 EXEC cmd - exec a command in shell + +0 GIFD link host - day gif +0 GIFW link host - week gif +0 GIFM link host - month gif +0 GIFY link host - year gif + - 0 GIFx link host -> <A HREF=link><IMG SRC=base/host-x.gif></IMG></A> + - 0 GIFx # host -> <A HREF=base/host.html><IMG SRC=base/host-x.gif></IMG></A> + - 0 GIFx link # -> <A HREF=base/link.html><IMG SRC=base/link-x.gif></IMG></A> + - 0 GIFx # # -> illegal + - host-x.gif means that it is searched in defined + hosts list for the name cfgmaker assign to that host + and append the right extension (e.g. -day.gif) to it + +0 ALIAS alias_name alias_body - define an alias named alias_name and + that will be used as %alias_name% and + CHECK4ALIAS yes +0 DELALIAS alias_name - erase the alias :] +0 CHECK4ALIAS yes|no - if yes, then all input string will be checked for + aliases. An alias is a name between %s (%alias_name% :) + +0 MSG msg - display the message msg on screen + +0 MKLINK dir host path - create a directory 'dir' that contain links through + a host page, located in path. If exist old links, + theses will be erased + + - create a htmlfile with day, week, month or year + gifs and links through appropiate html file. + Theses commandes MUST be done before any 0 DEFHOST + commands relative to host from fcfg. +0 MKD fcfg htmlfilename +0 MKW fcfg htmlfilename +0 MKM fcfg htmlfilename +0 MKY fcfg htmlfilename + +0 CHNGTRGNAME yes|no - change (or not) the name of the target html files + if change, then the name will be the defhost declared + name, otherwise will be the name declared in .cfg file + by cfgmaker + +0 CONVIP2NAME mrtg_out_path/ - change the name of the already existent files + from an ip style (somename.x where x is the snmp index) + into a defhost style + - 0 CHNGTRGNAME yes is required + +0 CONVNAME2IP mrtg_out_path/ - change the name of the already existent files + from a defhost style into ip style (somename.x where x + is the snmp index) + - 0 CHNGTRGNAME no is required + + - mrtg_out_path must be the path where mrtg create + the htmls, gifs and logs files and must end with a + slash ('/') + - must to be present before the definitions of the + hosts for with I intend to change the file name; + once switched to this action, exist not any way + to fall back + +n HTMLCODE html code - insert code in the html page, making identation; + not <BR> nor <P> added but surrounded by <LI></LI> +n HTMLLINK link text - insert a link in the html page, making identation; + not <BR> nor <P> added but surrounded by <LI></LI> +n LINK2DH host text - insert a link in the html page, making identation; + not <BR> nor <P> added but surrounded by <LI></LI> +n DATA host text - insert a link through a page genetrated by mrtg, + making identation; surrounded by <LI></LI> + +# or \n - treated as a comment + +If you expand the code, please notify me. + +"mkm" call the gcc to produce the exec "mrtgmk" from mrtgmk.c . +"smrtgmk" is an example of calling "mrtgmk". + +Iulian Radu (iulian_r@starnets.ro). +28th September 1999 12:00pm Romanian time diff --git a/contrib/mrtgmk/readme.1st b/contrib/mrtgmk/readme.1st new file mode 100644 index 0000000..49dc699 --- /dev/null +++ b/contrib/mrtgmk/readme.1st @@ -0,0 +1,26 @@ +"mrtgmk" by Iulian Radu (iulian_r@starnets.ro) [v2.2] + +"mrtgmk" is giftware. It is my contribution to mrtg package. + +"mrtgmk" is a program that scan a .cfg file and generate a mrtg.cfg +style file + a .html file with links to the .html files generated +by mrtg. + +Version 2.2 bring you a strong facility: you can rename the target +defined inside of genereated mrtg.cfg file. Using this new facility, +you will no longer depends on snmp index value. So, if the index of +a port is changed on a router, your graphics will still reprezent +corect the history of a host. + +If you need to migrate from v1.x to v2.x read the readme.1st and use +the program from v1_to_v2 directory. + +To learn to use mrtgmk v2.x read the docs from doc directory. + +In cfg directory you will find an example of a cfg file for mrtgmk v2.x. + +Because I dont make all the times checkes for receiving of correct arguments, +a core dump is posible :( , everything depends on you. + +Iulian Radu (iulian_r@starnets.ro). +13th July 1999 12:00am Romanian time diff --git a/contrib/mrtgmk/smrtgmk b/contrib/mrtgmk/smrtgmk new file mode 100755 index 0000000..da927e9 --- /dev/null +++ b/contrib/mrtgmk/smrtgmk @@ -0,0 +1,6 @@ +#!/bin/sh + +#this is an example of using mrtgmk + +clear +./mrtgmk cfg/a.cfg diff --git a/contrib/mrtgmk/src/alias.c b/contrib/mrtgmk/src/alias.c new file mode 100644 index 0000000..e10d796 --- /dev/null +++ b/contrib/mrtgmk/src/alias.c @@ -0,0 +1,71 @@ +/* +Iulian Radu [v2.0@07.1999] +*/ + +int apos=-1; //memorize position of a free cell + +char* findalias(char* buf){ +int i; +apos=-1; +for(i=0;i<nalias;i++){ + if(!strcmp(aliasn[i],buf)) + return aliasi[i]; + if(!aliasn[i][0]) apos=i; //no need to scan all defined aliases + } +if(strncmp(buf,"HOST_",5)) return NULL; +return findhost(buf+5); +} + +void falias(char* buf){ +char alias[129],*replace; +sscanf(buf,"%s",alias); +replace=findnsp(buf,1); +if(findalias(alias)) + fprintf(stderr,err[7],alias); +else + if(apos<0){ + strcpy(aliasn[nalias],alias); + strcpy(aliasi[nalias],replace); + nalias++;} + else{ + strcpy(aliasn[apos],alias); + strcpy(aliasi[apos],replace);} +} + +void fcheck4alias(char* buf){ +if(!strcasecmp(buf,"yes")){ + usealias=1; + return;} +if(!strcasecmp(buf,"no")){ + usealias=0; + return;} +fprintf(stderr,err[11],buf); +} + +char* expand(char* str){ +char buf[257],al[129]; +int i,j,k; +char* alias; +for(i=j=0;str[i];i++,j++) + if(str[i]!='%') buf[j]=str[i]; + else{ + for(i++,k=0;(str[i]) && (str[i]!='%');i++,k++) + al[k]=str[i]; + al[k]=0; + alias=findalias(al); + if(!alias){ + fprintf(stderr,err[8],al); + return str;} + strcpy(buf+j,alias); + j+=strlen(alias)-1;} +buf[j]=0; +strcpy(str,buf); +return str; +} + +void fdelalias(char* buf){ +int i; +for(i=0;i<nalias;i++) + if(!strcmp(aliasn[i],buf)) + aliasn[i][0]=0; +} diff --git a/contrib/mrtgmk/src/defhost.c b/contrib/mrtgmk/src/defhost.c new file mode 100644 index 0000000..5bcf918 --- /dev/null +++ b/contrib/mrtgmk/src/defhost.c @@ -0,0 +1,186 @@ +/* +Iulian Radu [v2.0@07.1999] +*/ + +int mkndx(char* file){ +char tmp[257],xtmp[257],*ptmp; +FILE *fcfg,*fndx; +unsigned long ofs,xofs; +/* open .cfg file */ +if(cfgdir[0]) sprintf(tmp,"%s/%s",cfgdir,file); +else strcpy(tmp,file); +fcfg=fopen(tmp,"rt"); +if(!fcfg){ + fprintf(stderr,err[0],tmp); + return 1;} +/* check if file .cfg has length 0 */ +if(fseek(fcfg,0,SEEK_END)){ + fclose(fcfg); + return 1;} +if(!ftell(fcfg)){ + fprintf(stderr,err[1],tmp); + sprintf(xtmp,"rm -f %s",tmp); + system(xtmp); + return 1;} +if(fseek(fcfg,0,SEEK_SET)) return 1; +/* create de index file */ +sprintf(tmp,"%s.ndx",extractfname(file)); +fndx=fopen(tmp,"wb"); +if(!fndx){ + fclose(fcfg); + return 1;} +while(!feof(fcfg)){ + xofs=ftell(fcfg); + tmp[0]=0; + fgets(tmp,256,fcfg); + if((tmp[0]=='#') || (tmp[0]==0) || (tmp[0]=='\n')) continue; + if(!strncmp(tmp,"Target[",7)) ofs=xofs; + if(!strncmp(tmp,"Title[",6)){ + ptmp=findnc(tmp,2,':'); + trim(ptmp); + fprintf(fndx,"%08ld %s\n",ofs,ptmp);} + } +fclose(fndx); +fclose(fcfg); +return 0; +} + +void setPI(char* buf,unsigned long* pos,char** ifa){ +sscanf(buf,"%08ld",pos); +*ifa=buf+9; +killnl(buf+9); +} + +void gettarget(char* buf,char* target){ //word between [] +int i; +for(;buf[0]!='[';buf++); +buf++; +for(i=0;buf[0]!=']';buf++,i++) target[i]=buf[0]; +target[i]=0; +} + +char* findhost(char* buf){ +int i; +for(i=0;i<nhosts;i++) + if(!strcmp(hostsn[i],buf)) + return hostsi[i]; +return NULL; +} + +void convertname(char* tmp){ +for(;tmp[0];tmp++){ + if(!isalnum(tmp[0])) tmp[0]='_'; + else tmp[0]=tolower(tmp[0]); + } +} + +void fdefhost(char* buf){ +char host[129],fcfg[257],tmp[257],target[129],xtarget[129],*port; +FILE *fi; +unsigned long pos; +char *ifa=NULL, + *txt[]={"day","week","month","year"}, + *xtxt[]={"-day.gif","-week.gif","-month.gif","-year.gif",".html",".log",".old"}; +int i,j; +if(!fm){ + fprintf(stderr,err[2]); + return;} +sscanf(buf,"%s %s",host,fcfg); +if(findhost(host)) + fprintf(stderr,err[6],host); +/* read index file */ +sprintf(tmp,"%s.ndx",extractfname(fcfg)); +fi=fopen(tmp,"rt"); +if(!fi){ + if(mkndx(fcfg)) return; //create the index file + fi=fopen(tmp,"rt"); + if(!fi) return; + } +port=findnsp(buf,2); +while(!feof(fi)){ + fgets(tmp,256,fi); + setPI(tmp,&pos,&ifa); //read pos and interface + if(!strcasecmp(port,ifa)){ + break;} + } +if(feof(fi)){ + if(cfgdir[0]) fprintf(stderr,err[3],port,cfgdir,fcfg); + else fprintf(stderr,err[4],port,fcfg); + fclose(fi); + return;} +fclose(fi); +/* comment in mrtg.cfg file */ +if(cfgdir[0]){ + fprintf(fm,"\n#host %s, cfgfile %s/%s, port %s\n\n",host,cfgdir,fcfg,port); + sprintf(tmp,"%s/%s",cfgdir,fcfg);} +else{ + fprintf(fm,"\n#host %s, cfgfile %s, port %s\n\n",host,fcfg,port); + strcpy(tmp,fcfg);} +/* read config file to extract section */ +fi=fopen(tmp,"rt"); +if(!fi){ + fprintf(stderr,err[5],tmp); + return;} +fseek(fi,pos,SEEK_SET); +fgets(buf,256,fi); /*Target[...*/ +gettarget(buf,xtarget); +if(chngname){ + strcpy(target,host); + convertname(target); /* switch to lowercase */ + j=strlen(buf); + for(i=0;i<j;i++){ /* write the line Target[... */ + fprintf(fm,"%c",buf[i]); + if(buf[i]=='['){ + for(;i<j;i++) if(buf[i]==']') break; + fprintf(fm,"%s]",target);} + } + while(!feof(fi)){ /* write rest of the lines */ + fgets(buf,256,fi); + j=strlen(buf); + for(i=0;i<j;i++){ + fprintf(fm,"%c",buf[i]); + if(buf[i]=='['){ + for(;i<j;i++) if(buf[i]==']') break; + fprintf(fm,"%s]",target);} + } + if(!strncmp(buf,"#-",2)) break; + } + } +else{ + strcpy(target,xtarget); + fprintf(fm,"%s",buf); + while(!feof(fi)){ + fgets(buf,256,fi); + fprintf(fm,"%s",buf); + if(!strncmp(buf,"#-",2)) break; + } + } +fclose(fi); +strcpy(hostsn[nhosts],host); +strcpy(hostsi[nhosts],target); +nhosts++; +/* mk?,? */ +for(i=0;i<4;i++){ + for(j=0;j<nmkr[i];j++){ + if(!strcmp(mkrn[j][i],fcfg)){ + fprintf(mkri[j][i],"<HR><BR><H1>%s %s</H1><BR>\n",btxt[1],host); + if(base[0]) fprintf(mkri[j][i],"<A HREF=\"http://%s/%s.html\"><IMG SRC=\"http://%s/%s-%s.gif\"></IMG></A><BR>\n",base,target,base,target,txt[i]); + else fprintf(mkri[j][i],"<A HREF=\"%s.html\"><IMG SRC=\"%s-%s.gif\"></IMG></A><BR>\n",target,target,txt[i]); + break;} + } + } +convertname(host); /* change again the name, this time host var */ +switch(conv){ + case 1: //convip2name + for(i=0;i<7;i++){ + sprintf(tmp,"mv %s%s%s %s%s%s",mrtgoutpath,xtarget,xtxt[i],mrtgoutpath,host,xtxt[i]); + system(tmp);} + break; + case 2: //convname2ip + for(i=0;i<7;i++){ + sprintf(tmp,"mv %s%s%s %s%s%s",mrtgoutpath,host,xtxt[i],mrtgoutpath,xtarget,xtxt[i]); + system(tmp);} + break; + } +} + diff --git a/contrib/mrtgmk/src/fnct0.c b/contrib/mrtgmk/src/fnct0.c new file mode 100644 index 0000000..212e4a4 --- /dev/null +++ b/contrib/mrtgmk/src/fnct0.c @@ -0,0 +1,280 @@ +/* +Iulian Radu [v2.0@07.1999] +*/ + +void fcomment(char* buf){ +comment=1; +} + +void finclude(char* buf){ +parsex(buf); +} + +void fmrtgcfg(char* buf){ +char dst[257],src[257],tmp[257]; +if(fm) fclose(fm); +sscanf(buf,"%s %s",dst,src); +if(strcmp(dst,src)){ + sprintf(tmp,"cp %s %s",src,dst); + system(tmp);} +fm=fopen(dst,"a+t"); +if(!fm) return; +fprintf(fm,"#----------------------------------------------------------------------\n"); +} + +void fhtmlfile(char* buf){ +closehtml(); +fh=fopen(buf,"wt"); +mkhtmlh(); +} + +void fxdebug(char* buf){ +if(!strcasecmp(buf,"on")) xdebug=1; +if(!strcasecmp(buf,"off")) xdebug=0; +} + +void fcfgdir(char* buf){ +strcpy(cfgdir,buf); +} + +void fnocfgdir(char* buf){ +cfgdir[0]=0; +} + +void fhtmlcode0(char* buf){ +int i; +if(!fh) return; +for(;identl;identl--){ + for(i=1;i<identl;i++) fprintf(fh,"\t"); + fprintf(fh,"</UL>\n");} +fprintf(fh,"%s\n",buf); +} + +void fmrtgtext(char* buf){ +if(!fm) return; +fprintf(fm,"#%s\n",buf); +} + +void fbody(char* buf){ +strcpy(body,buf); +} + +void fnobody(char* buf){ +body[0]=0; +} + +void fbase(char* buf){ +strcpy(base,buf); +} + +void fnobase(char* buf){ +base[0]=0; +} + +void fexec(char* buf){ +system(buf); +} + +void fmsg(char* buf){ +printf("%s\n",buf); +} + +void ftitle(char* buf){ +strcpy(title,buf); +} + +void fmklink(char* buf){ +char dir[257],host[65],path[257],*hosti,tmp1[257],tmp2[257],crtdir[257]; +sscanf(buf,"%s %s %s",dir,host,path); +hosti=findhost(host); +if(!hosti){ + fprintf(stderr,err[9],host); + return;} +mkdir(dir,S_IREAD | S_IWRITE | S_IEXEC); +getcwd(crtdir,256); +if(chdir(dir)){ + fprintf(stderr,err[10],dir); + return;} +/* index.html */ +sprintf(tmp1,"%s/%s.html",path,hosti); +unlink("index.html"); +symlink(tmp1,"index.html"); +/* gifs */ +sprintf(tmp1,"%s/%s-day.gif",path,hosti); +sprintf(tmp2,"%s-day.gif",hosti); +unlink(tmp2); +symlink(tmp1,tmp2); +sprintf(tmp1,"%s/%s-week.gif",path,hosti); +sprintf(tmp2,"%s-week.gif",hosti); +unlink(tmp2); +symlink(tmp1,tmp2); +sprintf(tmp1,"%s/%s-month.gif",path,hosti); +sprintf(tmp2,"%s-month.gif",hosti); +unlink(tmp2); +symlink(tmp1,tmp2); +sprintf(tmp1,"%s/%s-year.gif",path,hosti); +sprintf(tmp2,"%s-year.gif",hosti); +unlink(tmp2); +symlink(tmp1,tmp2); +/* mrtg imgs */ +sprintf(tmp1,"%s/mrtg-l.gif",path); +unlink("mrtg-l.gif"); +symlink(tmp1,"mrtg-l.gif"); +sprintf(tmp1,"%s/mrtg-m.gif",path); +unlink("mrtg-m.gif"); +symlink(tmp1,"mrtg-m.gif"); +sprintf(tmp1,"%s/mrtg-r.gif",path); +unlink("mrtg-r.gif"); +symlink(tmp1,"mrtg-r.gif"); +sprintf(tmp1,"%s/mrtg-tl.gif",path); +unlink("mrtg-tl.gif"); +symlink(tmp1,"mrtg-tl.gif"); +chdir(crtdir); +} + +void wrohtml(FILE* f,char* str,char* fcfg){ +fprintf(f,"<HTML>\n"); +fprintf(f,"<HEADER>\n"); +fprintf(f,"<TITLE>\n"); +if(title[0]) fprintf(f,"%s - %s",title,str); +else fprintf(f,"%s - %s",btxt[0],str); +fprintf(f,"</TITLE>\n"); +fprintf(f,"</HEADER>\n"); +if(body[0]) fprintf(f,"<BODY %s>\n",body); +else fprintf(f,"<BODY>\n"); +fprintf(f,"<H1>%s %s %s</H1><P>\n",str,btxt[2],fcfg); +} + +void wrchtml(FILE* f){ +fprintf(f,"</BODY>\n"); +fprintf(f,"</HTML>\n"); +} + +void fmkd(char* buf){ +char fcfg[257],fhtml[257]; +FILE* f; +int i; +sscanf(buf,"%s %s",fcfg,fhtml); +for(i=0;i<nmkr[0];i++) + if(!strcmp(mkrn[i][4],fhtml)){ + f=mkri[i][0]; + break;} +if(i==nmkr[0]){ + f=fopen(fhtml,"wt"); + if(!f) return; + wrohtml(f,"day",fcfg);} +i=nmkr[0]++; +mkri[i][0]=f; +strcpy(mkrn[i][0],fcfg); +strcpy(mkrn[i][4],fhtml); +} + +void fmkw(char* buf){ +char fcfg[257],fhtml[257]; +FILE* f; +int i; +sscanf(buf,"%s %s",fcfg,fhtml); +for(i=0;i<nmkr[1];i++) + if(!strcmp(mkrn[i][5],fhtml)){ + f=mkri[i][1]; + break;} +if(i==nmkr[0]){ + f=fopen(fhtml,"wt"); + if(!f) return; + wrohtml(f,"week",fcfg);} +i=nmkr[1]++; +mkri[i][1]=f; +strcpy(mkrn[i][1],fcfg); +strcpy(mkrn[i][5],fhtml); +} + +void fmkm(char* buf){ +char fcfg[257],fhtml[257]; +FILE* f; +int i; +sscanf(buf,"%s %s",fcfg,fhtml); +for(i=0;i<nmkr[2];i++) + if(!strcmp(mkrn[i][6],fhtml)){ + f=mkri[i][2]; + break;} +if(i==nmkr[2]){ + f=fopen(fhtml,"wt"); + if(!f) return; + wrohtml(f,"month",fcfg);} +strcpy(mkrn[nmkr[2]++][2],fcfg); +i=nmkr[2]++; +mkri[i][2]=f; +strcpy(mkrn[i][2],fcfg); +strcpy(mkrn[i][6],fhtml); +} + +void fmky(char* buf){ +char fcfg[257],fhtml[257]; +FILE* f; +int i; +sscanf(buf,"%s %s",fcfg,fhtml); +for(i=0;i<nmkr[3];i++) + if(!strcmp(mkrn[i][7],fhtml)){ + f=mkri[i][3]; + break;} +if(i==nmkr[3]){ + f=fopen(fhtml,"wt"); + if(!f) return; + wrohtml(f,"year",fcfg);} +i=nmkr[3]++; +mkri[i][3]=f; +strcpy(mkrn[i][3],fcfg); +strcpy(mkrn[i][7],fhtml); +} + +void fhtmllink0(char* buf){ +char link[129]; +int i; +if(!fh) return; +for(;identl;identl--){ + for(i=1;i<identl;i++) fprintf(fh,"\t"); + fprintf(fh,"</UL>\n");} +sscanf(buf,"%s",link); +if(base[0]) fprintf(fh,"<A HREF=\"http://%s/%s\">",base,link); +else fprintf(fh,"<A HREF=\"%s\">",link); +fprintf(fh,"%s",findnsp(buf,1)); +fprintf(fh,"</A>\n"); +} + +void flink2dh0(char* buf){ +char host[129],*hosti; +int i; +if(!fh) return; +for(;identl;identl--){ + for(i=1;i<identl;i++) fprintf(fh,"\t"); + fprintf(fh,"</UL>\n");} +sscanf(buf,"%s",host); +hosti=findhost(host); +if(!hosti){ + fprintf(stderr,err[9],host); + return;} +if(base[0]) fprintf(fh,"<A HREF=\"http://%s/%s.html\">",base,hosti); +else fprintf(fh,"<A HREF=\"%s.html\">",hosti); +fprintf(fh,"%s",findnsp(buf,1)); +fprintf(fh,"</A>\n"); +} + +void fchngtrgname(char* buf){ +if(!strcasecmp(buf,"yes")){ + chngname=1; + return;} +if(!strcasecmp(buf,"no")){ + chngname=0; + return;} +fprintf(stderr,err[12],buf); +} + +void fconvip2name(char* buf){ +conv=1; +sscanf(buf,"%s",mrtgoutpath); +} + +void fconvname2ip(char* buf){ +conv=2; +sscanf(buf,"%s",mrtgoutpath); +} diff --git a/contrib/mrtgmk/src/fnctn.c b/contrib/mrtgmk/src/fnctn.c new file mode 100644 index 0000000..c47c89b --- /dev/null +++ b/contrib/mrtgmk/src/fnctn.c @@ -0,0 +1,52 @@ +/* +Iulian Radu [v2.0@07.1999] +*/ + +void fhtmlcoden(char* buf){ +int i; +for(i=1;i<identl;i++) + fprintf(fh,"\t"); +fprintf(fh,"<LI>%s</LI>\n",buf); +} + +void fhtmllinkn(char* buf){ +char link[129]; +int i; +for(i=1;i<identl;i++) + fprintf(fh,"\t"); +sscanf(buf,"%s",link); +if(base[0]) fprintf(fh,"<LI><A HREF=\"http://%s/%s\">",base,link); +else fprintf(fh,"<LI><A HREF=\"%s\">",link); +fprintf(fh,"%s",findnsp(buf,1)); +fprintf(fh,"</A></LI>\n"); +} + +void fdata(char* buf){ +char host[129],*text,*hosti,url[257]; +sscanf(buf,"%s",host); +hosti=findhost(host); +if(!hosti) return; +text=findnsp(buf,1); +if(base[0]) sprintf(url,"http://%s/%s",base,hosti); +else strcpy(url,hosti); +fprintf(fh,"<LI><A HREF=\"%s.html\">",url); +fprintf(fh,"%s",text); +fprintf(fh,"</A></LI>\n"); +} + +void flink2dhn(char* buf){ +char host[129],*hosti; +int i; +for(i=1;i<identl;i++) + fprintf(fh,"\t"); +sscanf(buf,"%s",host); +hosti=findhost(host); +if(!hosti){ + fprintf(stderr,err[9],host); + return;} +if(base[0]) fprintf(fh,"<LI><A HREF=\"http://%s/%s.html\">",base,hosti); +else fprintf(fh,"<LI><A HREF=\"%s.html\">",hosti); +fprintf(fh,"%s",findnsp(buf,1)); +fprintf(fh,"</A></LI>\n"); +} + diff --git a/contrib/mrtgmk/src/gif.c b/contrib/mrtgmk/src/gif.c new file mode 100644 index 0000000..cea0519 --- /dev/null +++ b/contrib/mrtgmk/src/gif.c @@ -0,0 +1,51 @@ +/* +Iulian Radu [v2.0@07.1999] +*/ + +void fgif(char* buf,char* ext){ +char link[129],host[129],*hosti,url[257]; +if(!fh) return; +sscanf(buf,"%s %s",link,host); +if(strcmp(host,"#")){ //host!=# -> search for a host definition + hosti=findhost(host); + if(!hosti) return; + if(strcmp(link,"#")){ + if(base[0]) sprintf(url,"http://%s/%s",base,hosti); + else strcpy(url,hosti); + fprintf(fh,"<A HREF=\"%s\">",link); + fprintf(fh,"<IMG SRC=\"%s%s\">",url,ext);} + else{ + if(base[0]) sprintf(url,"http://%s/%s",base,hosti); + else strcpy(url,hosti); + fprintf(fh,"<A HREF=\"%s.html\">",url); + fprintf(fh,"<IMG SRC=\"%s%s\">",url,ext);} + } +else{ + if(strcmp(link,"#")){ + if(base[0]) sprintf(url,"http://%s/%s",base,link); + else strcpy(url,link); + fprintf(fh,"<A HREF=\"%s.html\">",url); + fprintf(fh,"<IMG SRC=\"%s%s\">",url,ext);} + else{ + fprintf(stderr,"\aERROR: 0 GIF%c # #\n",toupper(ext[1])); + return;} + } +fprintf(fh,"</IMG></A>\n"); +} + +void fgifd(char* buf){ +fgif(buf,"-day.gif"); +} + +void fgifw(char* buf){ +fgif(buf,"-week.gif"); +} + +void fgifm(char* buf){ +fgif(buf,"-month.gif"); +} + +void fgify(char* buf){ +fgif(buf,"-year.gif"); +} + diff --git a/contrib/mrtgmk/src/html.c b/contrib/mrtgmk/src/html.c new file mode 100644 index 0000000..125bd73 --- /dev/null +++ b/contrib/mrtgmk/src/html.c @@ -0,0 +1,29 @@ +/* +Iulian Radu [v2.0@07.1999] +*/ + +void mkhtmlh(){ /*use fh global*/ +if(!fh) return; +fprintf(fh,"<HTML>\n"); +fprintf(fh,"<HEADER>\n"); +fprintf(fh,"<TITLE>\n"); +if(title[0]) fprintf(fh,title); +else fprintf(fh,btxt[0]); +fprintf(fh,"</TITLE>\n"); +fprintf(fh,"</HEADER>\n"); +if(body[0]) fprintf(fh,"<BODY %s>\n",body); +else fprintf(fh,"<BODY>\n"); +} + +void closehtml(){ /*use fh global*/ +int i; +if(!fh) return; +for(;identl;identl--){ + for(i=1;i<identl;i++) fprintf(fh,"\t"); + fprintf(fh,"</UL>\n");} +fprintf(fh,"</BODY>\n"); +fprintf(fh,"</HTML>\n"); +fclose(fh); +fh=NULL; +} + diff --git a/contrib/mrtgmk/src/mkm b/contrib/mrtgmk/src/mkm new file mode 100755 index 0000000..82c6082 --- /dev/null +++ b/contrib/mrtgmk/src/mkm @@ -0,0 +1 @@ +gcc -o mrtgmk mrtgmk.c -Wall diff --git a/contrib/mrtgmk/src/mrtgmk.c b/contrib/mrtgmk/src/mrtgmk.c new file mode 100644 index 0000000..2b0602d --- /dev/null +++ b/contrib/mrtgmk/src/mrtgmk.c @@ -0,0 +1,35 @@ +/* +Iulian Radu [v2.0@07.1999] +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <sys/stat.h> +#include <unistd.h> + +#include "txte.h" //for english messages +//#include "txtro.h" //pentru mesaje in romaneste +#include "parse.c" + +void intro(char* aname){ +printf("\n%s (mrtgmk) %s Iulian Radu [v2.2@1.2000]\n\n",extractfname(aname),etxt[0]); +} + +void help(char* aname){ +printf("%s <cfg.fname>\n",aname); +printf(" <cfg.fname> = %s\n",etxt[3]); +printf(" <> = %s\n",etxt[1]); +printf(" [] = %s\n",etxt[2]); +printf("\n"); +exit(1); +} + +int main(int argc,char** argv){ +intro(argv[0]); +if(argc!=2) help(argv[0]); +parse(argv[1]); +return 0; +} + diff --git a/contrib/mrtgmk/src/parse.c b/contrib/mrtgmk/src/parse.c new file mode 100644 index 0000000..24357cc --- /dev/null +++ b/contrib/mrtgmk/src/parse.c @@ -0,0 +1,45 @@ +/* +Iulian Radu [v2.0@07.1999] +*/ + +#include "vars.h" + +void parsex(char* fcfg); +void parse(char* fcfg); + +#include "util.c" +#include "parse.ftbl" +#include "parse0.c" +#include "parsen.c" + +void parsex(char* fcfg){ +char buf[513]; +FILE* f; +f=fopen(fcfg,"rt"); +if(!f) return; +while(!feof(f)){ + buf[0]=0; //look stupid BUT it is not + fgets(buf,512,f); + if(xdebug) printf("EXTREM DEBUG: %s\n",buf); + trim(buf); + if(!buf[0] || (buf[0]=='#')) continue; + if(buf[0]=='0') parse0(buf+2); + else if(isdigit(buf[0])) + if(!comment) parsen(buf); + } +fclose(f); +} + +void parse(char* fcfg){ +int i,j; +parsex(fcfg); +closehtml(); +if(fm) fclose(fm); +/* close mk? */ +for(i=0;i<4;i++) + for(j=0;j<nmkr[i];j++){ + if(mkri[j][i]) wrchtml(mkri[j][i]); + mkri[j][i]=NULL;} +system("rm -f *.ndx"); +} + diff --git a/contrib/mrtgmk/src/parse.ftbl b/contrib/mrtgmk/src/parse.ftbl new file mode 100644 index 0000000..e14b123 --- /dev/null +++ b/contrib/mrtgmk/src/parse.ftbl @@ -0,0 +1,11 @@ +/* +Iulian Radu [v2.0@07.1999] +*/ + +typedef void (*fnct)(char* buf); + +struct fncttbl{ + char* cmd; + fnct func; + }; + diff --git a/contrib/mrtgmk/src/parse0.c b/contrib/mrtgmk/src/parse0.c new file mode 100644 index 0000000..b234bf0 --- /dev/null +++ b/contrib/mrtgmk/src/parse0.c @@ -0,0 +1,30 @@ +/* +Iulian Radu [v2.0@07.1999] +*/ + +#include "html.c" +#include "defhost.c" +#include "alias.c" +#include "gif.c" +#include "fnct0.c" +#include "parse0.ftbl" + +void parse0(char* buf){ +char cmd[129],*ebuf; +int i; +ltrim(buf); +sscanf(buf,"%s",cmd); +if(!strcmp(cmd,parse0_ftbl[0].cmd)){ + comment=0; + return;} +if(comment) return; +for(i=1;i<NEFTBL0;i++) + if(!strcmp(cmd,parse0_ftbl[i].cmd)){ + if(parse0_ftbl[i].func){ + ebuf=buf+strlen(parse0_ftbl[i].cmd)+1; + trim(ebuf); + if(usealias) expand(ebuf); + parse0_ftbl[i].func(ebuf);} + return;} +fprintf(stderr,"\aERROR: 0 %s\n",buf); +} diff --git a/contrib/mrtgmk/src/parse0.ftbl b/contrib/mrtgmk/src/parse0.ftbl new file mode 100644 index 0000000..a735fc0 --- /dev/null +++ b/contrib/mrtgmk/src/parse0.ftbl @@ -0,0 +1,44 @@ +/* +Iulian Radu [v2.0@07.1999] +*/ + +struct fncttbl parse0_ftbl[]={ + {"ENDCOMMENT",NULL}, //end of comment block - need to be be 1st + {"COMMENT",fcomment}, //1 + {"XDEBUG",fxdebug}, + {"INCLUDE",finclude}, + {"DEFHOST",fdefhost}, + {"MRTG.CFG",fmrtgcfg}, + {"HTMLFILE",fhtmlfile}, + {"CFGDIR",fcfgdir}, + {"NOCFGDIR",fnocfgdir}, + {"HTMLCODE",fhtmlcode0}, + {"MRTGTEXT",fmrtgtext}, //10 + {"TITLE",ftitle}, + {"BODY",fbody}, + {"NOBODY",fnobody}, + {"BASE",fbase}, + {"NOBASE",fnobase}, + {"EXEC",fexec}, + {"GIFD",fgifd}, + {"GIFW",fgifw}, + {"GIFM",fgifm}, + {"GIFY",fgify}, //20 + {"ALIAS",falias}, + {"DELALIAS",fdelalias}, + {"CHECK4ALIAS",fcheck4alias}, + {"MKLINK",fmklink}, + {"MKD",fmkd}, + {"MKW",fmkw}, + {"MKM",fmkm}, + {"MKY",fmky}, + {"MSG",fmsg}, + {"HTMLLINK",fhtmllink0}, //30 + {"LINK2DH",flink2dh0}, + {"CHNGTRGNAME",fchngtrgname}, + {"CONVIP2NAME",fconvip2name}, + {"CONVNAME2IP",fconvname2ip} + }; + +#define NEFTBL0 35 + diff --git a/contrib/mrtgmk/src/parsen.c b/contrib/mrtgmk/src/parsen.c new file mode 100644 index 0000000..889f2b0 --- /dev/null +++ b/contrib/mrtgmk/src/parsen.c @@ -0,0 +1,54 @@ +/* +Iulian Radu [v2.0@07.1999] +*/ + +int ident=0; + +#include "fnctn.c" +#include "parsen.ftbl" + +int formathtml(){ /* put UL or /UL */ +int i,j,k; +if(ident<1){ + return 1;} +if(!fh) return 1; +if(!identl){ + fprintf(fh,"<UL TYPE=\"disc\">\n"); + identl++;} +if(ident<identl){ + i=identl-ident; + k=identl-1; + for(;i;i--,k--){ + for(j=0;j<k;j++) fprintf(fh,"\t"); + fprintf(fh,"</UL>\n");} + } +if(ident>identl){ + i=ident-identl; + k=identl; + for(;i;i--,k++){ + for(j=0;j<k;j++) fprintf(fh,"\t"); + fprintf(fh,"<UL TYPE=\"disc\">\n");} + } +for(i=0;i<ident;i++) fprintf(fh,"\t"); +identl=ident; +return 0; +} + +void parsen(char* buf){ +char cmd[129],*ebuf; +int i; +ltrim(buf); +sscanf(buf,"%d %s",&ident,cmd); +for(i=0;i<NEFTBLn;i++) + if(!strcmp(cmd,parsen_ftbl[i].cmd)){ + if(parsen_ftbl[i].func){ + ebuf=findnsp(buf,2); + rtrim(ebuf); + if(usealias) expand(ebuf); + if(formathtml()){ + fprintf(stderr,"\aERROR: %s\n",ebuf); + return;} + parsen_ftbl[i].func(ebuf);} + return;} +fprintf(stderr,"\aERROR: %s\n",buf); +} diff --git a/contrib/mrtgmk/src/parsen.ftbl b/contrib/mrtgmk/src/parsen.ftbl new file mode 100644 index 0000000..1ffdd35 --- /dev/null +++ b/contrib/mrtgmk/src/parsen.ftbl @@ -0,0 +1,12 @@ +/* +Iulian Radu [v2.0@07.1999] +*/ + +struct fncttbl parsen_ftbl[]={ + {"HTMLCODE",fhtmlcoden}, + {"HTMLLINK",fhtmllinkn}, + {"LINK2DH",flink2dhn}, + {"DATA",fdata} + }; + +#define NEFTBLn 4 diff --git a/contrib/mrtgmk/src/txte.h b/contrib/mrtgmk/src/txte.h new file mode 100644 index 0000000..fb9731b --- /dev/null +++ b/contrib/mrtgmk/src/txte.h @@ -0,0 +1,34 @@ +#ifndef _TXT_H_ +#define _TXT_H_ + +char* etxt[]={ + "by", + "needed", + "optionally", + "configuration file" + }; + +char* btxt[]={ + "Traffic analyses", + "Traffic analysis for", + ".gifs for hosts in the .cfg file" + }; + +char* err[]={ + "\aERROR: openning file %s\n", + "\aERROR: index file %s has length 0 and I erase it\n", + "\aERROR: was not defined a mrtg.cfg file\n", + "\aERROR: port %s missing from %s/%s\n", + "\aERROR: port %s missing from %s\n", + "\aERROR: configuration file %s is missing\n", + "\aERROR: host %s redefined\n", + "\aERROR: alias %s redefined\n", + "\aERROR: alias %s not precedently defined\n", + "\aERROR: host %s not precedently defined\n", + "\aERROR: I can't switch in directory %s\n", //10 + "\aERROR: argument for CHECK4ALIAS was %s", + "\aERROR: argument for CHNGTRGNAME was %s" + }; + +#endif +
\ No newline at end of file diff --git a/contrib/mrtgmk/src/txtro.h b/contrib/mrtgmk/src/txtro.h new file mode 100644 index 0000000..27814af --- /dev/null +++ b/contrib/mrtgmk/src/txtro.h @@ -0,0 +1,34 @@ +#ifndef _TXT_H_ +#define _TXT_H_ + +char* etxt[]={ + "de", + "obligatoriu", + "optional", + "fisierul pt. configurare" + }; + +char* btxt[]={ + "Analiza trafic", + "Analiza traficului pentru", + ".gifs pentru hosturile definite in fisierul" + }; + +char* err[]={ + "\aERROR: deschidere fisier %s\n", + "\aERROR: fisierul index %s are lungime 0 si il sterg\n", + "\aERROR: nu a fost definit un fisier mrtg.cfg\n", + "\aERROR: portul %s lipseste din %s/%s\n", + "\aERROR: portul %s lipseste din %s\n", + "\aERROR: fisierul de configurare %s lipseste\n", + "\aERROR: hostul %s redefinit\n", + "\aERROR: alias %s redefinit\n", + "\aERROR: nu a fost definit nici un alias %s\n", + "\aERROR: nu a fost definit nici un host %s\n", + "\aERROR: nu ma pot muta in directorul %s\n", //10 + "\aERROR: argumentul pentru CHECK4ALIAS a fost %s", + "\aERROR: argumentul pentru CHNGTRGNAME a fost %s" + }; + +#endif +
\ No newline at end of file diff --git a/contrib/mrtgmk/src/util.c b/contrib/mrtgmk/src/util.c new file mode 100644 index 0000000..ec2de79 --- /dev/null +++ b/contrib/mrtgmk/src/util.c @@ -0,0 +1,55 @@ +/* +Iulian Radu [v2.0@07.1999] +*/ + +char* extractfname(char* fname){ +char* cptmp; +cptmp=fname+strlen(fname)-1; +while((cptmp>=fname) && (cptmp[0]!='/')) cptmp--; +return cptmp+1; +} + +void ltrim(char* buf){ +char* tmp; +for(tmp=buf;tmp[0] && isspace(tmp[0]);tmp++); +strcpy(buf,tmp); +} + +void rtrim(char* buf){ +char* tmp; +for(tmp=buf-1;buf[0];buf++) + if(!isspace(buf[0])) tmp=buf; +tmp[1]=0; +} + +void trim(char*buf){ +ltrim(buf); +rtrim(buf); +} + +char* findnsp(char* str,int n){ /*unde incepe cuvintul de dupa al n-lea spatiu*/ +while(str[0] && n) + if(isspace(str[0])){ + n--; + for(;str[0] && isspace(str[0]);str++); + } + else str++; +return str; +} + +char* findnc(char* str,int n,char ch){ /*gaseste al n-lea ch*/ +for(;str[0] && n;str++) + if(str[0]==ch) n--; +return str; +} + +void killnl(char* buf){ +for(;buf[0];buf++){ + if(buf[0]=='\n'){ + buf[0]=0; + return;} + if(buf[0]=='\r'){ + buf[0]=0; + return;} + } +} diff --git a/contrib/mrtgmk/src/vars.h b/contrib/mrtgmk/src/vars.h new file mode 100644 index 0000000..64c620b --- /dev/null +++ b/contrib/mrtgmk/src/vars.h @@ -0,0 +1,50 @@ +#ifndef _VARS_H_ +#define _VARS_H_ + +FILE *fh=NULL,*fm=NULL; //html and mrtg files +int xdebug=0; //say if produce extreme debug +int comment=0; //say if inside of a comment block +char cfgdir[257]=""; //path of the cfg file + +#define N_HOSTS 4096 +int nhosts=0; //# of defined states +char hostsn[N_HOSTS][65]; //host name +char hostsi[N_HOSTS][33]; //host definition as interface + +int identl=0; +char body[257]=""; //code appended to body tag +char base[257]=""; //base for html files + +#define N_ALIAS 128 +int nalias=0; //# of defined aliases +char aliasn[N_ALIAS][33]; //name of the aliases and their contents +char aliasi[N_ALIAS][129]; //name of the interfaces and their resolv + +int usealias=0; //say if is allowed to use aliases +int chngname=0; //say if change the name of the output files +int conv=0; //say if change or not the name of the files + +char title[65]; //title of the html page + +#define N_MK 128 +int nmkr[4]={ 0, //# of files procesed for mkd + 0, //# of files procesed for mkw + 0, //# of files procesed for mkm + 0}; //# of files procesed for mky +char mkrn[N_MK][8][257]; //0=name of the cfg procesed for mkd + //1=name of the cfg procesed for mkw + //2=name of the cfg procesed for mkm + //3=name of the cfg procesed for mky + //4=name of the router procesed for mkd + //5=name of the router procesed for mkw + //6=name of the router procesed for mkm + //7=name of the router procesed for mky + +FILE* mkri[N_MK][4]; //0=FILE* for mkd + //1=FILE* for mkw + //2=FILE* for mkm + //3=FILE* for mky + +char mrtgoutpath[256]; //used be convname2ip and convip2name + +#endif |
