Debian Codegraph @

interactive-notebook/RedHatBlog.ipynb

raw
1 {
2 "cells": [
3 {
4 "cell_type": "markdown",
5 "id": "58a08dd4-3adf-41e5-aca0-e4452aab7efd",
6 "metadata": {},
7 "source": [
8 "# ISystemTap: An interactive SystemTap notebook"
9 ]
10 },
11 {
12 "cell_type": "markdown",
13 "id": "6bcbc3b4-0557-4b43-b514-f18ae6f5653c",
14 "metadata": {},
15 "source": [
16 "## Example: Hello ISystemTap"
17 ]
18 },
19 {
20 "cell_type": "code",
21 "execution_count": null,
22 "id": "3af86008-3f08-4e47-9ff3-8068d59cde3a",
23 "metadata": {
24 "tags": []
25 },
26 "outputs": [],
27 "source": [
28 "%%edit helloworld\n",
29 "\n",
30 "global ns\n",
31 "probe begin {\n",
32 " println(\"Hello ISystemtap\")\n",
33 " ns = module_name()\n",
34 "}"
35 ]
36 },
37 {
38 "cell_type": "code",
39 "execution_count": null,
40 "id": "ca43481b-d2cb-4043-81c4-2bbd1226f21c",
41 "metadata": {
42 "tags": []
43 },
44 "outputs": [],
45 "source": [
46 "%%edit helloworld\n",
47 "\n",
48 "probe oneshot{\n",
49 " printf(\"I am the namespace %s\\n\", ns)\n",
50 "}"
51 ]
52 },
53 {
54 "cell_type": "code",
55 "execution_count": null,
56 "id": "0f32a0b7-19f3-496c-930e-f83e847c7d2f",
57 "metadata": {
58 "tags": []
59 },
60 "outputs": [],
61 "source": [
62 "%%run helloworld"
63 ]
64 },
65 {
66 "cell_type": "markdown",
67 "id": "e5d31426-617c-4047-8167-3611bafd3745",
68 "metadata": {},
69 "source": [
70 "## The power of Python"
71 ]
72 },
73 {
74 "cell_type": "code",
75 "execution_count": null,
76 "id": "29d653dc-c9d3-4d6a-8e11-1662008a5ab3",
77 "metadata": {
78 "tags": []
79 },
80 "outputs": [],
81 "source": [
82 "%%script histogram\n",
83 "global accumulator\n",
84 "global i = 0\n",
85 "\n",
86 "probe timer.ms(100){\n",
87 " printf(\"ping %d\\n\", i)\n",
88 " accumulator <<< randint(i*64+32)\n",
89 " if (i++ > 10)\n",
90 " exit()\n",
91 "}\n",
92 "\n",
93 "probe end{\n",
94 " println(\"Printing Histogram\")\n",
95 " println(@hist_log(accumulator))\n",
96 " print(\"All done\\n\")\n",
97 "}"
98 ]
99 },
100 {
101 "cell_type": "code",
102 "execution_count": null,
103 "id": "cd6c8441-c1db-4d28-8bed-a346dfc6dd49",
104 "metadata": {
105 "tags": []
106 },
107 "outputs": [],
108 "source": [
109 "%%python histogram\n",
110 "\n",
111 "print(f'{accumulator = }')\n",
112 "\n",
113 "print(f'{i = }')\n",
114 "\n",
115 "print(f'{i == accumulator[\"@count\"] = }')"
116 ]
117 }
118 ],
119 "metadata": {
120 "kernelspec": {
121 "display_name": "ISystemtap",
122 "language": "systemtap",
123 "name": "isystemtap"
124 },
125 "language_info": {
126 "codemirror_mode": "systemtap",
127 "file_extension": ".stp",
128 "mimetype": "text/x-systemtap",
129 "name": "systemtap"
130 }
131 },
132 "nbformat": 4,
133 "nbformat_minor": 5
134 }