Skip to content

Latest commit

 

History

History
28 lines (20 loc) · 1.14 KB

README.md

File metadata and controls

28 lines (20 loc) · 1.14 KB

Kubeshark's Public Scripts Repository

This repository contains scripts that can be used in Kubeshark's scripting system.

Kubeshark supports custom-logic scripts that use hooks and helpers to trigger actions, supported by the available integrations, and based on programmatic decisions and/or on a schedule.

Kubeshark scripting language is based on Javascript ES5.

The following script example calculates the number of packets and overall traffic processed per minute using an L4 network hook (onPacketCaptured), some helpers and a job.

var packetCount = 0;
var totalKB = 0;

function onPacketCaptured(info) {
  packetCount++;
  totalKB += info.length / 1000;
}

function logPacketCountTotalBytes() {
  console.log("Captured packet count per minute:", packetCount);
  packetCount = 0;
  console.log("Total KB captured per minute:", totalKB);
  totalKB = 0;
}

jobs.schedule("log-packet-count-total-bytes", "0 */1 * * * *", logPacketCountTotalBytes);