Categories: AsperaIBMTips

Using Lua Scripts with IBM Aspera High-Speed Transfer Server

Introduction

IBM Aspera High-Speed Transfer Server (HSTS) includes embedded support for executing Lua scripts in response to transfer events. Learn more about Lua at https://www.lua.org/.

HSTS makes information available about the transfer session and file events within a session. This allows you to record information about transfers or even automate processing against files as they arrive through your Aspera server.

Lua support supplants the now-deprecated aspera-prepost shell script option in older versions of HSTS.

Execution Events

Scripts can be executed based on five different event types during the life of a transfer:

  • Session Start
  • Session Stop
  • Session Progress
  • File Start
  • File Stop

Simple Logging Example

In this example, we will write basic information about a session into a separate text file on the HSTS host. Note that there is a function lua_log available natively that will create additional log entries in your native Aspera/ascp log. This example will create a separate simplified log outside of the Aspera logs, which would be consumed by users, other processes, or fed into another process.

We will be logging transfers that come in through one user – the “xfer” user – into a local file. Scripts can be run system-wide, or can be user-specific.

Create the Lua Script

Create a file at /home/xfer/transferdone.lua with these contents:

— transferdone.lua

file = io.open(“/home/xfer/transfer.log”, “a”)

io.output(file)

io.write(“———————————————–\n”)

io.write(“Transfer Session Complete\n”)

io.write(“Client IP Address: ” .. env_table[“peer_ip”] .. “\n”)

io.write(“Direction: ” .. env_table[“direction”] .. “\n”)

io.write(“Number of Files: ” .. env_table[“filecount”] .. “\n”)

io.write(“Total Bytes Transferred: ” .. env_table[“transfer_bytes”] .. “\n”)

io.close(file)

Update aspera.conf

We want this script to run on the Transfer Stop event, and only for the xfer user.

/opt/aspera/bin/asconfigurator -x “set_user_data;user_name,xfer;lua_session_stop_script_path,/home/xfer/transferdone.lua”

The changes will be shown within the appropriate section in the aspera.conf file.

                    <user>

                        <name>xfer</name>

                        <file_system>

                            <access>

                                <paths>

                                    <path>

                                        <absolute>/data</absolute>

                                    </path>

                                </paths>

                            </access>

                        </file_system>

                        <transfer>

                            <lua_session_stop_script_path>/home/xfer/transferdone.lua</lua_session_stop_script_path>

                        </transfer>

                    </user>

Try it out!

After running two transfer sessions, we see the new log at /home/xfer/transfer.log.

# cat /home/xfer/transfer.log

———————————————–

Transfer Session Complete

Client IP Address: 192.168.122.1

Direction: receive

Number of Files: 1

Total Bytes Transferred: 10485760

———————————————–

Transfer Session Complete

Client IP Address: 192.168.122.1

Direction: receive

Number of Files: 31

Total Bytes Transferred: 5641941

512-766-8715

PacGenesis

Recent Posts

Казино Пинко должностной веб-журнал, непраздничное гелиостат, приняться играть

Для каждого формата подготовлены предметные выборки, которые упрощают разыскание подходящих веселий. Зли всех неношеных заказчиков…

24 hours ago

Игорный дом Пинко должностной сайт, рабочее лучник, приняться бацать

ContentВознаграждение при регистрации в игорный дом - Пинко официальный сайтВербное во кабинет пользователя Пинко игорный…

1 day ago

Pinco kumarhanesinin resmi web sitesi ve ayrıca Pinco kumarhanesinin mobil versiyonu, bam online

SahiplikPinco Türkiye: En iyi PinUp slotları ve performans sağlayıcılarıPinco Online Casino Slot Makinesi Davranış KurallarıPinco…

1 day ago

Các trang web chơi game sòng bạc hàng đầu để kiếm lợi nhuận thực sự tại Hoa Kỳ năm 2024

Bài viếtTôi có muốn các quy tắc tiền thưởng để giúp bạn yêu cầu một…

2 days ago

Wolf Work on Free Enjoy in the Demo Mode & Opinion

BlogsBetter Online game to play which have a no-deposit IncentiveBonus symbolsThe brand new! Jackpot FinancingWolf…

3 days ago

Wish to Abreast of a star Position Opinion Greentube Trial Game

Posts❓ What is the Wish to On a good Jackpot RTP rates?Must i contain the…

3 days ago