1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056
|
SYSTEMTAP EXAMPLES INDEX
(see also keyword-index.txt)
For systemtap version 4.0.
apps/gmalloc_watch.stp - Tracing glib2 memory allocations
keywords: trace
The gmalloc_watch.stp script from Colin Walters' blog
(https://blog.verbum.org/2011/03/19/analyzing-memory-use-with-systemt
ap/) traces the allocation of glib2 memory using the markers in
glib2.
# stap gmalloc_watch.stp -T 1
apps/libguestfs_log.stp - Trace libguestfs startup
keywords: application trace
The libguestfs_log.stp script prints a log of when various
libgueststartup steps are encountered. The first column is
microseconds since the script started. The second column is the time
elapsed in microseconds between the previous and current events and
the third column is the event name.
# stap libguestfs_log.stp -T 1
apps/php-trace.stp - Tracing of PHP code execution
keywords: trace
Trace of executing PHP code using the enabled markers.
# stap php-trace.stp -c 'php -f hello.php'
apps/stap_time.stp - Provide elapsed times for Passes of SystemTap script compilation
keywords: application trace
SystemTap has multiple passes to convert the text of a SystemTap
script into instrumentation that actually collect data on the system.
The stap_time.stp script uses the markers in SystemTap to note the
amount of time that each of the passes requires. When SystemTap
completes pass 4 (compiling the instrumentation into a kernel module)
the script print out the script name followed by the amount of time
in milliseconds required for Pass 0 (command line option parsing),
Pass 1 (script parsing), Pass 2 (elaboration), Pass 3 (code
generation), and Pass 4 (module compilation). The resulting data can
be analyzed to determine if there are issues with the amount of time
that systemtap takes to generate instrumentation.
# stap stap_time.stp -T 1
general/alias_suffixes.stp - Count I/O Syscalls using Alias Suffixes
keywords: io statistics
alias_suffixes.stp is a demonstration of how alias suffixes in the
systemtap language might be used. The script tracks the wall clock
time for each invocation of the system calls open, close, read, and
write. When the script exists it prints out the minimum, average, and
maximum times in microseconds for each system call, followed by a
count of times that each syscall was invoked and a histogram showing
the distributions of times.
# stap alias_suffixes.stp -T 1
general/also_ran.stp - Keep a tally of executables run on the system
keywords: prometheus
The also_ran.stp script tallies each time a executable is started or
a shared library is loaded for execution. This information can be
useful to determine what software is actually being used on the
system. The script makes the information available via procfs in
Prometheus readable format.
# stap also_ran.stp -T 1
general/ansi_colors.stp - Color Table for ansi_set_color()
keywords: format
The script prints a table showing the available color combinations
for the ansi_set_color() function in the ansi.stp tapset.
# stap ansi_colors.stp
general/ansi_colors2.stp - Show Attribues in Table for ansi_set_color()
keywords: format
The script prints a table showing the available attributes (bold,
underline, and inverse) with color combinations for the
ans_set_color() function in the ansi.stp tapset.
# stap ansi_colors2.stp
general/badname.stp - Bad Filename Filter
keywords: filesystem guru
The badname.stp script shows how one could prevent the creation of
files with undesirable names using guru mode.
# stap -g badname.stp -c "touch /tmp/myXXXbadnameXXXfile.$$ 2>&1 | grep \
denied"
general/callgraph.stp - Callgraph Tracing
keywords: simple trace callgraph
Print a timed per-thread microsecond-timed nested callgraph. The
first parameter names the function probe points to trace.
# stap callgraph.stp 'kernel.function("*@fs/proc*.c")' -c "cat \
/proc/sys/vm/* || true"
general/cpu_throttle.stp - Monitor Intel processors for throttling due to power or thermal limits
keywords: prometheus limits
Intel processors have hardware mechanisms that will reduce the
effective processors speed to avoid exceeding set thermal or power
constraints. The cpu_throttle.stp script monitors when CPU throttling
occurs and accumulates the amount of time in milliseconds that each
processor is throttled. The script makes the information available
via procfs in Prometheus readable format.
# stap cpu_throttle.stp -T 1
general/eventcount.stp - Interactive Count Specified Events
keywords: interactive statistics thread process
The script periodically prints a count of specified events and their
related tid's over the course of execution. Numerous configuration
options exist to control filtering / reporting, some of which can be
modified at runtime. See the script source for more information.
# stap eventcount.stp 'syscall_any' -c 'sleep 3'
general/func_time_stats.stp - Function Time Statistics
keywords: function statistics
The func_time_stats.stp script tracks the wall clock time for each
invocation of the function probe listed as the first command line
argument. When the script exits it prints out the minimum, average,
and maximum times in microseconds followed by a count of times that
the function was called and a histogram showing the distributions of
times.
# stap func_time_stats.stp 'syscall.read' -T 1
general/graphs.stp - Graphing Disk and CPU Utilization with gnuplot
keywords: monitoring
The script tracks the disk and CPU utilization. It prints a stream
of data which, when piped directly into gnuplot, draws historical
curves for each.
# stap graphs.stp -T 1
general/helloworld.stp - SystemTap "Hello World" Program
keywords: _best simple
A basic "Hello World" program implemented in SystemTap script. It
prints out "hello world" message and then immediately exits.
# stap helloworld.stp
general/key.stp - make keyboard noises
keywords: simple
For fans of Leroy Anderson and Typewriters only, this script arranges
to play a click or a zing for various keystrokes.
# stap key.stp -c 'sleep 5'
general/keyhack.stp - Hack the keyboard
keywords: simple guru
This script makes it appear that one's keyboard is broken, by
changing keycodes at the kernel device driver level. Annoy your
friends!
# stap -g keyhack.stp -c 'sleep 5'
general/measureinterval.stp - Measure intervals between events
keywords: monitoring
The measureinteval.stp script allows quick creation of
instrumentation to measure quantity between different probe points,
aggregate the measurements, and display the results. The first
argument to the script is the quantity to measure such as time in
microseconds via "gettimeofday_us()". There could be multiple
intervals being measured concurrently and the second argument is the
means to match the start probe points listed in the fourth argument
with the end probes listed in the fifth argument. The third argument
is how to display the aggregated data. The data could be displayed
as a sum (@sum), an average (@avg), or a histogram (@hist_log). The
fourth and fifth arguments are lists of probes marking the start and
end of an interval. An optional sixth argument allows grouping of
the intervals. One could use "tid()" for the matching argument to
measure the intervals on a per-thread basis, but then use
"execname()" for the optional argument to group the measurements by
executable name. If there is no sixth argument, all the intervals
are aggregated into a single entry.
# stap measureinterval.stp "gettimeofday_us()" "tid()" @sum vm.pagefault \
vm.pagefault.return "execname()" -c 'sleep 3'
general/para-callgraph-verbose.stp - Callgraph Tracing with Verbose Arguments
keywords: trace callgraph
Print a timed per-thread microsecond-timed callgraph, complete with
pretty-printed function parameters and return values. The first
parameter names the function probe points to trace. The optional
second parameter names the probe points for trigger functions, which
acts to enable tracing for only those functions that occur while the
current thread is nested within the trigger.
# stap para-callgraph-verbose.stp 'kernel.function("*@fs/proc*.c")' \
'kernel.function("vfs_read")' -c "cat /proc/sys/vm/* || true"
general/para-callgraph.stp - Callgraph Tracing with Arguments
keywords: _best trace callgraph
Print a timed per-thread microsecond-timed callgraph, complete with
function parameters and return values. The first parameter names the
function probe points to trace. The optional second parameter names
the probe points for trigger functions, which acts to enable tracing
for only those functions that occur while the current thread is
nested within the trigger.
# stap para-callgraph.stp 'kernel.function("*@fs/proc*.c")' \
'kernel.function("vfs_read")' -c "cat /proc/sys/vm/* || true"
general/py2example.stp - SystemTap python 2 support tapset
keywords: simple
A python support tapset that displays backtraces and variable values
# stap -I tapset -c '/usr/bin/python2 pyexample.py 35' py2example.stp
general/py3example.stp - SystemTap python 3 support tapset
keywords: simple
A python support tapset that displays backtraces and variable values
# stap -g --suppress-time-limits -I tapset -c '/usr/bin/python3 \
pyexample.py 35' py3example.stp
general/regex.stp - Report opened files whose names match a given regex
keywords: regex
Uses the regex functionality to detect opened files whose names match
a pattern given on the command line. If no command line parameter is
given, demonstrate by filtering for files that end with an extension
showing them to be an archive.
# stap regex.stp -T 1
general/sizeof.stp - Print the Size of a C Type
keywords: statistics memory
This script prints the size of a type, based on dwarf debuginfo for
any kernel or userspace module, or trial-compilation of a given
header file name.
# stap sizeof.stp FILE '</usr/include/stdio.h>'
general/sizeof_interactive.stp - Interactive Print the Size of a C Type
keywords: statistics memory interactive
This script prints the size of a type, based on dwarf debuginfo for
any kernel or userspace module, or trial-compilation of a given
header file name. Types and corresponding locations are provided to
the script at runtime via keyboard input. The format of the input is
identical to that of sizeof.stp (see script source for more
information). Types and locations can be repeatedly given until the
process is terminated.
# echo "FILE '</usr/include/stdio.h>'" | stap sizeof_interactive.stp -T 1
general/socket-events.stp - Trace Socket Activity of a Process
keywords: socket syscall
Prints the life cycle of all sockets associated with a process. This
includes bytes and timing. The timing information that is tracked
includes event completion relative to the start of said event and the
end of the previous event. Currently tracks read, write, recv, send,
connect and close.
# stap socket-events.stp
general/stopwatches.stp - See the amount of wall clock time a process spends in various states
keywords: time
The stopwatch.stp script illustrates how to use multiple stopwatches
record how much wallclock time a process spends in kernel- and
user-space. On exit the script prints out the time in seconds,
milliseconds, microseconds, and nanoseconds. Note that this output of
this script is not directly comparable to the time command because
time records the time that the process is actually active in kernel-
and user-space.
# stap stopwatches.stp -T 1
general/tcl-funtop.stp - Profile Tcl calls
keywords: profiling
The tcl-funtop.stp script displays a top-like view of most frequently
used Tcl functions for the each five second interval.
# stap tcl-funtop.stp -T 5
general/tcl-trace.stp - Callgraph Tracing of Tcl code
keywords: callgraph
Print a timed per-thread microsecond-timed callgraph of executing Tcl
code.
# stap tcl-trace.stp -T 5
general/varwatch.stp - Watch a Variable Changing Value in a Thread
keywords: _best monitoring
This script places a set of probes (specified by $1), each of which
monitors the state of some context $variable expression (specified by
$2). Whenever the value changes, with respect to the active thread,
the event is traced.
# stap -w varwatch.stp 'kernel.statement("do_sys_open@fs/open.c:*")' \
'$$vars' -T 1
general/watchdog.stp - Watchdog Timer for Arbitrary Events
keywords: watchdog backtrace
The watchdog.stp script provides a watchdog timer mechanism for
arbitrary events. The script takes three arguments: the events to
start watchdog timer, the event to stop the watchdog timer, and the
time in millseconds for the watchdog. If the watchdog timer is
exceed, the script will trigger a stack backtrace of the user-process
that timed out using pstack. This script can be used to diagnose what
the userspace application is doing when a slower than expected
operation occurs.
# stap watchdog.stp 'syscall.nanosleep' 'syscall.nanosleep.return' 1000 \
-T 1
general/whythefail.stp - Why did the function fail?
keywords: speculation monitoring function trace _best
The whythefail.stp script prints a statement-execution trace for a
given function, but only for those runs of the function that ended up
with a (configurable) post-return condition.
# stap whythefail.stp kernel do_sys_open '$return < 0' -c 'cat \
/root/no-such-file || true'
interrupt/interrupts-by-dev.stp - Record Interrupts on a Per-Device Basis
keywords: interrupt
The interrupts-by-dev.stp script profiles interrupts received by each
device per 100 ms.
# stap interrupts-by-dev.stp -T 1
interrupt/scf.stp - Tally Backtraces for Inter-Processor Interrupt
keywords: interrupt backtrace
The Linux kernel function smp_call_function causes expensive
inter-processor interrupts (IPIs). The scf.stp script tallies the
processes and backtraces causing the interprocessor interrupts to
identify the cause of the expensive IPI. On exit the script prints
the tallies in descending frequency.
# stap scf.stp -T 1
io/capture_ssl_master_secrets.stp - Capture SSL/TLS master secrets from gnutls and openssl users
keywords: io monitoring
Capture SSL/TLS master secrets from gnutls and openssl users for easy
traffic decryption
# stap capture_ssl_master_secrets.stp -c 'sleep 3'
io/deviceseeks.stp - Histograms of Seek Behavior for Each Device
keywords: disk
The deviceseeks.stp script generates a periodic histogram showing the
frequency of different sized seeks (in sectors) on each device, or
optional given device-name regexp
# stap deviceseeks.stp -T 1 sda
io/disktop.stp - Summarize Disk Read/Write Traffic
keywords: disk
Get the status of reading/writing disk every 5 seconds, output top
ten entries during that period.
# stap disktop.stp -T 1
io/eatmydata.stp - disable fsync
keywords: io guru simple
Suppresses fsync() syscalls from processes identified by stap -c/-x
by turning them into presumed-faster fsync() on some dummy or other
file descriptor
# stap -g eatmydata.stp -c 'strace ls || true'
io/enospc.stp - Report an disk out-of-space condition.
keywords: disk filesystem
This script monitors a filesystem implementations for early internal
indications of ENOSPC, and reports these to the system logger and the
systemtap console.
# stap enospc.stp -T 1
io/inodewatch.stp - Monitoring Reads and Writes to a File
keywords: io
The inodewatch.stp outputs the executable name and process id each
time a read or write occurs to the specified inode on the specified
major/minor device.
# stap inodewatch.stp 0x08 0x01 100 -T 1
io/inodewatch2.stp - Monitoring Attribute Changes to a File
keywords: io
The inodewatch2.stp script outputs the executable name, process id,
and attributes each time the attributes are changed on the specified
inode on the specified major/minor device.
# stap inodewatch2.stp 0x08 0x01 100 -T 1
io/io_submit.stp - Tally Reschedule Reason During AIO io_submit Call
keywords: io backtrace
When a reschedule occurs during an AIO io_submit call, accumulate the
traceback in a histogram. When the script exits prints out a sorted
list from most common to least common backtrace.
# stap io_submit.stp -T 1
io/ioblktime.stp - Average Time Block IO Requests Spend in Queue
keywords: io
The ioblktime.stp script tracks the amount of time that each block IO
requests spend waiting for completion. The script computes the
average waiting time for block IO per device and prints list every 10
seconds. In some cases there can be too many outstanding block IO
operations and the script may exceed the default number of
MAXMAPENTRIES allowed. In this case the allowed number can be
increased with "-DMAXMAPENTRIES=10000" option on the stap command
line.
# stap ioblktime.stp -T 1
io/iodevstats.stp - List Executables Reading and Writing the Most Data by Device
keywords: io profiling
The iodevstats.stp script measures the amount of data successfully
read and written by all the executables for each io device on the
system. The output is sorted from greatest sum of bytes read and
written to a device by an executable to the least. The output
contains device major/minor number, the count of operations (reads
and writes), the totals and averages for the number of bytes read and
written.
# stap iodevstats.stp -T 1
io/iostat-scsi.stp - IO Statistics for SCSI Devices
keywords: io profiling scsi
The iostat-scsi.stp script provides a breakdown of the number of blks
read and written on the machine's various SCSI devices. The script
takes one argument which is the number of seconds between reports.
# stap -g iostat-scsi.stp 1 -T 1
io/iostats.stp - List Executables Reading and Writing the Most Data
keywords: io profiling
The iostat.stp script measures the amount of data successfully read
and written by all the executables on the system. The output is
sorted from most greatest sum of bytes read and written by an
executable to the least. The output contains the count of operations
(opens, reads, and writes), the totals and averages for the number of
bytes read and written.
# stap iostats.stp -T 1
io/iotime.stp - Trace Time Spent in Read and Write for Files
keywords: profiling syscall io file
The script watches each open, close, read, and write syscalls on the
system. For each file the scripts observes opened it accumulates the
amount of wall clock time spent in read and write operations and the
number of bytes read and written. When a file is closed the script
prints out a pair of lines for the file. Both lines begin with a
timestamp in microseconds, the PID number, and the executable name in
parentheses. The first line with the "access" keyword lists the file
name, the attempted number of bytes for the read and write
operations. The second line with the "iotime" keyword list the file
name and the number of microseconds accumulated in the read and write
syscalls.
# stap iotime.stp -T 1
io/iotop.stp - Periodically Print IO Activity by Process Name
keywords: io
Every five seconds print out the top ten executables generating I/O
traffic during that interval sorted in descending order.
# stap iotop.stp -T 1
io/mbrwatch.stp - Monitor Read/Write of the Boot Sector Area of Block Devices
keywords: io monitoring disk simple
The mbrwatch.stp script reports any attempted reads/writes of the
first few sectors of a raw block device.
# stap mbrwatch.stp -c "dd of=/dev/null count=1 if=/dev/`grep -v major \
/proc/partitions | grep . | grep -v 'sr[0-9]' | awk '{print $4}' | \
head -1`"
io/nfs_func_users.stp - Tally the Number of NFS Functions Used by Each Process
keywords: io profiling
The nfs_func_users.stp script counts the uses of NFS functions in the
kernel on a per process bases. The output is sorted from the process
with the greatest number of NFS functions called to the least. The
output contains the executable name, the process number, and the
total number of NFS functions called by the process.
# stap nfs_func_users.stp -T 1
io/slowvfs.stp - Trace slow vfs opens.
keywords: io simple
This script prints a line for every kernel vfs_open operation that
takes longer than a configurable number of microseconds. Highly
contended or remote filesystems are likelier to hit this.
# stap slowvfs.stp -G sloth=10 -c 'find /proc >/dev/null || true'
io/switchfile.stp - Switch log files
keywords: io
Every second print a log message and switch log files every 5
seconds.
# stap -o /tmp/switchfile.stp.out switchfile.stp -T 8
io/traceio.stp - Track Cumulative IO Activity by Process Name
keywords: io
Every second print out the top ten executables sorted in descending
order based on cumulative I/O traffic observed.
# stap traceio.stp -T 1
io/traceio2.stp - Watch IO Activity on a Particular Device
keywords: io
Print out the executable name and process number as reads and writes
to the specified device occur.
# stap traceio2.stp 0x0801 -T 1
io/ttyspy.stp - Monitor TTY Typing
keywords: io tty monitoring guru
The ttyspy.stp script uses tty_audit hooks to monitor recent typing
activity on the system, printing a scrolling record of recent
keystrokes, on a per-tty basis.
# stap --skip-badvars -g ttyspy.stp -T 1
locks/bkl.stp - Tracing Contention on Big Kernel Lock
keywords: locking
The bkl.stp script can help determine whether the Big Kernel Lock
(BKL) is causing serialization on a multiprocessor system due to
excessive contention of the BKL. The bkl.stp script takes two
arguments. The first one is optional, and used to enable backtraces,
and print them once a process has been holding the BKL for a user
specified number of nseconds is reached. The second option is
compulsory and is the number of processes waiting for the Big Kernel
Lock (BKL). When the number of processes waiting for the BKL is
reached or exceeded, the script will print a time stamp, the number
of processes waiting for the BKL, the holder of the BKL, and the
amount of time the BKL was held. If backtraces are enabled, a
backtrace will be printed as well.
# stap bkl.stp -T 1 1
locks/bkl_stats.stp - Per Process Statistics on Big Kernel Lock Use
keywords: locking
The bkl_stats.stp script can indicate which processes have excessive
waits for the Big Kernel Lock (BKL) and which processes are taking
the BKL for long periods of time. The bkl_stats.stp script prints
lists of all the processes that require the BKL. Every five seconds
two tables are printed out. The first table lists the processes that
waited for the BKL followed by the number of times that the process
waited, the minimum time of the wait, the average and the maximum
time waited. The second table lists has similar information for the
time spent in holding the lock for each of the processes.
# stap bkl_stats.stp -T 1
lwtools/accept2close-nd.stp - Show socket lifespan, from accept() to close() (non-debuginfo)
keywords: network socket
This traces socket duration from the accept() syscall to close(), and
provides details on the lifespan of these passive connections,
showing the distribution as a histogram.
# stap accept2close-nd.stp -T 1
lwtools/biolatency-nd.stp - Measure block I/O latency distribution (non-debuginfo)
keywords: io
This measures block I/O latency (storage I/O, ie, disk I/O), and
shows the distribution as a histogram. This can be useful to identify
the characteristics of I/O latency, beyond the averages shown by
iostat(1). For example, to study I/O latency outliers, or multi-modal
distributions.
# stap biolatency-nd.stp 1 1
lwtools/bitesize-nd.stp - Measure block I/O size distribution (non-debuginfo)
keywords: io
This uses the kernel tracepoint block_rq_insert to read the size of
I/O. The output includes the name of the process or thread that was
on-CPU when the I/O request was inserted on the issue queue.
# stap bitesize-nd.stp -T 1
lwtools/execsnoop-nd.stp - Trace process exec() with command line argument details (non-debuginfo)
keywords: io
This can identify if CPU is consumed by short-lived processes, by
tracing new process execution. It works by tracing exec() from the
fork()->exec() sequence, which means it will not catch new processes
that only fork(). It will also show every exec(), including those if
a process re-execs.
# stap execsnoop-nd.stp -T 1
lwtools/fslatency-nd.stp - Measure the distribution of file system synchronous read and write latency (non-debuginfo)
keywords: io filesystem
This dynamically traces two common file system functions:
do_sync_read() and do_sync_write(), and reports a histogram
distribution of latency. Many, but not all, file systems and
workloads use these functions. Tracing their time provides one view
of suffered file system latency.
# stap fslatency-nd.stp 1 1
lwtools/fsslower-nd.stp - Trace slow file system synchronous reads and writes (non-debuginfo)
keywords: io filesystem
This dynamically traces two common file system functions:
do_sync_read() and do_sync_write(), and shows details of each call
that is slower than a threshold. Many, but not all, file systems and
workloads use these functions. Tracing their time provides one view
of suffered file system latency.
# stap fsslower-nd.stp -T 1
lwtools/killsnoop-nd.stp - Trace kill() signals showing process and signal details (non-debuginfo)
keywords: io
This traces signals system-wide, including those sent by the kill(1)
command, and shows various details.
# stap killsnoop-nd.stp -T 1
lwtools/opensnoop-nd.stp - Trace open() syscalls showing filenames (non-debuginfo)
keywords: io
This traces the open() syscall system-wide, to show which files are
being opened, and by who.
# stap opensnoop-nd.stp -T 1
lwtools/rwtime-nd.stp - Summarize read() and write() syscall latency (non-debuginfo)
keywords: io
This traces read() and write() syscalls, producing a histogram
summary of their durations (aka latencies).
# stap rwtime-nd.stp -T 1
lwtools/syscallbypid-nd.stp - Count syscalls with process details (non-debuginfo)
keywords: io
This traces syscalls system-wide, and produces a summary report
showing their counts by process ID, process name, and syscall types.
# stap syscallbypid-nd.stp -T 1
memory/glibc-malloc.stp - Overview glibc malloc internal operations
keywords: memory process
This script reports on internal statistics of the glibc malloc
implementation, as used by a process restricted by stap -x/-c
# stap glibc-malloc.stp -c 'stap --dump-functions'
memory/hugepage_clear_delays.stp - Summarize the time each process spends clearing huge pages
keywords: memory
When a huge page is initially used by a process it must be cleared of
its original contents to avoid leaking information between processes.
On x86_64 machines the huge pages are 2MB in size, 512 times larger
than a normal 4KB page. Thus, clearing a huge page can delay program
execution by a hundred or more microseconds and maybe noticeable to
latency sensitive programs. This script will tally the number of
times that each process triggers a huge page clear, the total time in
microseconds spent clearing the pages, and the average time in
microseconds of the huge page clear.
# stap hugepage_clear_delays.stp -T 1
memory/hugepage_collapse.stp - Log the kernel collapsing normal pages into a huge page
keywords: memory
The kernel may attempt to group many normal sized pages into a single
huge page to improve TLB performance. This operation may take a
significant amount of time and affect program performance. You can
identify if huge page collapse operations are occurring with the
systemtap hugepage_collapse.stp script.
# stap hugepage_collapse.stp -T 1
memory/hugepage_cow_delays.stp - Summarize the time each process spends doing copy on write for huge pages
keywords: memory
The system may attempt to reduce memory use by having two or more
difference processes share the same writeable page in memory.
However, when one of the processes write to shared page that is
marked copy on write (COW) the page must be duplicated and then
modified. On x86_64 machines the huge pages are 2MB in size, 512
times larger than a normal 4KB page. Thus, copy on write operation
on a huge page can delay program execution by a hundred or more
microseconds and maybe noticeable to latency sensitive programs.
This script will tally the number of times that each process triggers
a huge page copy on write, the total time in microseconds spent
copying the pages, and the average time in microseconds of the huge
page copy.
# stap hugepage_cow_delays.stp -T 1
memory/hugepage_split.stp - Log the kernel splitting huge pages into normal sized pages
keywords: memory
Because some portions of the kernel code only work with normal-sized
pages the kernel may convert a huge page into a set of normal-sized
pages using a split operation. This operation may be relatively
expensive and noticeable to latency sensitive programs. You can
identify if split operations are occurring with the systemtap
hugepage_split.stp script.
# stap hugepage_split.stp -T 1
memory/hw_watch_addr.stp - Watch a Kernel Address Using Breakpoint Hardware
keywords: memory watchpoint
The script will watch accesses to a single kernel address and prints
a traceback each time the address is accessed. This script needs to
be run as root to allow access to the breakpoint hardware.
# stap --all-modules hw_watch_addr.stp 0x`grep "vm_dirty_ratio" \
/proc/kallsyms | awk '{print $1}'` -T 5
memory/hw_watch_sym.stp - Watch a Kernel Symbol Using Breakpoint Hardware
keywords: memory watchpoint
The script will watch accesses to the starting address of a single
kernel symbol and prints a traceback each time the symbol is
accessed. This script needs to be run as root to allow access to the
breakpoint hardware.
# stap --all-modules hw_watch_sym.stp vm_dirty_ratio -T 5
memory/kmalloc-top - Show Paths to Kernel Malloc Invocations
keywords: memory
The kmalloc-top perl program runs a small systemtap script to collect
stack traces for each call to the kmalloc function and counts the
time that each stack trace is observed. When kmalloc-top exits it
prints out sorted list. The output can be filtered to print only the
first N stack traces (-t), stack traces with a minimum counts (-m),
or exclude certain stack traces (-e).
# ./kmalloc-top -c "sleep 1"
memory/last_100_frees.stp - Log recent free(3) calls.
keywords: memory process backtrace
This script reports on the last few free(3) libc calls done by
processes (possibly restricted by stap -x/-c), along with a userspace
backtrace at those moments.
# stap last_100_frees.stp -c "stap -V" -d `which stap` --ldd
memory/mmanonpage.stp - Track Virtual Memory System Actions on Anonymous Pages
keywords: memory
The mmanonpage.stp script uses the virtual memory tracepoints
available in some kernels to track the number of faults, user space
frees, page ins, copy on writes and unmaps for anonymous pages. When
the script is terminated the counts are printed for each process that
allocated pages while the script was running. This script displays
the anonymous page statistics for each process that ran while the
script is active. It's useful in debugging leaks in the anonymous
regions of a process.
# stap mmanonpage.stp -T 1
memory/mmfilepage.stp - Track Virtual Memory System Actions on File Backed Pages
keywords: memory
The mmfilepage.stp script uses the virtual memory tracepoints
available in some kernels to track the number of faults, copy on
writes mapping, and unmapping operations for file backed pages. When
the script is terminated the counts are printed for each process that
allocated pages while the script was running. The mmfilepage.stp
script is useful in debugging leaks in the mapped file regions of a
process.
# stap mmfilepage.stp -T 1
memory/mmreclaim.stp - Track Virtual Memory System Page Reclamation
keywords: memory
The mmreclaim.stp script uses the virtual memory tracepoints
available in some kernels to track page reclaim activity that
occurred while the script was running. It's useful in debugging
performance problems that occur due to page reclamation.
# stap mmreclaim.stp -T 1
memory/mmwriteback.stp - Track Virtual Memory System Writing to Disk
keywords: memory
The mmwriteback.stp script uses the virtual memory tracepoints
available in some kernels to report all of the file writebacks that
occur form kupdate, pdflush and kjournald while the script is
running. It's useful in determining where writes are coming from on
a supposedly idle system that is experiencing unexpected IO.
# stap mmwriteback.stp -T 1
memory/numa_faults.stp - Summarize Process Misses across NUMA Nodes
keywords: memory numa
The numa_faults.stp script tracks the read and write pages faults for
each process. When the script exits it prints out the total read and
write pages faults for each process. The script also provide a break
down of page faults per node for each process. This script is useful
for determining whether the program has good locality (page faults
limited to a single node) on a NUMA computer.
# stap numa_faults.stp -T 1
memory/overcommit.stp - Log Failed Process Memory Allocation Due to Overcommit Limits
keywords: memory limits
The overcommit.stp script prints a line each time the kernel refuses
a memory allocation request from a process because of
/proc/sys/vm/overcommit* limits.
# stap overcommit.stp -T 1
memory/pfaults.stp - Generate Log of Major and Minor Page Faults
keywords: memory
The pfaults.stp script generates a simple log for each major and
minor page fault that occurs on the system. Each line contains a
timestamp (in microseconds) when the page fault servicing was
completed, the pid of the process, the address of the page fault, the
type of access (read or write), the type of fault (major or minor),
and the elapsed time for page fault. This log can be examined to
determine where the page faults are occurring.
# stap pfaults.stp -T 1
memory/vm.tracepoints.stp - Collect Slab Allocation Statistics
keywords: memory statistics
The script will probe all memory slab/slub allocations and collects
information about the size of the object (bytes requested) and
user-space process in execution. When run over a period of time, it
helps to correlate kernel-space memory consumption owing to
user-space processes.
# stap vm.tracepoints.stp -T 10
network/autofs4.stp - Watch autofs4 Operations
keywords: network nfs
Trace key autofs4 operations such as mounting or unmounting remote
filesystems.
# stap autofs4.stp -T 1
network/connect_stat.stp - Show Process Ancestry for IP Connections
keywords: network socket process
The connect_stat.stp script prints a task's entire ancestry (parent
process name/uid/gid) whenever it attempts an outgoing socket
connection to a given IP address.
# stap connect_stat.stp 127.0.0.1 -T 1
network/dropwatch.stp - Watch Where Socket Buffers Are Freed in the Kernel
keywords: network tracepoint socket
Every five seconds the dropwatch.stp script lists the number of
socket buffers freed at locations in the kernel.
# stap dropwatch.stp -T 1
network/net_xmit_json.stp - Tracks time between packet queue and transmit.
keywords: network statistics json
This script tracks time between packet queue and transmit. The
information is provided to userspace via procfs in JSON format.
# stap net_xmit_json.stp -T 1
network/netdev.stp - Trace Activity on Network Devices
keywords: network traffic
The netdev.stp script traces configuration and transmit/receive
activity on network devices.
# stap netdev.stp -T 1
network/netfilter_drop.stp - System-Wide Network Packet Dropping Tool
keywords: network packets guru
The script drops the specified number of packets of the specified
protocol. Valid protocols are TCP, UDP, or ALL. If ALL is specified,
all incoming packets are dropped. The number of packets to drop can
be specified with a positive integer. A value of 0 indicates that
packets should be dropped until the user manually exits.
# stap -g netfilter_drop.stp TCP 1 -T 2
network/netfilter_summary.stp - System-Wide Count of Network Packets by IPs
keywords: _best network traffic
The script watches all IPv4 network traffic on the system. On exit
the script prints a list showing the number of packets sent along
source IP address / destination IP address pair encountered, and the
total number of bytes sent among the pair. The list is ordered from
greatest to least number of packets seen among the source/destination
pairs.
# stap netfilter_summary.stp -T 1
network/netfilter_summary_json.stp - System-Wide Count of Network Packets by IPs
keywords: _best network traffic json
The script watches all IPv4 network traffic on the system. The data
is output in JSON format and includes the number of packets sent
along source IP address / destination IP address pair encountered,
and the total number of bytes sent among the pair.
# stap netfilter_summary_json.stp -T 1
network/nettop.stp - Periodic Listing of Processes Using Network Interfaces
keywords: network traffic
Every five seconds the nettop.stp script prints out a list of
processed (PID and command) with the number of packets sent/received
and the amount of data sent/received by the process during that
interval.
# stap nettop.stp -T 1
network/nfsd-recent.stp - Keep track of NFS server statistics
keywords: nfs statistics
This script tracks all nfsd server operations by client_ip address,
and periodically lists those clients that have made recent requests.
It's a way of finding out which nfs clients might be considered still
connected.
# stap nfsd-recent.stp -T 1
network/nfsd-trace.stp - Trace NFSD requests with file names.
keywords: nfs trace
This script traces all nfsd server operations by client_ip address,
operation, and complete file name (if possible).
# stap nfsd-trace.stp -T 1
network/nfsd_unlink.stp - Find Which Client Is Removing NFS Files on Server
keywords: nfs disk
The nfsd_unlink.stp script lists the ip address and file name each
time time a file is being removed or unlinked by the nfsd. This
script is run on the nfs server.
# stap nfsd_unlink.stp -T 1
network/nfsdtop.stp - Keep track of NFS server statistics
keywords: nfs statistics
The nfsdtop.stp script gathers and displays NFS lookups,
# stap nfsdtop.stp -T 1
network/packet_contents.stp - Network packet contents
keywords: network traffic
The packet_contents.stp script displays the length of each network
packet and its contents in both hexadecimal and ASCII. Systemtap
strings are MAXSTRINGLEN in length by default which may not be enough
for larger packets. In order to print larger packets, this limit can
be increased by passing in the "-DMAXSTRINGLEN=65536" command line
option.
# stap packet_contents.stp -T 1
network/sk_stream_wait_memory.stp - Track Start and Stop of Processes Due to Network Buffer Space
keywords: network tcp process
The sk_stream-wait_memory.stp prints a time stamp, executable, and
pid each time a process blocks due to the send buffer being full. A
similar entry is printed each time a process continues because there
is room in the buffer.
# stap sk_stream_wait_memory.stp -T 1
network/socket-trace.stp - Trace Functions Called in Network Socket Code
keywords: network socket
The script instruments each of the functions in the Linux kernel's
net/socket.c file. The script prints out trace data. The first
element of a line is time delta in microseconds from the previous
entry. This is followed by the command name and the PID. The "->" and
"<-" indicates function entry and function exit, respectively. The
last element of the line is the function name.
# stap socket-trace.stp -T 1
network/socktop - Periodically Summarize Socket Activity on the System
keywords: network socket
The socktop script periodically prints out a list of the processes
with the highest socket activity. Command line options for the
script allow filtering to focus on particular types of sockets. The
"-h" option lists socktop script's filtering options.
# ./socktop -c 1
network/stp_dump.stp - Dump of STP packets
keywords: network traffic
The stp_dump.stp prints out the packet contents. Each block contains
the STP protocol ID, version ID, flags, root and bridge MAC
addresses, and various times.
# stap stp_dump.stp -T 5
network/tcp_connections.stp - Track Creation of Incoming TCP Connections
keywords: network tcp socket
The tcp_connections.stp script prints information for each new
incoming TCP connection accepted by the computer. The information
includes the UID, the command accepting the connection, the PID of
the command, the port the connection is on, and the IP address of the
originator of the request.
# stap tcp_connections.stp -T 1
network/tcp_init_cwnd.stp - Increase Initial TCP Congestion Window to 10
keywords: network tcp socket guru
Run the tcp_init_cwnd.stp script in the background to override a
kernel's default tcp cwnd value to 10, which has been found to
improve latency for web server type workloads. The script prints a
count of cwnd value changes when it is stopped.
# stap -g tcp_init_cwnd.stp -T 1
network/tcp_retransmission.stp - print tcp retransmission packet
keywords: tcp retransmission
The tcp_retransmission.stp prints out a line for each tcp
retransmission packet
# stap tcp_retransmission.stp -T 1
network/tcp_trace.stp - TCP Connection Tracing Utility
keywords: network trace
This scripts traces a given TCP connection based on the filter
parameters given by the user. The indexing is done by the 4 tuples
local address, remote address, local port, remote port.
# stap tcp_trace.stp 127.0.0.1:*-127.0.0.1:* timeout=1
network/tcpdumplike.stp - Dump of Received UDP/TCP Packets
keywords: network traffic
The tcpdumplike.stp prints out a line for each TCP & UDP packet
received. Each line includes the source and destination IP addresses,
the source and destination ports, and flags.
# stap tcpdumplike.stp -T 1
network/tcpipstat.stp - Display Network Statistics for Individual TCP Sockets
keywords: network statistics
The tcpipstat script collects and displays network statistics related
to individual TCP sockets or groups of sockets. The statistics that
are collected are simular to that of the command netstat -s, only
sorted and grouped by individual sockets.
# stap tcpipstat.stp timeout=1
network/who_sent_it.stp - Trace threads sending network traffic to given host and/or port
keywords: network trace traffic simple
This script traces outgoing network packets using the netfilter
probes (not requiring debuginfo), printing the source thread name/id
and destination host:port. It may be filtered with the_dport and
the_daddr globals, e.g., to watch only for DNS traffic (port 53),
and/or only to the localhost (127.0.0.1).
# stap who_sent_it.stp -G the_dport=53 -c "ping -c 1 sourceware.org || \
true"
process/auditbt.stp - Generate backtraces for kernel audit events
keywords: monitoring security backtrace
Attaches to the kernel audit-log paths (also used by libaudit), and
log every record being sent, along with a user-space backtrace of the
process that caused it.
# stap auditbt.stp -d /usr/bin/sudo --ldd -c "sudo true"
process/chng_cpu.stp - Monitor Changes in Processor Executing a Task
keywords: scheduler
The chng_cpu.stp script takes an argument which is the executable
name of the task it should monitor. Each time a task with that
executable name is found running on a different processor, the script
prints out the thread id (tid), the executable name, the processor
now running the task, the thread state, and a backtrace showing the
kernel functions that triggered the running of the task on the
processor.
# stap chng_cpu.stp -T 1 bash
process/cycle_thief.stp - Track IRQ's and Other Processes Stealing Cycles from a Task
keywords: _best process scheduler time tracepoint interrupt
The cycle_thief.stp script instruments the scheduler and IRQ handler
to determine which processes and interrupts are competing with the
specified task for the cpu cycles. This script uses the '-c' or '-x'
options to focus on a specific task. The script output the number of
times the task migrates between processors, histograms showing the
length of time on and off processor, lists of processes running while
the task is off the processor, and the interrupts that occurred while
the task was running.
# stap cycle_thief.stp -T 1
process/errsnoop.stp - Tabulate System Call Errors
keywords: process syscall
Prints a periodic tabular report about failing system calls, by
process and by syscall failure. The first optional argument
specifies the reporting interval (in seconds, default 5); the second
optional argument gives a screen height (number of lines in the
report, default 20).
# stap errsnoop.stp 1 10 -T 1
process/forktracker.stp - Trace Creation of Processes
keywords: process scheduler
The forktracker.stp script prints out a time-stamped entry showing
each fork and exec operation on the machine. This can be useful to
determine what process is creating a flurry of short-lived processes.
# stap forktracker.stp -T 1
process/futexes.stp - System-Wide Futex Contention
keywords: syscall locking futex
The script watches the futex syscall on the system. On exit the
futex's address, the number of contentions, and the average time for
each contention on the futex are printed from lowest pid number to
highest.
# stap futexes.stp -T 1
process/futexes2.stp - System-Wide Shared Futex Contention
keywords: syscall locking futex
The script watches just shared futex syscalls on the system. On exit
the futex's key, the number of contentions, and the average time for
each contention on the futex are printed from lowest pid number to
highest.
# stap futexes2.stp -T 1
process/ltrace.stp - uprobes-based ltrace
keywords: process
The ltrace.stp script lists calls that the designated process makes
through PLTs (procedure linkage tables), generally into shared
libraries.
# stap ltrace.stp -c ls || echo PR14738
process/migrate.stp - Track the Migration of Specific Executables
keywords: scheduler
The migrate.stp script takes an argument which is the executable name
of the task it should monitor. Each time a task with that executable
name migrates between processors an entry is printed with the process
id (pid), the executable name, the processor off loading the task,
and the process taking the task. Note that the task may or may not be
executing at the time of the migration.
# stap migrate.stp -T 1 bash
process/mutex-contention.stp - pthread mutex contention analysis
keywords: locking
Tracks pthread-mutex initialization/use and underlying futex
operations, to identify (with backtraces/symbol-names) the mutexes
suffering most contention. Invoke with "-d SHLIB --ldd", perhaps
with -DMAXMAPENTRIES=NNNN for some large NNNN, if the arrays overflow
due to heavy activity.
# stap mutex-contention.stp -T 1
process/noptrace.stp - Disable ptrace from Hierarchies of Processes
keywords: process security guru
Blocks ptrace(2) attempts from processes identified by stap -c/-x, as
also specifiable from /proc/systemtap/stap_XXX/ control files.
Processes may be added or removed from the blocked list.
# stap -g noptrace.stp -c 'strace ls || true'
process/pfiles.stp - Print Process File Descriptors
keywords: process file
Run pfiles.stp to produce a human-readable summary of all open file
descriptors of a given process. Specify the process-id as -x PID for
fastest performance.
# stap -g pfiles.stp -x $$
process/plimit.stp - Print Resource Limits of Process
keywords: process
The script prints a variety of resource limits for a given pid, like
/proc/$$/limits on recent kernels.
# stap -g plimit.stp $$
process/procmod_watcher.stp - Monitor process creation/termination and module [un]loading
keywords: process monitoring syscall tracepoint
The procmod_watcher.stp script monitors calls to fork(), exec(),
exit(), init_module(), and delete_module(). Event-specific details
are also printed out (e.g. for exec(), the file being exec'ed). This
script does not require debuginfo.
# stap procmod_watcher.stp -T 1
process/proctop.stp - Periodically Print Process Information With History
keywords: process scheduler _best
Every 5 seconds, print out a list of 25 processes that took the most
system time with information about the processes. Includes
information on processes that may have exited while the script was
running. The script contains configuration options listed in the
script source.
# stap proctop.stp -T 1
process/psig.stp - Print Process File Descriptors
keywords: process signals
Run psig.stp to produce a human-readable summary of the signal
handling configuration of a given process. Specify the process-id as
-x PID for fastest performance.
# stap -DMAXACTION=10000 -g psig.stp -x $$
process/pstrace_exec.stp - Print trace of process ancestors for matching exec commands
keywords: process backtrace
The pstrace_exec.stp script watches each exec operation. If the exec
contains a substring that matches the script's command-line argument,
it prints out that process and all of its ancestors.
# stap pstrace_exec.stp -T 1 bash
process/pstree.stp - Generates a process diagram in DOT form.
keywords: process diagram
The pstree.stp script generates a process diagram in DOT form. For
instance, it may be useful on a 'make' command to see all the
processes that are started.
# stap pstree.stp -T 1
process/rlimit_nofile.stp - Trace processes running out of file descriptors
keywords: limits
This script watches processes being scheduled and which try to
allocate a file descriptor without luck.
# stap rlimit_nofile.stp -T 1
process/sched-latency.stp - track wakeup-to-dispatch latency stats
keywords: process scheduler time tracepoint
This script periodically reports a histogram of the latency between a
task (thread) being woken up and it actually being dispatched to a
CPU: the amount of time it's spent in the runnable queue.
# stap sched-latency.stp -T 7
process/schedtimes.stp - Track Time Processes Spend in Various States Using Tracepoints
keywords: process scheduler time tracepoint
The schedtimes.stp script instruments the scheduler to track the
amount of time that each process spends in running, sleeping,
queuing, and waiting for io. On exit the script prints out the
accumulated time for each state of processes observed. Optionally,
this script can be used with the '-c' or '-x' options to focus on a
specific PID and its children.
# stap schedtimes.stp -T 1
process/semop-watch.stp - Watch semop(2)/semtimedop(2) operations
keywords: process locking
Prints a timed trace of semop(2)/semtimedop(2) syscalls
# stap semop-watch.stp -c 'sleep 2'
process/sig_by_pid.stp - Signal Counts by Process ID
keywords: signals
Print signal counts by process ID in descending order.
# stap sig_by_pid.stp -T 1
process/sig_by_proc.stp - Signal Counts by Process Name
keywords: signals
Print signal counts by process name in descending order.
# stap sig_by_proc.stp -T 1
process/sigkill.stp - Track SIGKILL Signals
keywords: signals
The script traces any SIGKILL signals. When that SIGKILL signal is
sent to a process, the script prints out the signal name, the
destination executable and process ID, the executable name and user
ID that sents the signal.
# stap sigkill.stp -T 1
process/sigmon.stp - Track a Particular Signal to a Specific Process
keywords: signals
The script watches for a particular signal sent to a specific
process. When that signal is sent to the specified process, the
script prints out the PID and executable of the process sending the
signal, the PID and executable name of the process receiving the
signal, and the signal number and name.
# stap sigmon.stp -T 1 SIGKILL
process/sleepingBeauties.stp - Generate Backtraces of Threads Waiting for IO Operations
keywords: io scheduler backtrace
The script monitors the time that threads spend in waiting for IO
operations (in "D" state) in the wait_for_completion function. If a
thread spends over 10ms, its name and backtrace is printed, and later
so is the total delay.
# stap sleepingBeauties.stp -T 1
process/sleeptime.stp - Trace Time Spent in Nanosleep Syscalls
keywords: syscall nanosleep
The script watches each nanosleep syscall on the system. At the end
of each nanosleep syscall the script prints out a line with a
timestamp in microseconds, the pid, the executable name in
parentheses, the "nanosleep:" key, and the duration of the sleep in
microseconds.
# stap sleeptime.stp -T 1
process/spawn_seeker.stp - Track Creation of Processes by process and execname
keywords: process scheduler
The spawn_seeker.stp script every minute (and on exit) prints out the
local time and sorted lists of which processes and executables
spawned tasks during the previous minute. This can be useful to
determine what process is creating a flurry of short-lived processes.
When a process exits its count of tasks created is added to its
parent's count to better account for the indirect task creation by
children processes. For more detailed examination of task creation
consider using forktracker.stp.
# stap spawn_seeker.stp -T 1
process/strace.stp - Trace system calls
keywords: _best process syscall
The script loosely emulates strace, when applied to individual
processes or hierarchies (via -c/-x), or the entire system (without
-c/-x). A few output configuration parameters may be set with -G.
# stap strace.stp -c "cat /proc/sys/vm/* || true"
process/syscalls_by_pid.stp - System-Wide Count of Syscalls by PID
keywords: syscall
The script watches all syscall on the system. On exit the script
prints a list showing the number of systemcalls executed by each PID
ordered from greatest to least number of syscalls.
# stap syscalls_by_pid.stp -T 1
process/syscalls_by_proc.stp - System-Wide Count of Syscalls by Executable
keywords: syscall
The script watches all syscall on the system. On exit the script
prints a list showing the number of systemcalls executed by each
executable ordered from greatest to least number of syscalls.
# stap syscalls_by_proc.stp -T 1
process/syscalltimes - System-Wide Syscall Statistics with Filtering
keywords: syscall
Combination shell/systemtap script to measure system call counts and
times. Can be filtered by process IDs, process names and users.
# ./syscalltimes -c 'sleep 1'
process/thread-business.stp - monitor syscall history
keywords: _best process syscall
Prints a periodic tabular report about the counts of syscall activity
of all threads on the system, along with a textual
recent-syscall-history for each
# stap thread-business.stp -T 10
process/threadstacks.stp - Override default new-pthread stack sizes
keywords: thread guru
Overrides default NPTL pthread_create stack size for all new threads
created by target processes. Reports one line per process when the
related glibc variable __default_stacksize is updated. Moot for
glibc versions that support $LIBC_PTHREAD_DEFAULT_STACKSIZE_NP.
# stap -g threadstacks.stp -Gsize=65536 -T 1 -d `which stap`
process/wait4time.stp - Trace Time Spent in wait4 Syscalls
keywords: syscall process
The script watches each wait4 syscall on the system. At the end of
each wait4 syscall the script prints out a line with a timestamp in
microseconds, the pid, the executable name in parentheses, the
"wait4:" key, the duration of the wait and the PID that the wait4 was
waiting for. If the waited for PID is not specified , it is "-1".
# stap wait4time.stp -T 1
profiling/container_check.stp - Monitor capabilities and syscalls used by a process and it children
keywords: profiling container syscall
The container_check.stp script monitors the use of linux capablities
and optionally forbidden syscalls by a process and its children. On
exit the script prints out lists showing the capabilies used by each
executable, which syscall used specific capabilites for each
executable, a list of forbidden syscalls used, and details on any
syscalls that failed during monitoring. This script is designed to
help diagnose issues caused by restricted capabilies and syscalls
when running an application in a container. If the script warns
about skipped probes, the number of active kretprobes may need to be
increased with "-DKRETACTIVE=100" option on the command line
# stap container_check.stp -c "ping -c 1 sourceware.org || true"
profiling/errno.stp - Show Which Processes and System Calls Return Errors Most Frequently
keywords: profiling
On exit the errno.stp script provides a sorted list showing which
combination of PID, system call, and error occur most frequently.
# stap errno.stp -T 1
profiling/fileline-profile.stp - Profile Kernel/User Functions
keywords: profiling
The fileline-profile.stp script ends by printing out a sorted list of
the top twenty kernel and/or user processes providing file:line
information, if available, from the samples addresses gathered over
the time period the script is run. Use any of --ldd, --all-modules,
-d MODULE, -d /PATH/TO/EXEC to add more symbolic info. To include the
symbol name in the output, specify guru mode (-g) and add
symbolname="yes" to the stap command.
# stap fileline-profile.stp -T 6 --all-modules --ldd
profiling/fntimes.stp - Show Functions Taking Longer Than Usual
keywords: _best profiling
The fntimes.stp script monitors the execution time history of a given
function family (assumed non-recursive). Each time (beyond a warmup
interval) is then compared to the historical maximum. If it exceeds
a certain threshold (250%), a message is printed.
# stap fntimes.stp 'kernel.function("sys_*")' -T 7
profiling/functioncallcount.stp - Count Times Functions Are Called
keywords: profiling function
The functioncallcount.stp script takes one argument, a list of
functions to probe. The script will run and count the number of times
that each of the functions on the list is called. On exit the script
will print a sorted list from most frequently to least frequently
called function.
# stap -w functioncallcount.stp "*@mm/*.c" -T 1
profiling/ioctl_handler.stp - Monitor which executables use ioctl syscalls and what kernel code is handling the ioctl
keywords: profiling
The ioctl systemcall is used to manipulate devices setting or special
files. The way that ioctl syscalls are handled depend greatly on the
device the special file is associated with. Using strace to monitor
the open and ioctl syscalls may not give a good indication of what
kernel code is actually handling the ioctl operations. The
ioctl_handler.stp script is designed to provide more details. On exit
the ioctl_handler.stp script provides a count of the ioctl syscalls
for each executable run on the system. If there was some special
device driver code used to handle to the ioctl, the output will have
a tally of the times the function name and module was called for that
executable. The "--all-modules" option should be included on the
command line so the script can provide function name information.
# stap ioctl_handler.stp --all-modules -T 1
profiling/latencytap.stp - Show Reasons and Durations for Processes Sleeping
keywords: _best profiling
The latencytap.stp script collects data on the intervals processes
are deactivated (sleeping). The script categorizes the reasons for
the sleeps by analyzing the backtraces and displays a sorted list of
the top 20 causes from largest total sum time sleeping to smallest.
The output is updated every 30 seconds. The script needs to be
compiled with the '--all-modules' option to produce reasons for
sleeps caused by modules. Optionally, this script can be used with
the '-c' or '-x' options to focus on a specific PID.
# stap latencytap.stp --all-modules -T 1
profiling/linetimes.stp - Show Time Spent on Each Line of a Function
keywords: profiling _best
The linetimes.stp script takes two arguments: where to find the
function and the function name. linetimes.stp will instrument each
line in the function. It will print out the number of times that the
function is called, a table with the average and maximum time each
line takes, and control flow information when the script exits.
# stap linetimes.stp kernel do_nanosleep -T 1
profiling/perf.stp - Show performance ratios using perf.counter to access performance counters
keywords: profiling
On exit the perf.stp script provides a sorted list showing cycles per
insn, branches per insn, and cache refs per insn
# stap -w perf.stp -c "find /usr/bin -name \"l*\" -printf \"%h/%f %s %Cx \
%Ck%CM %Y\n\""
profiling/periodic.stp - Show the Period of the Various Timers on the System
keywords: profiling
The periodic.stp script uses the kernel.trace("timer_expire_entry")
tracepoint to collect data on period and frequency of the various
timers on the system. The script displays a sorted list of the
timers observed on the system from most frequent to least frequent.
The script needs to be compiled with the '--all-modules' option to
produce list the function names. Optionally, this script can be used
with a numerical argument to indicate the interval in seconds between
printing output.
# stap periodic.stp --all-modules -T 1
profiling/pf2.stp - Profile Kernel Functions
keywords: profiling
The pf2.stp script sets up time-based sampling. Every five seconds it
prints out a sorted list with the top ten kernel functions with
samples.
# stap pf2.stp -T 1
profiling/pf3.stp - Profile Kernel/User Functions
keywords: profiling
The pf3.stp script sets up time-based sampling. Every five seconds it
prints out a sorted list with the top twenty kernel and/or user
functions with samples. Use any of --ldd, --all-modules, -d MODULE,
-d /PATH/TO/EXEC to add more symbolic info.
# stap pf3.stp -T 6 --all-modules --ldd
profiling/pf4.stp - Profile Kernel/User Backtraces
keywords: _best profiling backtrace
The pf4.stp script sets up time-based sampling. Every five seconds it
prints out a sorted list with the top twenty kernel and/or user stack
backtraces (on a per-cpu basis). Use any of --ldd, --all-modules, -d
MODULE, -d /PATH/TO/EXEC to add more symbolic info.
# stap pf4.stp -T 6 --all-modules --ldd
profiling/sched_switch.stp - Display the Task Switches Happening in the Scheduler
keywords: profiling function
The sched_switch.stp script takes two arguments, first argument can
be "pid" or "name" to indicate what is being passed as second
argument. The script will trace the process based on pid/name and
print the scheduler switches happening with the process. If no
arguments are passed, it displays all the scheduler switches. This
can be used to understand which tasks schedule out the current
process being traced, and when it gets scheduled in again.
# stap sched_switch.stp -T 1
profiling/syscallerrorsbypid.stp - Provide a per-process syscall error tally on the system
keywords: prometheus process syscall tracepoint
The syscallerrorsbypid.stp script tallies syscall errors for each
running process. This information can be useful to whether there are
excessive errors for various processes on the system. The script
makes the information available via procfs in Prometheus readable
format. When a process exits its data will be eliminated from the
prometheus output. To avoid exceeding the storage limitations of
SystemTap older entries maybe overwritten by newer entries. This can
lead to some active process syscall error counts disappearing and/or
later reappearing with a lower value. Also note that the script does
not properly name syscalls for 32-bit applications running on 64-bit
machines.
# stap syscallerrorsbypid.stp -T 1
profiling/syscalllatency.stp - Provide a per-process accumulation of syscall latency on the system
keywords: prometheus process syscall tracepoint
The syscalllatency.stp script accumulates syscall latency for each
running process. This information can be useful to whether excessive
time is being spent in particular syscalls on the system. The script
makes the information available via procfs in Prometheus readable
format. When a process exits its data will be eliminated from the
prometheus output. To avoid exceeding the storage limitations of
SystemTap older entries maybe overwritten by newer entries. This can
lead to some active process syscall error counts disappearing and/or
later reappearing with a lower value. Also note that the script does
not properly name syscalls for 32-bit applications running on 64-bit
machines.
# stap syscalllatency.stp -T 1
profiling/syscallsbypid.stp - Provide a per-process syscall tally on the system
keywords: prometheus process syscall tracepoint
The syscallsbypid.stp script tallies each syscall for each running
process. This information can be useful to determine the activity of
various processes on the system. The script makes the information
available via procfs in Prometheus readable format. When a process
exits its data will be eliminated from the prometheus output. To
avoid exceeding the storage limitations of SystemTap older entries
maybe overwritten by newer entries. This can lead to some active
process syscall counts disappearing and/or later reappearing with a
lower value. Also note that the script does not properly name
syscalls for 32-bit applications running on 64-bit machines.
# stap syscallsbypid.stp -T 1
profiling/thread-times.stp - Profile Kernel Functions
keywords: _best profiling
The thread-times.stp script sets up time-based sampling. Every five
seconds it prints out a sorted list with the top twenty threads
occupying the CPUs, broken down as a percentage of user and kernel
time.
# stap thread-times.stp -T 1
profiling/timeout.stp - Show Processes Doing Polling Operations
keywords: profiling
The timeout.stp script is based on a blog entry
(http://udrepper.livejournal.com/19041.html) mentioning a need for a
tool to help developers find applications that are polling. The
timeout.stp script monitors systemcall used for polling and records
the systemcalls that timed out rather than returned because some
action occurred. The script updates the screen once a second with the
top twenty processes.
# stap timeout.stp -T 1
profiling/topsys.stp - Show Processes Doing Polling Operations
keywords: profiling
The topsys.stp script lists out the top twenty systemcalls for the
previous 5 seconds. The output is sorted from most frequent to least
frequent.
# stap topsys.stp -T 1
security-band-aids/cve-2008-0600.stp - cve-2008-0600 security band-aid
keywords: security guru
historical emergency security band-aid, for reference/education only
security-band-aids/cve-2012-0056.stp - cve-2012-0056 security band-aid
keywords: security guru
historical emergency security band-aid, for reference/education only
security-band-aids/cve-2013-2094.stp - cve-2013-2094 security band-aid
keywords: security guru
historical emergency security band-aid, for reference/education only
security-band-aids/cve-2014-7169.stp - cve-2014-7169 security band-aid
keywords: security guru
historical emergency security band-aid, for reference/education only
security-band-aids/cve-2015-0235.stp - cve-2015-0235 security band-aid
keywords: security guru
historical emergency security band-aid, for reference/education only
security-band-aids/cve-2015-3456.stp - cve-2015-3456 security band-aid
keywords: security guru
historical emergency security band-aid, for reference/education only
security-band-aids/cve-2015-7547.stp - cve-2015-7547 security band-aid
keywords: security guru
historical emergency security band-aid, for reference/education only
security-band-aids/cve-2016-0728.stp - cve-2016-0728 security band-aid
keywords: security guru
historical emergency security band-aid, for reference/education only
security-band-aids/cve-2016-5195.stp - cve-2016-5195 security band-aid
keywords: security guru
historical emergency security band-aid, for reference/education only
security-band-aids/cve-2017-6074.stp - cve-2017-6074 security band-aid
keywords: security guru
historical emergency security band-aid, for reference/education only
security-band-aids/cve-2018-14634.stp - cve-2018-14634 security band-aid
keywords: security guru
historical emergency security band-aid, for reference/education only
stapgames/2048.stp - 2048
keywords: _best stapgames
The modern classic 2048 sliding-tiles game, using local keyboard and
ansi animation.
# stap -p4 2048.stp
stapgames/block.stp - block breaker game
keywords: stapgames
A block game where you progressively break the ceiling blocks until
clearing the level
# stap -p4 -Itapset/ block.stp
stapgames/eater.stp - eater game
keywords: stapgames
walk through a maze, eat stuff
# stap -p4 -Itapset/ eater.stp
stapgames/lifegame.stp - life game
keywords: stapgames
watch as your creation morphes into different forms
# stap -p4 -Itapset/ lifegame.stp
stapgames/pingpong.stp - pingpong game
keywords: stapgames
A simulated ball bounces around the terminal reflecting at the edges
# stap -p4 -Itapset/ pingpong.stp
virtualization/kvm_service_time.stp - Time Statistics on KVM Exit Reasons
keywords: _best virtualization kvm
The kvm_service_time.stp script tracks the statistics about the
amount of time that the processor left the guest virtual machine for
each exit reason (for example fixing up a page table or handling an
IO operation). When the script exits it prints out the number of
times each exit reason was encountered, the total duration of time it
left the guest VM, the minimum time, the average time, and the
maximum time in microseconds for that exit reason. On Linux 2.6.38
and newer kernel the script can automatically determine whether it is
running on Intel or AMD processors. For older kernels with a
kernel.trace("kvm_exit") tracepoint that does not have the $isa
parameter you can explicitly state the kvm type with a "-G kvm=intel"
or "-G kvm=amd" on the command line.
# stap kvm_service_time.stp -T 1
virtualization/qemu_count.stp - Tally the Number of User-Space QEMU Events
keywords: virtualization qemu kvm
The qemu_count.stp script tallies the number of times each of the
user-space qemu probepoints is encountered. When the script exits, it
prints a list of the number of times each user-space qemu probepoint
is encountered.
# stap qemu_count.stp -T 1
virtualization/qemu_io.stp - Tally the Number of User-Space QEMU IO on Each IO Port
keywords: virtualization qemu kvm io
The qemu_io.stp script tallies the number of times each of the IO
port on the guest virtual machines is touched by a input or output
operation. When the script exits, it prints a count of the number of
times each IO port read and written.
# stap qemu_io.stp -T 1
|