
ntop ntopngユーザースクリプト インターフェイススループット
現在まで、ntop社のntopngユーザースクリプトを2個紹介してきました。
基本やり方は一緒ですので、説明とデバック方法は省いて、今回のユーザースクリプトの紹介をします。
インターフェイスのスループットアラートです。

設定では、一分ごとにインターフェースのスループットをチェックして、100Mbpsを超えている場合アラートを発報します。
/usr/share/ntopng/scripts/plugins/threshold_cross/user_scripts/interface/throughput.luaが、スクリプト本体です。
Mbpsの計算にバグがあったので、修正しております。
修正したluaスクリプトは、以下のとおりです。
--
-- (C) 2019-20 - ntop.org
--
local alerts_api = require("alerts_api")
local alert_consts = require("alert_consts")
local user_scripts = require("user_scripts")
local script = {
-- Script category
category = user_scripts.script_categories.network,
default_enabled = false,
-- This script is only for alerts generation
is_alert = true,
-- See below
hooks = {},
gui = {
i18n_title = "alerts_thresholds_config.throughput",
i18n_description = "alerts_thresholds_config.alert_throughput_description",
i18n_field_unit = user_scripts.field_units.mbits,
input_builder = "threshold_cross",
}
}
-- #################################################################
function script.hooks.all(params)
local value = alerts_api.interface_delta_val(script.key, params.granularity, params.entity_info["stats"]["bytes"]) * 8 / 1024 / 1024 / alert_consts.granularity2sec(params.granularity)
-- Check if the configured threshold is crossed by the value and possibly trigger an alert
alerts_api.checkThresholdAlert(params, alert_consts.alert_types.alert_threshold_cross, value)
end
-- #################################################################
return script
追加したのは、/ 1024 / 1024 の部分です。こちらで、Mbpsにしております。
今回は、ntopngでiperf3サーバーを起動し、Windows側でクライアントを実行し、200Mbps帯域を占有するように実行しました。


iperf3クライアント実行後、1分間隔のチェックにあたれば図4のアラートが表示されます。

200Mbpsになっていますね。修正したluaはここでデバックできます。
このインターフェイススループットアラートは、監視対象ポートのミラーポートをntopngに接続している場合、トラフィック過負荷を監視し、異常時に素早いアクションを起こすことに使えるユーザースクリプトですね。
最新記事 by 伊集院 (全て見る)
- 【暗号化通信(TLS)を復元できる】WIRESHARK達人への道 第二十五歩 暗号化通信(TLS)を復号する方法 - 1月 1, 2023
- 【詳細版】NSM(ネットワークセキュリティモニタ)、Zeekとは? - 9月 1, 2022
- 【簡易版】OSSネットワークセキュリティモニタZeekとは? - 8月 26, 2022