Article title: MRTG application practice autobiography: How does network management achieve high salaries ?. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Editor's note: We often complain: Why is the income from network management low? However, when network administrators only use network management tools, some people are trying to transform and develop network management tools to achieve better network management efficiency, it is the road to high salaries for network administrators!
This is another self-transmission masterpiece of xiangziji "Xiangzi's autobiography: How to grow into a senior engineer. The MRTG software is a network traffic monitoring tool and an essential tool for network management by many network administrators. However, when many people only use MRTG, Xiangzi conducts deep mining on MRTG, especially in combination with Linux script programming, and conducts secondary development on MRTG, improved network management efficiency.
Undoubtedly, Xiangzi's practice is worth learning. Just a few days ago, Xiangzi was pleased to mention that he had passed the internal position competition and was promoted to the project manager. As a result, Xiangzi has grown from a former senior network engineer to a project manager responsible for the entire network system project team. Congratulations to Xiangzi. I believe this is also the wish of many network administrators.
Basic application: set MRTG to a self-starting Program
MRTG intermediate application: set parameters to make output more accurate
Advanced Skills 1 use scripts to simplify command input
Intermediate and advanced skills 2 use the results of FC command comparison
Advanced script development and application: change the MRTG and switch ports as needed
Xiang Zi and his colleagues have been using the MRTG software for some years. now many colleagues have learned to use MRTG to monitor the traffic of network devices (such as switches, routers, and firewalls) in the LAN, however, we also found some problems during use. for example, in the actual network, the terminal devices connected to the switch ports often change. every time we make such a change, we need to re-modify the configuration file, it is troublesome to enter a long line of configuration string, and it is easy to make errors manually, or you forget to enable the MRTG process when restarting the server, resulting in a blank network traffic for a period of time, if you want to monitor multiple network devices in the LAN, you may have missed the parameters when starting the process. after a few days, you will find that there are still several devices that do not generate traffic statistics.
Tool application: not just superficial
All kinds of inconveniences make us feel that the MRTG application should not only stay on the superficial layer, but should be tapped into to explore the advanced MRTG application in depth, using Linux Shell programming for secondary development, unexpected management efficiency is achieved. The following is a report on the results of this study (we use Hongqi LINUX6.0 desktop edition + mrtg1_.2 as the platform for this study)
Basic application: set MRTG to a self-starting Program
This is the most basic requirement for the MRTG process to start along with the system, because the most basic function of MRTG is to record the traffic of network devices in real time, and the operating system always restarts, what we need to achieve is that after the system is restarted, MRTG also starts. how can this problem be solved? Make a script and place it in the/etc/rc.5/Directory. There are several points to note.
(1) correctly determine the directory where the script is stored
In this article, the MRTG program runs in the desktop environment of the Hongqi LINUX6.0 operating system. Therefore, the startup file is stored in the/etc/rc5.d/directory.
(2) create a startup script
The content is as follows:
[Root @ jncatvrd6a htdocs] # more/etc/rc5.d/S31mrtg
#! /Bin/sh
Cd/usr/local/mrtg-2/bin &./mrtg/usr/local/mrtg-2/bin/cfg/192.168.3.1.cfg
This file starts with an uppercase "S" and is represented as a startup file followed by two digits, followed by a string that marks the program.
(3) set the correct permissions for the script
Even if a formatted file name is created, the script content is normal. after the computer is restarted, the MRTG process cannot be started correctly. the reason for the failure is probably that the permission is not set correctly, you can check the restriction settings of other files in this directory and find that they are all executable files. just write them as they are:
[Root @ jncatvrd6a rc5.d] # chmod 777 S31mrtg
[Root @ jncatvrd6a rc5.d] # ls-l S31mrtg
-Rwxrwxrwx 1 root 87 10-27 16:25 S31mrtg
After completing the above three steps, MRTG can start with the system.
(4) do not forget to start the WWW publishing process at the same time.
We published the webpage (the result of MRTG monitoring) through the APACHE program. we also need to set this program to automatically start.
[Root @ jncatvrd6a rc5.d] # chmod 777 S65apache
[Root @ jncatvrd6a rc5.d] # more S65apache
#! /Bin/sh
Cd/usr/local/apache2/bin &./apachectl start
[1] [2] [3] [4] [5] Next page