It is very essential to monitor resources like RAM, CPU Load, Bandwidth etc. to ensure that they are efficiently utilized. To monitor the the resource utilization of any network device such as sever, router, switch, UPS, etc. you can follow the steps mentioned below:
1 : Create a RRD File :
First create a rrd file by using the following rrd command:
“rrdtool create $fname -s 60 DS:total:GAUGE:600:U:U DS:used:GAUGE:600:U:U RRA:AVERAGE:0.5:1:259200”
- $fname is the name you want to give to the rrd file.
- DS:total:GAUGE:600:U:U:GAUGE:600:U:U is for variable declaration, where ‘total’ is the name of the variable and GAUGE is its data-type.
- RRA:AVERAGE:0.5:1:259200 is the Round Robin Archive.
2 : Update RRD File: Once RRD file is created you need to update it at the same interval you have specified while file creation.
For example: In our case it is 60 seconds (-s 60). Here -s is for steps,the step of 60 means that database expects new values every 60 seconds. You can define your own step value.
To update RRD file the command is:
“rrdtool update $ram_rrdfile N:$total:$used“.
where $total and $used are the values you get for the variable names total and used we have specified
in file create command respectively.
The RRD File is to be updated at the same interval as defined in the create command. So the best way to update the file is to set a Cron Job for the same which runs exactly at the same interval you have specified. Every data get stored with its time stamp so you can easily get the data of any time span.
3 : Create the Graph or Show the data in tabular report as per your requirement:
Now the final step is to make report from the data you have stored in the RRD database. There are
many ways to get the data from RRD database depending on your need, I have mentioned two ways below:
a ) Create a graph : You can directly create a graph from the data you have stored in RRD File . To plot a graph the command is :
$rrdcommand = “/usr/bin/rrdtool graph – ” .
“–imgformat PNG “.
“–font DEFAULT:7: “.
“–lazy –height=$graph_height –width=$graph_width “.
“–color CANVAS#FFFFFF “.
“–lower-limit=0 –slope-mode –vertical-label=’Total’ “.
” DEF:USED =$filename:used:AVERAGE”.
” AREA:TOTAL#FF33FF:’Total Resource’ “.
” LINE1:USAGE#0033FF:’Utilized‘ “;
b ) Get data in XML Format : To show the report in other format you can fetch the RRD database value in XML file by using rrd fetch or rrd dump command and then get the data from that file.
Use SNMP, MIB, OID’s to get the resources data.