1. Create a script to generate output in the proper format (low
value high value name).
mrtg_poc.sh
echo "10 5 Testing"
2. Create an mrtg.cfg file
/opt/mrtg/mrtg.cfg
WorkDir: /root
Target[Server1]: `/root/mrtg_poc.sh`
Title[Server1]: Mrtg Proof of Concept
Pagetop[Server1]: Sar info from Server1
Maxbytes[Server1]: 13
3. Execute mrtg at the command line to check for errors
/usr/local/src/mrtg-2/bin/mrtg /opt/mrtg/mrtg.cfg
3. Bring up webpage:
file:///root//Server1.html
Example System: Using scripts to gather %CPU and %WIO on
multiple servers.
1. Script to gather information
from remote servers anc copy the data to the mrtg server. Repeat
this code for each server that you are collecting data from:
#
# Server1
#
datadir="/tmp"
server="Server1"
cpu_data=$server"_cpu.txt"
wio_data=$server"_wio.txt"
#
# Get cpu utilization and wio from Server1
#
rsh $server "sar 1 1"|sed 1,4d|awk '{print $5}'>$datadir/$cpu_data
rsh $server "sar 1 1"|sed 1,4d|awk '{print $4}'>$datadir/$wio_data
#
# Write the data to Mrtg Server
rcp $datadir/$cpu_data mrtgserver:/root/$cpu_data
rcp $datadir/$wio_data mrtgserver:/root/$wio_data
2. Schedule the statisitics
script to run at the proper time intervals using crontab:
#
# Statistics on linux server mrtgserver- Every 5 minutes
#
00,05,10,15,20,25,30,35,40,45,50,55 * * * *
/opt/scripts/wte_mrtg_stats.sh
3. mrtg.cfg file on the mrtg
server to collect these statistics (each server requires these 25 lines
for %cpu and %wio):
Target[server1]: `/root/server1_cpu.pl`
Colours[server1]: LIGHT BLUE#7AAFFF,BLUE#1000FF,DARK
GREEN#006000,VIOLET#FF00FF
Options[server1]: gauge,noinfo, nopercent, growright, unknaszero
MaxBytes[server1_cpu]: 200
Title[server1_cpu]: Server server1 % CPU Utililization
YLegend[server1_cpu]: % CPU
ShortLegend[server1_cpu]: % CPU
Legend1[server1_cpu]: CPU Utilization
Legend2[server1_cpu]:
LegendI[server1_cpu]:
LegendO[server1_cpu]: CPU Utilization :
PageTop[server1_cpu]: <b>% CPU Utilization of Server
bplex_db</b>
YSize[server1_cpu]: 100
Target[server1_wio]: `/root/server1_wio.pl`
Colours[server1_wio]: LIGHT BLUE#7AAFFF,BLUE#1000FF,DARK
GREEN#006000,VIOLET#FF00FF
Options[server1_wio]: gauge,noinfo, nopercent, growright, unknaszero
MaxBytes[server1_wio]: 200
Title[server1_wio]: Server server1 % WIO
YLegend[server1_wio]: % WIO
ShortLegend[server1_wio]: % WIO
Legend1[server1_wio]: % WIO
Legend2[server1_wio]:
LegendI[server1_wio]:
LegendO[server1_wio]: % WIO :
PageTop[server1_wio]: <b>% WIO on Server server1</b>
1. Create a script to get cpu utilization from a list of servers
and write it to a file:
cat
/opt/scripts/wte_mrtg_server_cpu.sh
datadir="/opt/mrtg/server_stats"
server_list="bplex_db scorpius bpapp_gvl gvlscsun001"
for server in $server_list
do
rsh $server "sar 1 1"|sed 1,4d|awk '{print
$5}'>$datadir/$server"_cpu.txt"
done
2. Create a script to take the cpu utilization and present it to
mrtg in the proper format:
3. Configure mrtg.cfg to run the cpu utilization program
cat /opt/mrtg/mrtg.cfg
WorkDir: /var/www/html/mrtg
Target[bplex_cpu]: `/opt/mrtg/bplex_db_cpu.pl`
Colours[bplex_cpu]: LIGHT BLUE#7AAFFF,BLUE#1000FF,DARK
GREEN#006000,VIOLET#FF00FF
Options[bplex_cpu]: gauge,noinfo, nopercent, growright, unknaszero
MaxBytes[bplex_cpu]: 200
Title[bplex_cpu]: Server bplex_db % CPU Utililization
YLegend[bplex_cpu]: % CPU
ShortLegend[bplex_cpu]: % CPU
Legend1[bplex_cpu]: CPU Utilization
Legend2[bplex_cpu]:
LegendI[bplex_cpu]:
LegendO[bplex_cpu]: CPU Utilization :
PageTop[bplex_cpu]: <b>% CPU Utilization of Server
bplex_db</b>
YSize[bplex_cpu]: 100
4. Schedule in crontab
the collection of cpu utilization and the graphing of the data in mrtg:
1. Create a script to get cpu wio from a list of servers and
write it to a file:
cat
/opt/scripts/wte_mrtg_server_cpu.sh
datadir="/opt/mrtg/server_stats"
server_list="bplex_db scorpius bpapp_gvl gvlscsun001"
for server in $server_list
do
rsh $server "sar 1 1"|sed 1,4d|awk '{print
$4}'>$datadir/$server"_wio.txt"
done
2. Create a script to take the wio and present it to mrtg in the
proper format:
HP Omniback
omniback -> uma -ioctl /dev/picker < /tmp/uma_test.txt|grep
-c Full <-- on server that is Cell Manager
Veritas Netbackup
/usr/openv/volmgr/bin/vmoprcmd|grep dlt|grep -v -|wc
-l <-- on server that is Media Master
Monitoring Netbackup scratch tapes
1. Create a script to get the number of scratch tapes from the
netbackup server and write it to a file:
cat wte_mrtg_backup.sh
# Get the number of scratch tapes
from the netbackup server:
server="scorpius"
datadir="/opt/mrtg/server_stats"
datafile=$server"_scratch.txt"
rsh $server "/usr/openv/volmgr/bin/vmquery -pn Scratch"|grep -c "robot
slot" > $datadir/$datafile
2. Create a script to take the number of scratch tapes and
present it to mrtg in the proper format:
#
# nusales2
#
datadir="/tmp"
nusales2_cpu="nusales2_cpu.txt"
#
# Write the data to lupus
rcp $datadir/$nusales2_cpu lupus:/root/$nusales2_cpu
3. On the mrtg box configure the mrtg.cfg and associated
scripts:
mrtg.cfg:
Target[nusales2_cpu]: `/root/nusales2_cpu.pl`
Colours[nusales2_cpu]: LIGHT BLUE#7AAFFF,BLUE#1000FF,DARK
GREEN#006000,VIOLET#FF00FF
Options[nusales2_cpu]: gauge,noinfo, nopercent, growright, unknaszero
MaxBytes[nusales2_cpu]: 200
Title[nusales2_cpu]: Server nusales2 % CPU Utililization
YLegend[nusales2_cpu]: % CPU
ShortLegend[nusales2_cpu]: % CPU
Legend1[nusales2_cpu]: CPU Utilization
Legend2[nusales2_cpu]:
LegendI[nusales2_cpu]:
LegendO[nusales2_cpu]: CPU Utilization :
PageTop[nusales2_cpu]: <b>% CPU Utilization of Server
nusales2</b>
YSize[nusales2_cpu]: 100