Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to merge two pictures in Cacti

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to merge two pictures in Cacti". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to merge two pictures in Cacti.

Cacti is a great open source network monitoring system that is widely used to graphically display network elements such as bandwidth, storage, processor, and memory usage. Using its Web-based interface, you can easily create and organize a variety of charts. However, it does not provide some advanced features by default, such as merging pictures, creating aggregate graphics using multiple sources, and migrating Cacti to another server. You also need some experience to use these features of Cacti. In this tutorial, we will see how to merge two Cacti images into one.

Take a look at this example. In the past 6 months, client A has connected to port 5 of switch A. An error occurred on port 5, so the client migrated to port 6. Because Cacti uses a different diagram for each interface / element, the client's bandwidth history is divided into port 5 and port 6. The result is that we have two images for one client-one is 6 months old data, and the other holds the subsequent data.

In this case, we can actually merge two images to add the old data to the new one, so that a single graph can be used to save historical and new data for a single user. This tutorial will explain how to do this.

Cacti saves the data of each picture in its own RRD (round robin database, circular database) file. When a picture is requested, the graph is generated according to the values saved in the corresponding RRD file. On Ubuntu/Debian systems, the RRD file is saved in / var/lib/cacti/rra, and on CentOS/RHEL systems it is / var/www/cacti/rra.

The idea behind merging images is to change these RRD files so that the values from the old RRD file can be appended to the new RRD file.

Scenario

A client service has been running on eth0 for more than a year. Due to hardware corruption, the client migrates to the eth2 interface of another server. We want to show the bandwidth of the new interface while retaining more than a year of historical data. The client wants to be displayed in only one picture.

Determine the RRD file of the diagram

The first step in graph merging is to determine the RRD file associated with the diagram. We can check the file by opening the diagram in debug mode. To do this, in the Cacti menu: console > manage Diagram > Select Diagram > Open Diagram Debug Mode.

Old image:

New figure:

From the sample output (based on the Debian system), we can determine the RRD file for the two pictures:

Old figure: / var/lib/cacti/rra/old_graph_traffic_in_8.rrd

New figure: / var/lib/cacti/rra/new_graph_traffic_in_10.rrd

Prepare the script

We will use a RRD splicing script to merge the two RRD files. Download the PHP script and install it on / var/lib/cacti/rra/rrdsplice.php (Debian/Ubuntu system) or / var/www/cacti/rra/rrdsplice.php (CentOS/RHEL system).

Next, confirm that the Apache user owns the file.

On Debian or Ubuntu systems, run the following command:

# chown www-data:www-data rrdsplice.php

And update rrdsplice.php. Find the following line:

Chown ($finrrd, "apache")

Replace it with the following statement:

Chown ($finrrd, "www-data")

On CentOS or RHEL systems, run the following command:

# chown apache:apache rrdsplice.php merges two images

You can get the usage syntax of the script by running the script without any parameters.

# cd / path/to/rrdsplice.php# php rrdsplice.phpUSAGE: rrdsplice.php-oldrrd=file-newrrd=file-finrrd=file

Now we are ready to merge the two RRD files. You only need to specify the names of the old RRD file and the new RRD file. We will rewrite the merged result to the new RRD file.

# php rrdsplice.php-oldrrd=old_graph_traffic_in_8.rrd-newrrd=new_graph_traffic_in_10.rrd-finrrd=new_graph_traffic_in_10.rrd

Now the data from the old RRD file has been appended to the new RRD file. Cacti writes any new data to the new RRD file. If we click on the picture, we can find that the week, month, and annual records of the old graph have also been added. The second picture in the chart below shows the weekly record of the old one.

In summary, the tutorial shows how to simply merge two Cacti images into one. This tip is useful when the service is migrated to another device / interface and we want to deal with only one image instead of two. This script is very convenient because it can merge pictures regardless of whether the source devices are the same or not, such as Cisco 1800 routers and Cisco 2960 switches.

At this point, I believe you have a deeper understanding of "how to merge two pictures in Cacti". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report