/usr/bin/cfgmaker --global 'WorkDir: /var/www/mrtg' --global 'Options[_]: bits,growright' --output /etc/mrtg.cfg public@172.16.11.104
ou pour plusieurs
/usr/bin/cfgmaker --global 'WorkDir: /var/www/mrtg' --global 'Options[_]: bits,growright' --output /etc/mrtgessai.cfg public@172.16.11.102 nagios@172.16.5.25
RUNNING MRTG
Once you have created a configuration file, try the following:
/usr/local/mrtg-2/bin/mrtg /home/mrtg/cfg/mrtg.cfg
This will query your router and also create your first mrtg trafic graphs and webpages. When you run mrtg for the first time there will be a lot of complaints about missing log files. Don't worry, this is normal for the first 2 times you start mrtg. If it keeps complaining after this time you might want to look into the problem.
Starting mrtg by hand is not ideal in the long run. So when you are satisfied with the results you can automate the process of running mrtg in regular intervals (this means every 5 minutes by default).
You can either add mrtg to your crontab with a line like this:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * \
/mrtg /mrtg.cfg \
--logging /var/log/mrtg.log
or if you live in Linux Land the line may look like this if you are using crontab -e
*/5 * * * */mrtg /mrtg.cfg \
--logging /var/log/mrtg.log
or like this if you use /etc/crontab
*/5 * * * * mrtg-user/mrtg /mrtg.cfg \
--logging /var/log/mrtg.log
You can also run mrtg as a daemon process by adding the line
RunAsDaemon: Yes
to your mrtg configuration file and then creating a startup script in your system startup sequence. Unfortunately, adding startup scripts differs widely amongst different unix systems. The modern ones normally have a directory called /etc/init.d or /etc/rc.d/init.d where you put scripts which starts the process you want to run when the system boots. Further you must create a symbolic link in /etc/rc3.d or /etc/rc.d/rc?.d called S65mrtg (this is just a sample name ... it is just important that it starts with S followed by a two digit number). If you are not sure about this, make sure you consult the documentation of your system to make sure you get this right.
A minimal script to put into init.d might look like this:
#! /bin/sh
cd /usr/local/mrtg-2.15.2/bin && ./mrtg --user=mrtg-user \
/home/httpd/mrtg/mrtg.cfg --logging /var/log/mrtg.log
Note that this will only work with RunAsDaemon: Yes in your mrtg.cfg file.
----------------------------------env LANG=C /usr/bin/mrtg /etc/mrtg.cfg
sur une debian 4.0 en français cette commande est nécessaire
------------------------------
dans le fichier services
define service {
host_name switch104
service_description port 1 bandwidth usage
check_command traffic_average!/var/www/mrtg/172.16.11.104_1.log!2000,2000!50000,50000
use generic-service
notification_interval 0 ; set > 0 if you want to be renotified
}
------------------------------------------------------------------------------------
# 'traffic_average' command definition
define command{
command_name traffic_average
command_line /usr/lib/nagios/plugins/check_mrtgtraf -F $ARG1$ -a AVG -w $ARG2$ -c $ARG3$ -e 10
}
Aucun commentaire:
Enregistrer un commentaire