如何给ss bash 写一个 WEB 端查看流量的页面

前端之家收集整理的这篇文章主要介绍了如何给ss bash 写一个 WEB 端查看流量的页面前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

@H_403_0@由于刚毕业的穷大学生,和朋友合租了一台服务器开了多个端口提供 ss 服务,懒得配置 ss-panel,就使用了 ss-bash 来监控不同端口的流量,但每次都要等上服务器才能看到流量使用情况,很麻烦,于是就写了个简单的页面来提供 WEB 访问。


@H_4030@

JavaScript 版本


@H
403_0@用 crontab 定时把流量记录文件复制到 WEB 目录下,写个 JS 脚本作数据处理。


<div class="jb51code">
<pre class="brush:js;">
function successFunction(data) {
var allRows = data.split(/\r?\n|\r/);
var table = '<table class="table table-hover" style="width: 50%; margin: auto;">';
for (var singleRow = 0; singleRow < allRows.length; singleRow++) {
if (singleRow === 0) {
table += '';
table += '<tr>';
} else {
table += '<tr>';
}
var rowCells = allRows[singleRow].split(',');
for (var rowCell = 0; rowCell < rowCells.length; rowCell++) {
if (singleRow === 0) {
table += '<th class="text-right">';
table += rowCells[rowCell];
table += '';
} else {
table += '<td class="text-right">';
table += rowCells[rowCell];
table += '</td>';
}
}
if (singleRow === 0) {
table += '</tr>';
table += '';
table += '';
} else {
table += '</tr>';
}
}
table += '';
table += '</table>';
$('body').append(table);
}

@H_403_0@首页

Traffic nofollow" rel="external nofollow" rel="stylesheet"> nofollow" rel="external nofollow" rel="stylesheet">

猜你在找的JavaScript相关文章