⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uptime.pl

📁 ns 2.28 下 SPAN节能协议源码
💻 PL
字号:
#!/usr/bin/perlstrict;$first = 21;$stop = 500;@sleep_time;@idle_time;@last_action;@last_idle;for (my $i=0; $i<120; $i++) {  $sleep_time[$i] = 0;  $idle_time[$i] = 0;  $last_action[$i] = 0;  $last_idle[$i] = 0;}while (<>) {  if ($_ =~ /^v ([\d.]+) _(\d+)_/) {    $idle_time[$2] += ($1-$last_action[$2]);    $last_action[$2] = $1;    $last_idle[$2] = 1;    if ($1 > $stop) { print $_; last; }  }  elsif ($_ =~ /^~ ([\d.]+) _(\d+)_/) {    $idle_time[$2] += ($1-$last_action[$2]);    $last_action[$2] = $1;    $last_idle[$2] = 0;    if ($1 > $stop) { print $_; last; }  }  elsif ($_ =~ /^- ([\d.]+) _(\d+)_/) {    $sleep_time[$2] += ($1-$last_action[$2]);    $last_action[$2] = $1;    $last_idle[$2] = 1;    if ($1 > $stop) { print $_; last; }  }}my $n = 0;my $total_sleep = 0;my $total_idle = 0;for($i=$first; $i<=120; $i++) {  if ($last_action[$i] > 0) {    $n++;    if ($last_idle[$2]) {      $idle_time[$i] += ($stop-$last_action[$i]);    } else {      $sleep_time[$i] += ($stop-$last_action[$i]);    }    $total_sleep += $sleep_time[$i];    $total_idle += $idle_time[$i];  }}printf("avg sleep time: %3.3f\n", $total_sleep/$n);printf("avg idle  time: %3.3f\n", $total_idle/$n);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -