#!/bin/bash #This script will create a folder inside the directory /var/www/html/mrtg" #which is named by the first argument. It will also create a cfg file inside #the /etc/mrtg folder, and also add a line to the script "/etc/mrtg/all-ip" #so that crontab will run this script which in turn will run mrtg for each #device. The second argument is the IP address of each device to be monitored.. #This script is best run when "all" the workstations connected to it are #powered up because "cfgmaker" ignores inactive ports when it is run. # EX: # Arg1 Arg2 # | | #[root@localhost /root]# create-mrtg IDFSW1 10.0.0.1 # # Create a "workdir" for this device using the first argument mkdir -p /var/www/html/mrtg/$1 #Create the cfg file for this Ip address using the first variable #This assumes that the "community string" is set to "public" perl /usr/bin/cfgmaker public@$2 --global "workdir: /var/www/html/mrtg/$$1" --output /etc/mrtg/$1.cfg #Create an index.html file for this folder using the first variable perl /usr/bin/indexmaker /etc/mrtg/$1.cfg > /var/www/html/mrtg/$1/index.html #Create an entry in script "all-ip" to run mrtg for each device. echo "/usr/bin/mrtg /etc/mrtg/$1.cfg;" >> /etc/mrtg/all-ip #Uncommenting the line below will create a "master" index.html #inside the /var/www/html directory for all devices. #Note that this line will create a text file called index.html. #It should be edited for correct html syntax. # #echo "
MRTG of Device $1 " >> /var/www/html/mrtg/index.html