blob: 90e69e3b3ec613ab437cd535c578d0b6a3e66f9b [file]
{
"cells": [
{
"cell_type": "markdown",
"id": "58a08dd4-3adf-41e5-aca0-e4452aab7efd",
"metadata": {},
"source": [
"# ISystemTap: An interactive SystemTap notebook"
]
},
{
"cell_type": "markdown",
"id": "6bcbc3b4-0557-4b43-b514-f18ae6f5653c",
"metadata": {},
"source": [
"## Example: Hello ISystemTap"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3af86008-3f08-4e47-9ff3-8068d59cde3a",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"%%edit helloworld\n",
"\n",
"global ns\n",
"probe begin {\n",
" println(\"Hello ISystemtap\")\n",
" ns = module_name()\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ca43481b-d2cb-4043-81c4-2bbd1226f21c",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"%%edit helloworld\n",
"\n",
"probe oneshot{\n",
" printf(\"I am the namespace %s\\n\", ns)\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0f32a0b7-19f3-496c-930e-f83e847c7d2f",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"%%run helloworld"
]
},
{
"cell_type": "markdown",
"id": "e5d31426-617c-4047-8167-3611bafd3745",
"metadata": {},
"source": [
"## The power of Python"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "29d653dc-c9d3-4d6a-8e11-1662008a5ab3",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"%%script histogram\n",
"global accumulator\n",
"global i = 0\n",
"\n",
"probe timer.ms(100){\n",
" printf(\"ping %d\\n\", i)\n",
" accumulator <<< randint(i*64+32)\n",
" if (i++ > 10)\n",
" exit()\n",
"}\n",
"\n",
"probe end{\n",
" println(\"Printing Histogram\")\n",
" println(@hist_log(accumulator))\n",
" print(\"All done\\n\")\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cd6c8441-c1db-4d28-8bed-a346dfc6dd49",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"%%python histogram\n",
"\n",
"print(f'{accumulator = }')\n",
"\n",
"print(f'{i = }')\n",
"\n",
"print(f'{i == accumulator[\"@count\"] = }')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "ISystemtap",
"language": "systemtap",
"name": "isystemtap"
},
"language_info": {
"codemirror_mode": "systemtap",
"file_extension": ".stp",
"mimetype": "text/x-systemtap",
"name": "systemtap"
}
},
"nbformat": 4,
"nbformat_minor": 5
}