Новое в системе Wolfram
Mathematica
9
◄
предыдущая
|
следующая
►
Новое в системе Wolfram
Mathematica
9
›
Интерактивные индикаторы
Мониторинг сетевого трафика
In[1]:=
X
$networkIn = 0; $networkOut = 0;
In[2]:=
X
networkIn[] :=(*platform-specific*) ToExpression[ Import["!netstat -ib | grep -e \"en1\" -m 1 | awk '{print $7}'", "Text"]]
In[3]:=
X
networkOut[] :=(*platform-specific*) ToExpression[ Import["!netstat -ib | grep -e \"en1\" -m 1 | awk '{print $10}'", "Text"]]
In[4]:=
X
RemoveScheduledTask[ScheduledTasks[]]; RunScheduledTask[ Block[{tmp = {networkIn[], networkOut[]}}, {inRate, outRate} = 0.5 (tmp - {$networkIn, $networkOut})/1024.;(*KB*) {$networkIn, $networkOut} = tmp], {2, 200}];
In[5]:=
X
DynamicModule[{DinRate = 780, DoutRate = 46, maxinrate = 2100, maxoutrate = 89}, Row[{AngularGauge[ Dynamic[{maxinrate = Max[maxinrate, DinRate], DinRate = Floor[DinRate + (inRate - DinRate)/100]}, UpdateInterval -> 0.02], {0, 3000}, GaugeStyle -> {Directive[Opacity[0.3], Darker@ColorData[63, 1]], ColorData[63, 1]}, GaugeLabels -> {Column[{Dynamic[DinRate, UpdateInterval -> 0.02], Dynamic[Style[maxinrate, Directive[Opacity[0.3], Darker@ColorData[63, 1]]]]}, Alignment -> Center], Placed["Receive", {0.5, 0.65}]}, ImageSize -> 251], AngularGauge[ Dynamic[{maxoutrate = Max[maxoutrate, DoutRate], DoutRate = Floor[DoutRate + (outRate - DoutRate)/100]}, UpdateInterval -> 0.02], {0, 200}, GaugeStyle -> {Directive[Opacity[0.3], Darker@ColorData[63, 2]], ColorData[63, 2]}, GaugeLabels -> {Column[{Dynamic[DoutRate], Dynamic[Style[maxoutrate, Directive[Opacity[0.3], Darker@ColorData[63, 2]]]]}, Alignment -> Center], Placed["Transmit", {0.5, 0.65}]}, ImageSize -> 251]}]]
Play Animation
»
Stop Animation
»