- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
希望大家在这里一切都好。
我正在用 C#/VB.Net 编写一个 windows 服务,旨在测量本地主机上所有网站的带宽消耗 并将他们的统计数据存储在本地/远程数据库中以供上传、下载等。
目标平台仅包括 Windows Server 2003、2003 R2、2008 和 2008 R2。
我对这个东西进行了一些搜索,发现了以下内容:
请指导最合适、安全和有效的方法/技术或可用于测量每个不同网站的带宽消耗的一组此类技术。
也请分享这方面的任何代码。
问候
史蒂夫
最佳答案
我找到了一个名为 snmpsharpnet 的程序集这对于在 .NET 上使用 SNMP 非常有帮助。
根据我在this article中写的解释输入带宽使用率可以通过给定接口(interface)计算:
“In”带宽使用百分比 = (((ifInOctets(t2)-ifInOctets(t1)) * 8)*100)/(ifSpeed * (t2-t1))
这是一个示例代码。
using System;
using System.Collections.Generic;
using System.Text;
using SnmpSharpNet;
namespace Exemple2
{
class Program
{
static void Main(string[] args)
{
/* Get an SNMP Object
*/
SimpleSnmp snmpVerb = new SimpleSnmp("192.168.1.121", 161, "public");
if (!snmpVerb.Valid)
{
Console.WriteLine("Seems that IP or comunauty is not cool");
return;
}
/* Sample of simple Get usage on ifSpeed on interface 10
* TODO : for sure you have to detect the right interface
*/
Oid oidifSpeed = new Oid(".1.3.6.1.2.1.2.2.1.5.10");
/* Getting ifSpeed
*/
Dictionary<Oid, AsnType> snmpDataS = snmpVerb.Get(SnmpVersion.Ver2, new string[] { oidifSpeed.ToString() });
if (snmpDataS != null)
Console.WriteLine("Interface speed \"{0}\" : {1}", oidifSpeed.ToString(), snmpDataS[oidifSpeed].ToString());
else
Console.WriteLine("Not Glop!");
/* Sample of simple Get usage on ifInOctets on interface 10
* TODO : for sure you have to detect the right interface
*/
Oid oidifInOctets = new Oid(".1.3.6.1.2.1.2.2.1.10.10");
Dictionary<Oid, AsnType> snmpData1;
/* Getting it for the first time
*/
snmpData1 = snmpVerb.Get(SnmpVersion.Ver2, new string[] { oidifInOctets.ToString() });
if (snmpData1 != null)
Console.WriteLine("Number of In octets \"{0}\" : {1}", oidifInOctets.ToString(), snmpData1[oidifInOctets].ToString());
else
Console.WriteLine("Not Glop!");
int missed = 0;
while (true)
{
if (missed == 0)
{
/* When you detect a non refesh data, keep the last one
*/
snmpData1 = snmpVerb.Get(SnmpVersion.Ver2, new string[] { oidifInOctets.ToString() });
if (snmpData1 != null)
Console.WriteLine("Number of In octets \"{0}\" : {1}", oidifInOctets.ToString(), snmpData1[oidifInOctets].ToString());
else
Console.WriteLine("Not Glop!");
}
/* Some Wait (less aproximative)
*/
int duration = 5;
System.Threading.Thread.Sleep(duration*1000); // duration seconds
/* Getting it for the Second time
*/
Dictionary<Oid, AsnType> snmpData2 = snmpVerb.Get(SnmpVersion.Ver2, new string[] { oidifInOctets.ToString() });
if (snmpData2 != null)
Console.WriteLine("Number of In octets \"{0}\" : {1}", oidifInOctets.ToString(), snmpData2[oidifInOctets].ToString());
else
Console.WriteLine("Not Glop!");
Counter32 I1 = new Counter32();
I1.Set(snmpData1[oidifInOctets]);
Counter32 I2 = new Counter32();
I2.Set(snmpData2[oidifInOctets]);
Counter32 speed = new Counter32();
speed.Set(snmpDataS[oidifSpeed]);
if (I2.Value == I1.Value)
{
missed += 1;
continue;
}
decimal bandWithUsage = (((decimal)(I2.Value - I1.Value) * 8) * 100) / (speed * duration * (1+missed));
Console.WriteLine("BandWith usage : {0}%", bandWithUsage);
missed = 0;
}
}
}
}
这只是概念验证,现在您可能需要合并一个 BackgroundWorker 和一个计时器。
如果您不确定 SNMP 是否可以在服务器上连接并且您想要测试 SNMP 端口连接,您将需要 Microsoft PortQry .此工具确定端口是否正在监听。此工具还提供其他功能,具体取决于您使用的命令。
关于c# - 如何以编程方式使用 C#/VB.Net 以 MB 为单位测量网站带宽(上传+下载)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2948830/
USRP2 可以处理的最大带宽是多少? 最佳答案 100MS/s I & Q 下的 USRP2 A/D 样本被缩减为 25MS/s 复杂。我们使用 16 位 I & Q。 这在 USRP2 的千兆以太
使用下面的脚本来检测连接到网络的系统的互联网速度。引用javascript to detect internet speed 但是,https://fast.com/ 的速度结果和 http://ww
我需要能够使用java监视内部网络的速度。我当时想我可以使用一个包含服务器和客户端的两部分系统。我不需要响应时间(例如使用ping生成的响应时间),但不需要上载和下载时的mbps实际速度。 我的想法是
我正在使用 HttpWebRequest 调用页面并使用 HttpWebResponse 获取结果, 我的问题是如何获取或计算返回页面的总大小(以字节为单位)。此外,我还想知道我用来调用该页面的流量/
使用 Firebase,我为字段指定易于理解的名称,例如“timestamp”、“last_changed”、“message_direction”等。 字段名称是每个“行”数据交换的一部分吗? 意思
使用 Firebase,我为字段指定易于理解的名称,例如“timestamp”、“last_changed”、“message_direction”等。 字段名称是每个“行”数据交换的一部分吗? 意思
最近我接到了一项任务,要在 Nexus 7 平板电脑上开发 Android 应用程序,该应用程序将使用 wifi 通过 tcp 套接字与电脑连接。 特别是我必须将图像流(例如未压缩的 BMP)传递给平
我正在编写一个在服务器上运行的应用程序,我需要能够为每个以太网端口设置最大带宽(最多有 6 个端口)。 显然我可以限制我的应用程序使用的带宽,但我还没有找到任何关于限制计算机上实际以太网端口带宽的信息
我有一个 gRPC用 Go 编写的服务,它有很长的运行流。我想要一种方法来测量每个流的网络/带宽使用情况,并将该信息提供给 prometheus . 我找到了 grpc.StreamServerInt
我制作了一个 OpenCL 程序并使用固定内存 (CL_MEM_ALLOC_HOST_PTR) 来获得从设备到主机的更高传输速率。 传输速率按我的预期增加(使用 AMD APP Profiler 2.
有什么方法可以在 Xcode 中以编程方式检查互联网连接速度或带宽。我正在尝试这样做,因为慢速连接给某些图像上传带来了问题。 最佳答案 如果你真的需要知道,你将不得不测试它。 设置与具有低延迟的已知服
我已将大小为 876MB 的文件推送到 git lfs,这分别显示了我总共 0.9 的可用存储空间和带宽,但是,然后我做了一些更改,例如删除了旧存储库并卸载了 git lfs,因为我将图像大小从 90
关闭。这个问题需要更多focused .它目前不接受答案。 想改善这个问题吗?更新问题,使其仅关注一个问题 editing this post . 8 个月前关闭。 Improve this ques
这个问题在这里已经有了答案: How to programmatically check Internet bandwidth in VC++? (3 个答案) 关闭 8 年前。 我想在 vc++
这让我发疯,所以我想看看是否有人能给我一个线索。我有一个小型 VPS,运行 Centos 5、最新的 Apache、MySQL 和 PHP。 大约 1% 的用户报告页面加载速度非常慢,即使对于静态 H
在 Win32 中有没有什么方法可以在不实际传输任何数据的情况下以编程方式确定给定网络接口(interface)的带宽?我只想区分不同类型的接口(interface)(例如拨号 vs DSL vs L
我了解延迟 - 消息从发件人到收件人所需的时间 - 和带宽 - 在给定时间内可以传输的最大数据量 - 但我正在努力寻找合适的术语来描述相关事物: 如果协议(protocol)是基于对话的——负载在端点
我试图找到内存泄漏,我已将其归零到这部分代码,但我找不到内存泄漏的位置或如何修复它,当我让一些人调查时他们建议它与此处提到的“代码”有关: https://golang.org/src/time/ti
我正在使用 WCF 编写客户端和服务器代码,我需要知道客户端和服务器之间的“感知”流量带宽。我可以使用 ping 统计信息单独收集此信息,但我想知道是否有一种方法可以在 WCF 中配置 channel
我知道可以在对等连接上使用“setParameter”来限制上传(发送)带宽。我正在寻找一种方法来限制下载(已接收)但找不到。(我没有控制权 我错过了这个概念吗?或者有办法做到这一点? 谢谢 最佳答案
我是一名优秀的程序员,十分优秀!