PHP Classes
elePHPant
Icontem

RRD Manipulator: Retrieve server traffic information using RRDTool

Recommend this page to a friend!
  Info   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2009-11-18 (6 years ago) RSS 2.0 feedNot yet rated by the usersTotal: 560 All time: 5,194 This week: 889Up
Version License PHP version Categories
rrd-manipulator 1.0GNU General Publi...5Networking, System information
Description Author

This class can be used to retrieve server traffic information using RRDTool.

It takes as parameters about the RRD file paths, network interfaces and period to analyze.

The class retrieves information about the in and out traffic currently, average, maximum and percentage.

Innovation Award
PHP Programming Innovation award nominee
December 2009
Number 5


Prize: One copy of Delphi for PHP
RRDTool is a package of programs for logging and graphing time series data in a so called Round Robin Database, like for instance network traffic data.

This class can be used to retrieve network statistics logged by RRDTool.

Manuel Lemos
Picture of monjurul hasan
Name: monjurul hasan <contact>
Classes: 1 package by
Country: Bangladesh Bangladesh
Innovation award
Innovation award
Nominee: 1x

Details
################################################################################
#                            rrdmrtg.class.php                                 #
#                                                                              #
#                                                                              #
#                        Created by Md. Monjurul Hasan                         #
#                                                                              #
#                        Website: http://www.monjurulhasan.com                 #
#                                                                              #
#                        Email: jewel.buet.cse@gmail.com                       #
#                                                                              #
################################################################################


Please read below to successfully implement this class

Intended use 
To manipulate RRD values (Average, Maximum, Last and 95th Percentile) using PHP-RRDTool API, current PHP-RRDTool API only gives us the rrd values fetch feature.

Pre-requisites
1. Network bandwidth calculation using SNMP-MRTG-RRDTool-PHP
2. Time series RRDTool-MRTG should be enabled in linux server. For this application, platform was CentOS 5.2 with RRDTool 1.2.27, PHP 5.1.6 and rrdtool-php-1.2.27 enabled.
3. RRD database is updated continuously otherwise you wont see values in the display table

Value Estimation Algorithms
Calculating Average: Sum of values/Total # of value
Last/Current Value: Last updated value (in and out) in rrd file 
Maximum: Get the maximum of the rrd values (in and out)
95th Percentile:
For my algorithm, please read the following example that I found from http://forums.cacti.net/post-95140.html&highlight=

Say we have a series of data stored, we want to calculate the 95th percentile for this series of data.

1. We take the set of data, this data is an array of values retrieved from RRDtool.
array: [ 2345, 3456, 1234, 5678, 7890, 5675, 3452, 56758, 2345, 234, 57788 ]

2. We have to sort the array, because we are only interested in knowing the 95th highest value.
array: [ 234, 1234, 2345, 2345, 3452, 3456, 5675, 5678, 7890, 56758, 57788 ]

3. We take the number of elements in the array (11) and we multiply by the Nth percentage we want (.95) and we then round that value.
round( 11 * .95 ) = 10 = Array element of interest

4. We then return the 95th percentile number, which is the 10 element in the array.

All values are round up.

Files included:
config file //required for the rrdfiles path
test.php //test file 
rrdmrtg.php // main class file
HelperFunc.php //helper functions
datagrid.css //css file for the table
images/head_bg.gif //required for the display table
Screenshot.png //a screenshot of the output 

Could not include here the rrd files:
rra/test1.rrd //required rrd files for test
rra/test2.rrd

Thanks for reading.
################################   End   ###########################################
Md. Monjurul Hasan
Website: http://www.monjurulhasan.com

Please post me bugs and feature requests At: jewel.buet.cse@gmail.com

	
  Files folder image Files  
File Role Description
Files folder imageimages (1 file)
Accessible without login Plain text file config.php Conf. config file
Accessible without login Plain text file datagrid.css Data Data grid css file
Plain text file HelperFunc.php Class Helper Functions
Accessible without login Plain text file README.txt Doc. Instructions before use
Plain text file rrd_manipulator.php Class Main Class file
Accessible without login Plain text file test.php Example Test Script for the class

  Files folder image Files  /  images  
File Role Description
  Accessible without login Image file head_bg.gif Icon Header Image File for display table

 Version Control Unique User Downloads Download Rankings  
 0%
Total:560
This week:0
All time:5,194
This week:889Up