Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- VMware Technology Network
- :
- SDDC
- :
- Automation
- :
- VMware PowerCLI Discussions
- :
- How to get a total network transmit and receive in...

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

hakhak

Contributor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-08-2012
06:26 AM

How to get a total network transmit and receive in 7 days?

3 Replies

LucD

Leadership

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-08-2012
05:11 PM

Afaik, there is no direct metric that gives you those numbers over the last 7 days (Historical Interval 2).

Also remember that the metrics are aggregated for the Historical Intervals.

See my PowerCLI & vSphere statistics – Part 1 – The basics post for more details on this.

If you ask for metric values over the last 7 days, you could use the **net.bytesRx.average** and **net.bytesTx.average**.

This will give you the average number of bytes transmitted and received during the interval.

If you multiply the average number of bytes (KBps) by the number of seconds in the interval you should get a decent approximation of the absolute values you are after.

Something like this

Get-VM | Get-Stat -Stat "net.bytesRx.average","net.bytesTx.average" -Start (Get-Date).AddDays(-7) | Group-Object -Property {$_.Entity.Name} | Select @{N="VM";E={$_.Name}}, @{N="Received (KB)";E={ ($_.Group | where {$_.MetricId -eq "net.bytesRx.average"} | %{$_.Value * $_.IntervalSecs} | Measure-Object -Sum).Sum}}, @{N="Transmitted (KB)";E={ ($_.Group | where {$_.MetricId -eq "net.bytesTx.average"} | %{$_.Value * $_.IntervalSecs} | Measure-Object -Sum).Sum}}

Note that this script will summarise traffic for all vNICs that a VM has.

The script also requires at least statistics level 2 for Historical Interval 2.

Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference

hakhak

Contributor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-08-2012
06:31 PM

hi LucD,

alright, thanks for the script. By the way, I have another question, how about virtual disk? how can i get total write and read in 7 days? I can only get the average instead of total. Apperciate that you may help on this.

LucD

Leadership

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-09-2012
02:54 AM

You could use the same concept, but with the **virtualdisk.read.average** and **virtualdisk.write.average** metrics.

Get-VM | Get-Stat -Stat "virtualdisk.read.average","virtualdisk.write.average" -Start (Get-Date).AddDays(-7) | Group-Object -Property {$_.Entity.Name} | Select @{N="VM";E={$_.Name}}, @{N="Read (KB)";E={ ($_.Group | where {$_.MetricId -eq "virtualdisk.read.average"} | %{$_.Value * $_.IntervalSecs} | Measure-Object -Sum).Sum}}, @{N="Write (KB)";E={ ($_.Group | where {$_.MetricId -eq "virtualdisk.write.average"} | %{$_.Value * $_.IntervalSecs} | Measure-Object -Sum).Sum}}

The script summarises all the virtual disks per VM.

Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference