diff --git a/sources/tech/20150615 How to combine two graphs on Cacti.md b/sources/tech/20150615 How to combine two graphs on Cacti.md deleted file mode 100644 index 6b13ccd612..0000000000 --- a/sources/tech/20150615 How to combine two graphs on Cacti.md +++ /dev/null @@ -1,92 +0,0 @@ -Translating by ictlyh -How to combine two graphs on Cacti -================================================================================ -[Cacti][1] a fantastic open source network monitoring system that is widely used to graph network elements like bandwidth, storage, processor and memory utilization. Using its web based interface, you can create and organize graphs easily. However, some advanced features like merging graphs, creating aggregate graphs using multiple sources, migration of Cacti to another server are not provided by default. You might need some experience with Cacti to pull these off. In this tutorial, we will see how we can merge two Cacti graphs into one. - -Consider this example. Client-A has been connected to port 5 of switch-A for the last six months. Port 5 becomes faulty, and so the client is migrated to Port 6. As Cacti uses different graphs for each interface/element, the bandwidth history of the client would be split into port 5 and port 6. So we end up with two graphs for one client - one with six months' worth of old data, and the other that contains ongoing data. - -In such cases, we can actually combine the two graphs so the old data is appended to the new graph, and we get to keep a single graph containing historic and new data for one customer. This tutorial will explain exactly how we can achieve that. - -Cacti stores the data of each graph in its own RRD (round robin database) file. When a graph is requested, the values stored in a corresponding RRD file are used to generate the graph. RRD files are stored in `/var/lib/cacti/rra` in Ubuntu/Debian systems and in `/var/www/cacti/rra` in CentOS/RHEL systems. - -The idea behind merging graphs is to alter these RRD files so the values from the old RRD file are appended to the new RRD file. - -### Scenario ### - -The services for a client is running on eth0 for over a year. Because of hardware failure, the client has been migrated to eth1 interface of another server. We want to graph the bandwidth of the new interface, while retaining the historic data for over a year. The client would see only one graph. - -### Identifying the RRD for the Graph ### - -The first step during graph merging is to identify the RRD file associated with a graph. We can check the file by opening the graph in debug mode. To do this, go to Cacti's menu: Console > Graph Management > Select Graph > Turn On Graph Debug Mode. - -#### Old graph: #### - -![](https://farm4.staticflickr.com/3853/18795518096_f50a78d082_c.jpg) - -#### New graph: #### - -![](https://farm4.staticflickr.com/3674/18634036918_5c4118c4b9_c.jpg) - -From the example output (which is based on a Debian system), we can identify the RRD files for two graphs: - -- **Old graph**: /var/lib/cacti/rra/old_graph_traffic_in_8.rrd -- **New graph**: /var/lib/cacti/rra/new_graph_traffic_in_10.rrd - -### Preparing a Script ### - -We will merge two RRD files using a [RRD splice script][2]. Download this PHP script, and install it as /var/lib/cacti/rra/rrdsplice.php (for Debian/Ubuntu) or /var/www/cacti/rra/rrdsplice.php (for CentOS/RHEL). - -Next, make sure that the file is owned by Apache user. - -On Debian or Ubuntu, run the following command: - - # chown www-data:www-data rrdsplice.php - -and update rrdsplice.php accordingly. Look for the following line: - - chown($finrrd, "apache"); - -and replace it with: - - chown($finrrd, "www-data"); - -On CentOS or RHEL, run the following command: - - # chown apache:apache rrdsplice.php - -### Merging Two Graphs ### - -The syntax usage of the script can easily be found by running it without any parameters. - - # cd /path/to/rrdsplice.php - # php rrdsplice.php - ----------- - - USAGE: rrdsplice.php --oldrrd=file --newrrd=file --finrrd=file - -Now we are ready to merge two RRD files. Simply supply the names of an old RRD file and a new RRD file. We will overwrite the merged result back 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 should be appended to the new RRD. Any new data will continue to be written by Cacti to the new RRD file. If we click on the graph, we should be able to verify that the weekly, monthly and yearly records have also been added from the old graph. The second graph in the following diagram shows weekly records from the old graph. - -![](https://farm6.staticflickr.com/5493/18821787015_6730164068_b.jpg) - -To sum up, this tutorial showed how we can easily merge two Cacti graphs into one. This trick is useful when a service is migrated to another device/interface and we want to deal with only one graph instead of two. The script is very handy as it can join graphs regardless of the source device e.g., Cisco 1800 router and Cisco 2960 switch. - -Hope this helps. - --------------------------------------------------------------------------------- - -via: http://xmodulo.com/combine-two-graphs-cacti.html - -作者:[Sarmed Rahman][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:http://xmodulo.com/author/sarmed -[1]:http://xmodulo.com/install-configure-cacti-linux.html -[2]:http://svn.cacti.net/viewvc/developers/thewitness/rrdsplice/rrdsplice.php \ No newline at end of file diff --git a/translated/tech/20150615 How to combine two graphs on Cacti.md b/translated/tech/20150615 How to combine two graphs on Cacti.md new file mode 100644 index 0000000000..49abbf76d1 --- /dev/null +++ b/translated/tech/20150615 How to combine two graphs on Cacti.md @@ -0,0 +1,92 @@ +如何在 Cacti 中合并两幅图片 +================================================================================ +[Cacti][1] 是一个很棒的开源网络监视系统,它广泛使用于图示网络元素,例如带宽、存储、处理器和内存使用。使用它的基于网络的接口,你可以轻松地创建和组织图。然而,默认并没有提供一些高级功能,例如合并图片、使用多个来源创建聚合图、迁移 Cacti 到另一台服务器。使用 Cacti 的这些功能你还需要一些经验。在该教程中,我们会看到如何在将两幅 Cacti 图片合并为一幅。 + +考虑这个例子。在过去的 6 个月中,客户端 A 连接到了交换机 A 的端口 5。端口 5 发生了错误,因此客户端迁移到了端口 6。由于 Cacti 为每个接口/元素使用不同的图,客户端的带宽历史会分成端口 5 和端口 6。结果是对于一个客户端我们有两幅图片 - 一幅是 6 个月的旧数据,另一幅保存了后续的数据。 + +在这种情况下,我们实际上可以合并两幅图片将旧数据加到新的图中,使得用一个单独的图为一个用户保存历史的和新数据。该教程将会解释如何做到这一点。 + +Cacti 将每幅图片的数据保存在它自己的 RRD(round robin database,循环数据库) 文件中。当请求一幅图片时,根据保存在对应 RRD 文件中的值生成图。在 Ubuntu/Debian 系统中,RRD 文件保存在 `/var/lib/cacti/rra`,在 CentOS/RHEL 系统中则是 `/var/www/cacti/rra`。 + +合并图片背后的思想是更改这些 RRD 文件使得旧 RRD 文件中的值能追加到新的 RRD 文件中。 + +### 情景 ### + +一个客户端的服务在 eth0 上运行了超过一年。由于硬件损坏,客户端迁移到了另一台服务器的 eth1 接口。我们想图示新接口的带宽,同时保留超过一年的历史数据。只在一幅图中显示客户端。 + +### 确定图的 RRD 文件 ### + +图合并的首个步骤是确定和图关联的 RRD 文件。我们可以通过以调试模式打开图检查文件。要做到这点,在 Cacti 的菜单中: 控制台 > 管理图 > 选择图 > 打开图调试模式。 + +#### 旧图: #### + +![](https://farm4.staticflickr.com/3853/18795518096_f50a78d082_c.jpg) + +#### 新图: #### + +![](https://farm4.staticflickr.com/3674/18634036918_5c4118c4b9_c.jpg) + +从样例输出(基于 Debian 系统)中,我们可以确定两幅图片的 RRD 文件: +From the example output (which is based on a Debian system), we can identify the RRD files for two graphs: + +- **旧图**: /var/lib/cacti/rra/old_graph_traffic_in_8.rrd +- **新图**: /var/lib/cacti/rra/new_graph_traffic_in_10.rrd + +### 准备脚本 ### + +我们会用一个 [RRD 剪接脚本][2] 合并两个 RRD 文件。下载该 PHP 脚本,并安装为 /var/lib/cacti/rra/rrdsplice.php (Debian/Ubuntu 系统) 或 /var/www/cacti/rra/rrdsplice.php (CentOS/RHEL 系统)。 + +下一步,确认 Apache 用户拥有该文件。 + +在 Debian 或 Ubuntu 系统中,运行下面的命令: + + # chown www-data:www-data rrdsplice.php + +并更新 rrdsplice.php。查找下面的行: + + chown($finrrd, "apache"); + +用下面的语句替换: + + chown($finrrd, "www-data"); + +在 CentOS 或 RHEL 系统中,运行下面的命令: + + # chown apache:apache rrdsplice.php + +### 合并两幅图 ### + +通过不带任何参数运行该脚本可以获得脚本的使用语法。 + + # cd /path/to/rrdsplice.php + # php rrdsplice.php + +---------- + + USAGE: rrdsplice.php --oldrrd=file --newrrd=file --finrrd=file + +现在我们准备好合并两个 RRD 文件了。只需要指定旧 RRD 文件和新 RRD 文件的名称。我们会将合并后的结果重写到新 RRD 文件中。 + + # php rrdsplice.php --oldrrd=old_graph_traffic_in_8.rrd --newrrd=new_graph_traffic_in_10.rrd --finrrd=new_graph_traffic_in_10.rrd + +现在旧 RRD 文件中的数据已经追加到了新 RRD 文件中。Cacti 会将任何新数据写到新 RRD 文件中。如果我们点击图,我们可以发现也已经添加了旧图的周、月、年记录。下面图表中的第二幅图显示了旧图的周记录。 + +![](https://farm6.staticflickr.com/5493/18821787015_6730164068_b.jpg) + +总之,该教程显示了如何简单地将两幅 Cacti 图片合并为一幅。当服务迁移到另一个设备/接口,我们希望只处理一幅图片而不是两幅时,这个小技巧非常有用。该脚本非常方便,因为它可以不管源设备合并图片,例如 Cisco 1800 路由器和 Cisco 2960 交换机。 + +希望这些能对你有所帮助。 + +-------------------------------------------------------------------------------- + +via: http://xmodulo.com/combine-two-graphs-cacti.html + +作者:[Sarmed Rahman][a] +译者:[ictlyh](https://github.com/ictlyh) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://xmodulo.com/author/sarmed +[1]:http://xmodulo.com/install-configure-cacti-linux.html +[2]:http://svn.cacti.net/viewvc/developers/thewitness/rrdsplice/rrdsplice.php \ No newline at end of file