solutions
-
install mrtg ubuntu 11.10 debian squeeze
-
install
mrtg
andsnmp
$ sudo apt-get install snmpd mrtg
-
configure
snmp
$ sudo mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.bak $ sudo pico /etc/snmp/snmpd.conf rocommunity public syslocation "hadoop" syscontact hqlgree2@gmail.com com2sec public localhost public group public v1 public group public v2c public group public usm public view all included .1 access public "" any noauth exact all none none
-
check
/etc/default/snmpd
$ sudo pico /etc/default/snmpd ... SNMPDRUN=yes SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid -c /etc/snmp/snmpd.conf' TRAPDRUN=yes SNMPDCOMPAT=yes
-
restart
snmpd
$ sudo /etc/init.d/snmpd restart
-
configure mrtg
# 1. create folder $ sudo mkdir /var/www/mrtg $ sudo chmod o+w /var/www/mrtg # 2. create configuration file $ sudo cfgmaker --global 'WorkDir:/var/www/mrtg' \ --ifref=name --ifdesc=eth --global 'Options[_]: bits' \ --output /etc/mrtg.cfg public@localhost # 3. create index file $ sudo indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html # 4. run mrtg $ sudo env LANG=C /usr/bin/mrtg /etc/mrtg.cfg
-
create scheduled job
$ sudo crontab -e */5 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg.cfg
-
-
nagios switch-check_mrtgtraf: unable to open mrtg log file
-
place output files in
/etc/mrtg/conf.d
# change it from $ cfgmaker --global 'WorkDir:/var/www/html/mrtg' \ --global 'Options[_]: bits,growright' \ --output /etc/mrtg/mrtg.cfg public@192.168.1.253 # to $ cfgmaker --global 'WorkDir:/var/www/html/mrtg' \ --global 'Options[_]: bits,growright' \ --output /etc/mrtg/conf.d/192.168.1.253.cfg \ public@192.168.1.253 # and then on your next one you add $ cfgmaker --global 'WorkDir:/var/www/html/mrtg' \ --global 'Options[_]: bits,growright' \ --output /etc/mrtg/conf.d/192.168.2.253.cfg \ public@192.168.2.253
-
-
how to install and configure mrtg on ubuntu server
-
install
mrtg
$ sudo apt-get update $ sudo apt-get install mrtg # yes => file permissions 640 # no => file permissions 644
-
sample configure file
$ sudo cat /etc/mrtg.cfg # full listing of what # mrtg installs and where $ sudo updatedb && locate mrtg
-
keep things tidy
# mv mrtg.cfg into a folder $ sudo mkdir /etc/mrtg $ sudo mv /etc/mrtg.cfg /etc/mrtg
-
configure
# note 192.168.1.253 is your router's ip $ sudo cfgmaker --output=/etc/mrtg/mrtg.cfg public@192.168.1.253 # two or more router $ sudo cfgmaker --output=/etc/mrtg/mrtg.cfg public@192.168.1.253 public@192.168.2.253 # uncomment $ sudo pico /etc/mrtg/mrtg.cfg ... # under debian WorkDir: /var/www/mrtg ... # under global defaults Options[_]: growright, bits ... # under EnableIPv6: no # of global defaults RunAsDaemon: Yes Interval: 5 # this means that every 5 minutes # mrtg will poll the snmp service # in your gateway/router and update its graphs # by default mrtg graphs grow to the left # so by adding `growright` will flips the graphs # `bits` means that the monitored traffice values # obtained from gateway/router are multiplied by 8 # displayed bits/s instead of bytes/s
-
create web page
# 1. create page $ sudo mkdir /var/www/mrtg $ sudo indexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg # 2. config apache2 $ sudo pico /etc/apache2/apache.conf ... Alias /mrtg "/var/www/mrtg/" <Directory "/var/www/mrtg"> Options None AllowOverride None Require all granted </Directory> # 3. restart apache $ sudo service apache2 restart # 4. fix `...reliably determine the server's fully qualified domain name...` # add following line to $ sudo pico /etc/apache2/apache.conf ... ServerName localhost:80
-
start
$ sudo env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --logging /var/log/mrtg.log
-
operate
# automate the process of running mrtg $ cd $ pico mrtg #! /bin/sh ### BEGIN INIT INFO # Provides: mrtg # Required-Start: # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: mrtg init script # Description: This file is used to start, stop, restart, # and determined status of the mrtg daemon. # Author: iceflatline <iceflatline@gmail.com> ### END INIT INFO ### START OF SCRIPT set -e # PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="mrtg" NAME=mrtg DAEMON=/usr/bin/$NAME DAEMON_ARGS="/etc/mrtg/mrtg.cfg --logging /var/log/mrtg.log" PIDFILE=/etc/mrtg/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME # Exit if the mrtg package is not installed [ -x "$DAEMON" ] || exit 0 # Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh # Define LSB log_* functions. # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions # Function that starts the mrtg daemon start() { env LANG=C start-stop-daemon --start --quiet \ --exec $DAEMON -- $DAEMON_ARGS } # Function that stops the mrtg daemon stop() { start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \ --pidfile $PIDFILE } case "$1" in start) log_daemon_msg "Starting $DESC" start case "$?" in 0) log_end_msg 0 ;; 1) log_end_msg 1 ;; esac ;; stop) log_daemon_msg "Stopping $DESC" stop case "$?" in 0) log_end_msg 0 ;; 1) log_end_msg 1 ;; esac ;; restart|force-reload) log_daemon_msg "Restarting $DESC" stop case "$?" in 0|1) start case "$?" in 0) log_end_msg 0 ;; 1) log_end_msg 1 ;; esac ;; esac ;; status) status_of_proc "$DAEMON" "$NAME" ;; *) echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" ;; esac exit 0 ### END OF SCRIPT
-
use the script
# 1. save to /etc/init.d $ chmod +x mrtg $ sudo mv mrtg /etc/init.d/ # 2. link mrtg script to # all of multi-user run levels (2-5) $ sudo update-rd.d mrtg defaults # remove script from multi-user run levels $ sudo update-rc.d -f mrtg remove # 3. start mrtg use this script $ sudo service mrtg start
-
-
nagios core 4 installation on ubuntu 12.04
-
copy the included config from nagios
$ cd ~/Downloads/nagioscore-nagios-4.0.8/sample-config $ cp mrtg.cfg /usr/local/nagios/etc/
-
create a folder for the graphs and files
$ mkdir -p /usr/local/nagios/share/stats
-
config mrtg to use this folder
$ sudo pico /usr/local/nagios/etc/mrtg.cfg # add the following at the top of the file WorkDir: /usr/local/nagios/share/stats
-
do the initial run
$ sudo env LANG=C /usr/bin/mrtg /usr/local/nagios/etc/mrtg.cfg
-
create the html pages
$ sudo /usr/bin/indexmaker /usr/local/nagios/etc/mrtg.cfg \ --output=/usr/local/nagios/share/stats/index.html
-
create a cron job to run mrtg every 5 minutes
$ sudo pico /etc/cron.d/mrtg-nagios */5 * * * * root env LANG=C /usr/bin/mrtg /usr/local/nagios/etc/mrtg.cfg
-
browser
http://node5/nagios/stats
-
add link to nagios menu
$ sudo pico /usr/local/nagios/share/side.php <div class="navsection"> <div class="navsectiontitle">Extra Tools</div> <div class="navsectionlinks"> <ul class="navsectionlinks"> <li><a href="/nagios/stats" target="<?php echo $link_target;?>">MRTG stats</a></li> </ul> </div> </div> </div>
-