How to query out the switch port bandwidth usage by given start time and end time?

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
liaodalin19903
Posts: 3
Joined: Mon Jun 03, 2019 5:58 am

How to query out the switch port bandwidth usage by given start time and end time?

Post by liaodalin19903 »

I can use the below command to select a switch port's rrd path.


```
$switchName="Los-Angels-A"
$portName="Gi0/5";

$sql = "SELECT DTD.data_source_path FROM `host` AS H LEFT JOIN host_snmp_cache AS HSC ON ( HSC.host_id = H.id AND HSC.field_name = 'ifName' ) LEFT JOIN data_local AS DL ON ( DL.host_id = HSC.host_id AND HSC.snmp_index = DL.snmp_index ) LEFT JOIN data_template_data AS DTD ON ( DL.id = DTD.local_data_id ) WHERE HSC.field_value = '".$portName."' AND (H.description LIKE '".$switchName."' OR H.hostname LIKE '".$switchName."')";
```

But how can I query out the bandwidth usage by given start date time and end date time?

I mean if I give the `start time`, `end time` and `Switch port`, I can query out the bandwidth usage of the Switch's port.
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: How to query out the switch port bandwidth usage by given start time and end time?

Post by netniV »

You basicallly need to get the name of the RRD file, then use RRDtool with a UNIX timestamp version of the start/end dates.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
liaodalin19903
Posts: 3
Joined: Mon Jun 03, 2019 5:58 am

Re: How to query out the switch port bandwidth usage by given start time and end time?

Post by liaodalin19903 »

netniV wrote: Fri Oct 11, 2019 11:01 am You basicallly need to get the name of the RRD file, then use RRDtool with a UNIX timestamp version of the start/end dates.
Can you provide an example to me for explain more?

---

because the rrd file only store a moment's bandwidth speed, it do not store the usage amount. How can I get the bandwidth usage from a given time quantum?
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: How to query out the switch port bandwidth usage by given start time and end time?

Post by netniV »

Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests