チュートリアル-プロトコル拡張を使用した syslog メッセージのロードバランシング

Citrix ADCアプライアンスで使用可能なSyslogプロトコルは、Citrix ADCアプライアンスで生成されたメッセージに対してのみ機能します。外部ノードからのメッセージの負荷分散は行われません。このようなメッセージをロードバランシングするには、プロトコル拡張機能を使用し、Lua 5.2 プログラミング言語を使用して syslog メッセージ解析ロジックを記述する必要があります。

syslog メッセージを解析するためのコード

このコードには、TCP クライアントデータコールバック関数 (client.on_data ()) のみが定義されています。サーバーデータの場合、コールバック関数を追加せず、サーバーからクライアントへの高速ネイティブパスを取得します。このコードは、末尾の文字に基づいてメッセージの境界を識別します。TCP パケットに複数の syslog メッセージが含まれている場合は、末尾の文字に基づいてパケットを分割し、各メッセージをロードバランシングします。

--[[ Syslog event handler for TCP client data ctxt - TCP client side App processing context. data - TCP Data stream received. --]] function client.on_data(ctxt, payload) local message = nil local data_len local data = payload.data local trailing_character = "\n" ::split_message:: -- Get the offset of trailing character local new_line_character_offset = data:find(trailing_character) -- If trailing character is not found, then wait for more data. if (not new_line_character_offset) then goto need_more_data end -- Get the length of the current message data_len = data:len() -- Check whether we have more than one message -- by comparing trailing character offset and -- current data length if (data_len > new_line_character_offset) then -- If we have more than one message, then split -- the data into two parts such that first part -- will contain message upto trailing character -- offset and second part will contain -- remaining message. message, data = data:split(new_line_character_offset) else message = data data = nil end -- Send the data to the backend server. ns.send(ctxt.output, "EOM", {data = message}) goto done ::need_more_data:: -- Wait for more data ctxt:hold(data) data = nil goto done ::done:: -- If we have more data to parse, -- then do parsing again. if (data) then goto split_message end end 
チュートリアル-プロトコル拡張を使用した syslog メッセージのロードバランシング