Skip to content

Example scripts that can be used in Kubeshark's scripting system

Notifications You must be signed in to change notification settings

kubeshark/scripts

Repository files navigation

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);

About

Example scripts that can be used in Kubeshark's scripting system

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published