Step 1: Enable Repositories and Install Dependencies
# Enable the EPEL repository
[root@node1 ~]# dnf install -y https://fedoraproject.org
# Enable the CodeReady Builder repository (needed for EPEL dependencies)
[root@node1 ~]# subscription-manager repos --enable
codeready-builder-for-rhel-8-x86_64-rpms
# Update the dnf cache
[root@node1 ~]# dnf makecache
# Install MRTG, SNMP tools, and Apache Web Server
[root@node1 ~]# dnf install -y mrtg net-snmp net-snmp-utils httpd
Step 2: Configure and Start SNMP
#Open the SNMP configuration file
[root@node1 ~]# vi /etc/snmp/snmpd.conf
#Map a community name (e.g., public) to a security name. Find or add the line
[root@node1 ~]# rocommunity public 127.0.0.1
#Start and enable the SNMP daemon:
[root@node1 ~]# systemctl enable --now snmpd
Test that SNMP is responding locally:
[root@node1 ~]# snmpwalk -v 2c -c public 127.0.0.1 system
Step 3: Configure Apache Web Server
Create a web directory to host the HTML and PNG image files that MRTG generates.
# Create the directory for MRTG web files
[root@node1 ~]# mkdir -p /var/www/html/mrtg
# Give ownership to the Apache user
[root@node1 ~]# chown -R apache:apache /var/www/html/mrtg
# Start and enable Apache
[root@node1 ~]# systemctl enable --now httpd
Step 4: Generate the MRTG Configuration File
# Generate the config file
[root@node1 ~]# cfgmaker --global "WorkDir: /var/www/html/mrtg" \
--global "Options[_]: growright,bits" \
--output=/etc/mrtg/mrtg.cfg \
public@127.0.0.1
Step 5: Generate the Web Index Page
Use indexmaker to scan your newly created mrtg.cfg and generate a central web index page:
[root@node1 ~]# indexmaker --output=/var/www/html/mrtg/index.html /etc/mrtg/mrtg.cfg
Step 6: Test Run MRTG
(Note: It is normal to see warnings about missing log files during the first two runs, as it has to build them from scratch.)
[root@node1 ~]#env LANG=C mrtg /etc/mrtg/mrtg.cfg
[root@node1 ~]#firewall-cmd --permanent --add-service=http
[root@node1 ~]#s firewall-cmd --reload
http://<your-server-ip>/mrtg/http://192.168.184.131/mrtg/
No comments:
Post a Comment