Difference between revisions of "Instalasi MRTG"

From OnnoWiki
Jump to navigation Jump to search
Line 15: Line 15:
 
Before starting, you will need to install some packages to your system. You can install all of them by running the following command:
 
Before starting, you will need to install some packages to your system. You can install all of them by running the following command:
  
sudo apt-get install apache2 snmp snmpd -y
+
sudo apt-get install apache2 snmp snmpd -y
  
 
Once all the packages are installed, start apache and snmp service and enable them to start on boot with the following command:
 
Once all the packages are installed, start apache and snmp service and enable them to start on boot with the following command:
  
sudo systemctl start apache2
+
sudo systemctl start apache2
sudo systemctl enable apache2
+
sudo systemctl enable apache2
sudo systemctl start snmpd
+
sudo systemctl start snmpd
sudo systemctl enable snmpd
+
sudo systemctl enable snmpd  
  
 
Install and Configure MRTG
 
Install and Configure MRTG
Line 28: Line 28:
 
By default, MRTG is available in the Ubuntu 18.04 default repository. You can install it by just running the following command:
 
By default, MRTG is available in the Ubuntu 18.04 default repository. You can install it by just running the following command:
  
sudo apt-get install mrtg -y
+
sudo apt-get install mrtg -y
  
 
After installing MRTG, you will need to configure it to monitoring target devices. First, create a MRTG directory inside Apache root directory:
 
After installing MRTG, you will need to configure it to monitoring target devices. First, create a MRTG directory inside Apache root directory:
  
sudo mkdir /var/www/mrtg
+
sudo mkdir /var/www/mrtg
  
 
Next, give proper ownership to the mrtg directory:
 
Next, give proper ownership to the mrtg directory:
  
sudo chown -R www-data:www-data /var/www/mrtg
+
sudo chown -R www-data:www-data /var/www/mrtg
  
 
Next, rebuild MRTG configuration with the following command:
 
Next, rebuild MRTG configuration with the following command:
  
sudo cfgmaker public@localhost > /etc/mrtg.cfg
+
sudo cfgmaker public@localhost > /etc/mrtg.cfg
  
 
You should see the following output:
 
You should see the following output:
Line 58: Line 58:
 
Next, Create an index file for the /web server with the following command:
 
Next, Create an index file for the /web server with the following command:
  
sudo indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html
+
sudo indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html
  
 
Configure Apache for MRTG
 
Configure Apache for MRTG
Line 64: Line 64:
 
Next, you will need to create an apache virtual host file for MRTG. You can do this with the following command:
 
Next, you will need to create an apache virtual host file for MRTG. You can do this with the following command:
  
sudo nano /etc/apache2/sites-available/mrtg.conf
+
sudo nano /etc/apache2/sites-available/mrtg.conf
  
 
Add the following lines:
 
Add the following lines:
  
<VirtualHost *:80>
+
<VirtualHost *:80>
ServerAdmin admin@yourdomain.com
+
ServerAdmin admin@yourdomain.com
DocumentRoot "/var/www/mrtg"
+
DocumentRoot "/var/www/mrtg"
ServerName yourdomain.com
+
ServerName yourdomain.com
<Directory "/var/www/mrtg/">
+
<Directory "/var/www/mrtg/">
Options None
+
Options None
AllowOverride None
+
AllowOverride None
Order allow,deny
+
Order allow,deny
Allow from all
+
Allow from all
Require all granted
+
Require all granted
</Directory>
+
</Directory>
TransferLog /var/log/apache2/mrtg_access.log
+
TransferLog /var/log/apache2/mrtg_access.log
ErrorLog /var/log/apache2/mrtg_error.log
+
ErrorLog /var/log/apache2/mrtg_error.log
</VirtualHost>
+
</VirtualHost>
  
 
Save and Close the file, when you are finished. Then enable virtual host and restart apache service to apply all the changes:
 
Save and Close the file, when you are finished. Then enable virtual host and restart apache service to apply all the changes:
  
sudo a2ensite mrtg
+
sudo a2ensite mrtg
sudo systemctl restart apache2
+
sudo systemctl restart apache2
  
 
Now, open your web browser and type the URL http://yourdomain.com. You will be redirected to the following page:
 
Now, open your web browser and type the URL http://yourdomain.com. You will be redirected to the following page:

Revision as of 08:26, 14 May 2020

Sumber: https://www.howtoforge.com/tutorial/how-to-install-and-configure-mrtg-on-ubuntu-1804/


MRTG also known as "Multi Router Traffic Grapher" is a free and open source tool to monitor the traffic load on network links. You can monitor daily, weekly, monthly and yearly network traffic using MRTG. MRTG supports for Windows and Linux operating system. MRTG provides a simple web interface to display network traffic data in graphical form.

In this tutorial, we will learn how to install MRTG on Ubuntu 18.04 server. Requirements

   A server running Ubuntu 18.04.
   A non-root user with sudo privileges.

Install Required Packages

Before starting, you will need to install some packages to your system. You can install all of them by running the following command:

sudo apt-get install apache2 snmp snmpd -y

Once all the packages are installed, start apache and snmp service and enable them to start on boot with the following command:

sudo systemctl start apache2
sudo systemctl enable apache2
sudo systemctl start snmpd
sudo systemctl enable snmpd 

Install and Configure MRTG

By default, MRTG is available in the Ubuntu 18.04 default repository. You can install it by just running the following command:

sudo apt-get install mrtg -y

After installing MRTG, you will need to configure it to monitoring target devices. First, create a MRTG directory inside Apache root directory:

sudo mkdir /var/www/mrtg

Next, give proper ownership to the mrtg directory:

sudo chown -R www-data:www-data /var/www/mrtg

Next, rebuild MRTG configuration with the following command:

sudo cfgmaker public@localhost > /etc/mrtg.cfg

You should see the following output:

cfgmaker public@localhost > /etc/mrtg.cfg --base: Get Device Info on public@localhost: --base: Vendor Id: Unknown Vendor - 1.3.6.1.4.1.8072.3.2.10 --base: Populating confcache --base: Get Interface Info --base: Walking ifIndex --base: Walking ifType --base: Walking ifAdminStatus --base: Walking ifOperStatus --base: Walking ifMtu --base: Walking ifSpeed

Next, Create an index file for the /web server with the following command:

sudo indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html

Configure Apache for MRTG

Next, you will need to create an apache virtual host file for MRTG. You can do this with the following command:

sudo nano /etc/apache2/sites-available/mrtg.conf

Add the following lines:

<VirtualHost *:80>
ServerAdmin admin@yourdomain.com
DocumentRoot "/var/www/mrtg"
ServerName yourdomain.com
<Directory "/var/www/mrtg/">
Options None
AllowOverride None
Order allow,deny
Allow from all
Require all granted
</Directory>
TransferLog /var/log/apache2/mrtg_access.log
ErrorLog /var/log/apache2/mrtg_error.log
</VirtualHost>

Save and Close the file, when you are finished. Then enable virtual host and restart apache service to apply all the changes:

sudo a2ensite mrtg
sudo systemctl restart apache2

Now, open your web browser and type the URL http://yourdomain.com. You will be redirected to the following page:


Referensi

Pranala Menarik