├── CONTRIBUTING.md ├── CONTRIBUTORS ├── LICENSE.txt ├── Makefile ├── README.md ├── SECURITY.md ├── oled.man ├── oled.py ├── sbom_generation.yaml ├── scripts ├── Makefile ├── core │ ├── spinlock_time.d │ └── spinlock_time_example.txt ├── io │ ├── nvme_io_comp.d │ ├── nvme_io_comp_example.txt │ ├── scsi_latency.d │ ├── scsi_latency_example.txt │ ├── scsi_queue.d │ └── scsi_queue_example.txt └── net │ ├── arp_origin.d │ ├── arp_origin_example.txt │ ├── ping_lat.d │ ├── ping_lat_example.txt │ ├── rds_bcopy_metric.d │ ├── rds_bcopy_metric_example.txt │ ├── rds_check_tx_stall.d │ ├── rds_check_tx_stall_example.txt │ ├── rds_conn2irq.d │ ├── rds_conn2irq_example.txt │ ├── rds_egress_TP.d │ ├── rds_egress_TP_example.txt │ ├── rds_rdma_lat.d │ ├── rds_rdma_lat_example.txt │ ├── rds_rdma_xfer_rate.d │ ├── rds_rdma_xfer_rate_example.txt │ ├── rds_tx_funccount.d │ └── rds_tx_funccount_example.txt └── tools ├── kstack ├── Makefile ├── kstack └── kstack.man ├── lkce ├── Makefile ├── lkce.man └── scripts │ ├── kdump_report.py │ └── lkce.py ├── memstate ├── Makefile ├── memstate.man ├── memstate.py └── memstate_lib │ ├── __init__.py │ ├── base.py │ ├── buddyinfo.py │ ├── constants.py │ ├── hugepages.py │ ├── logfile.py │ ├── meminfo.py │ ├── numa.py │ ├── pss.py │ ├── rss.py │ ├── slabinfo.py │ └── swap.py ├── scanfs ├── Makefile ├── scanfs.man └── scanfs.py ├── syswatch ├── Makefile ├── syswatch ├── syswatch.8 └── syswatch.8.scd └── vmcore-utils ├── Makefile ├── vmcore_sz.man └── vmcore_sz.py /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to this repository 2 | 3 | We welcome your contributions! There are multiple ways to contribute. 4 | 5 | ## Opening issues 6 | 7 | For bugs or enhancement requests, please file a GitHub issue unless it's 8 | security related. When filing a bug remember that the better written the bug 9 | is, the more likely it is to be fixed. If you think you've found a security 10 | vulnerability, do not raise a GitHub issue and follow the instructions in our 11 | [security policy](./SECURITY.md). 12 | 13 | ## Contributing code 14 | 15 | We welcome your code contributions. Before submitting code via a pull request, 16 | you will need to have signed the [Oracle Contributor Agreement][OCA] (OCA) and 17 | your commits need to include the following line using the name and e-mail 18 | address you used to sign the OCA: 19 | 20 | ```text 21 | Signed-off-by: Your Name 22 | ``` 23 | 24 | This can be automatically added to pull requests by committing with 25 | `--signoff` or `-s`, e.g. 26 | 27 | ```text 28 | git commit --signoff 29 | ``` 30 | 31 | Only pull requests from committers that can be verified as having signed the 32 | OCA can be accepted. 33 | 34 | ## Pull request process 35 | 36 | 1. Ensure there is an issue created to track and discuss the fix or enhancement 37 | you intend to submit. 38 | 1. Fork this repository. 39 | 1. Create a branch in your fork to implement the changes. We recommend using 40 | the issue number as part of your branch name, e.g. `1234-fixes`. 41 | 1. Ensure that any documentation is updated with the changes that are required 42 | by your change. 43 | 1. Ensure that any samples are updated if the base image has been changed. 44 | 1. Submit the pull request. *Do not leave the pull request blank*. Explain 45 | exactly what your changes are meant to do and provide simple steps on how to 46 | validate. your changes. Ensure that you reference the issue you created as 47 | well. 48 | 1. We will assign the pull request to 2-3 people for review before it is 49 | merged. 50 | 51 | ## Code of conduct 52 | 53 | Follow the [Golden Rule](https://en.wikipedia.org/wiki/Golden_Rule). If you'd 54 | like more specific guidelines, see the [Contributor Covenant Code of 55 | Conduct][COC]. 56 | 57 | [OCA]: https://oca.opensource.oracle.com 58 | [COC]: https://www.contributor-covenant.org/version/1/4/code-of-conduct/ 59 | -------------------------------------------------------------------------------- /CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | Alina Yurenko 2 | Arumugam Kolappan 3 | Aruna Ramakrishna 4 | Cesar Roque 5 | Jeffery Yoder 6 | Jose Lombera 7 | Manjunath Patil 8 | Mridula Shastry 9 | Nagappan Ramasamy Palaniappan 10 | Oleksandra Pavlusieva 11 | Partha Sarathi Satapathy 12 | Praveen Kumar Kannoju 13 | Srikanth C S 14 | Srinivas Eeda 15 | Wengang Wang 16 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023, Oracle and/or its affiliates. 2 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 | # 4 | # This code is free software; you can redistribute it and/or modify it 5 | # under the terms of the GNU General Public License version 2 only, as 6 | # published by the Free Software Foundation. 7 | # 8 | # This code is distributed in the hope that it will be useful, but WITHOUT 9 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11 | # version 2 for more details (a copy is included in the LICENSE file that 12 | # accompanied this code). 13 | # 14 | # You should have received a copy of the GNU General Public License version 15 | # 2 along with this work; if not, see . 16 | # 17 | # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 18 | # or visit www.oracle.com if you need additional information or have any 19 | # questions. 20 | 21 | VERSION="0.7" 22 | ARCH := $(shell uname -m) 23 | 24 | subdirs := tools/lkce tools/memstate tools/kstack tools/syswatch tools/scanfs tools/vmcore-utils 25 | 26 | subdirs := $(subdirs) scripts 27 | rev_subdirs := $(shell echo -n "$(subdirs) " | tac -s ' ') 28 | OLEDDIR := $(DESTDIR)/etc/oled 29 | SBINDIR := $(DESTDIR)/usr/sbin 30 | MANDIR := $(DESTDIR)/usr/share/man/man8 31 | OLEDBIN := $(DESTDIR)/usr/libexec/oled-tools 32 | 33 | export OLEDDIR 34 | export MANDIR 35 | 36 | all: 37 | echo $(subdirs) 38 | $(foreach dir,$(subdirs), $(MAKE) BINDIR=$(OLEDBIN) -C $(dir) all || exit 1;) 39 | 40 | clean: 41 | 42 | $(foreach dir,$(subdirs), $(MAKE) BINDIR=$(OLEDBIN) -C $(dir) clean;) 43 | 44 | install: 45 | @echo "install:$(CURDIR)" 46 | $(MAKE) all 47 | mkdir -p $(OLEDDIR) 48 | mkdir -p $(SBINDIR) 49 | mkdir -p $(MANDIR) 50 | mkdir -p $(OLEDBIN) 51 | install -m 755 oled.py $(SBINDIR)/oled 52 | gzip -c oled.man > $(MANDIR)/oled.8.gz; chmod 644 $(MANDIR)/oled.8.gz 53 | $(foreach dir,$(subdirs), $(MAKE) BINDIR=$(OLEDBIN) -C $(dir) install || exit 1;) 54 | @echo "oled-tools installed" 55 | 56 | uninstall: 57 | @echo "uninstall:$(CURDIR)" 58 | $(foreach dir, $(rev_subdirs), $(MAKE) BINDIR=$(OLEDBIN) -C $(dir) uninstall || exit 1;) 59 | rm -f $(MANDIR)/oled.8.gz 60 | rm -f $(SBINDIR)/oled 61 | rmdir $(OLEDBIN) || : 62 | rmdir $(OLEDDIR) || : 63 | @echo "oled-tools uninstalled" 64 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # oled-tools 2 | 3 | Oracle Linux Enhanced Diagnostic (OLED) tools is a collection of tools, 4 | scripts, configs, etc. that collect and analyze data about the health of the 5 | system in order to root cause and resolve any system issues. 6 | 7 | ## Components 8 | 9 | The oled-tools repo includes the following debug tools/scripts that aid in 10 | gathering additional debug data from the system. Please review the 11 | corresponding man pages for more details. 12 | 13 | - lkce: Extracts data from a vmcore or from within the kdump kernel after a 14 | crash 15 | - memstate: Captures and analyzes various memory usage statistics on the 16 | running system 17 | - filecache: List the paths of the biggest files present in the page cache 18 | (note: this is present only on the x86-64 architecture) 19 | - dentrycache: Lists a sample of file paths which have active dentries in the 20 | dentry hash table 21 | (note: this is present only on the x86-64 architecture) 22 | - kstack: Collects the kernel stack trace for selected processes, based on 23 | status or PID 24 | - syswatch: Execute user-provided commands when CPU utilization reaches a 25 | threshold 26 | - scanfs: Scan KVM images for corruption, supports XFS and EXT4 27 | - vmcore-utils: Estimating vmcore size before kernel dump 28 | 29 | ## Installation 30 | 31 | ### Build dependencies 32 | 33 | - `make` 34 | - `python3` 35 | - `zlib-devel` 36 | - `bzip2-devel` 37 | - `elfutils-devel` 38 | 39 | ### Runtime dependencies 40 | 41 | - `python3` 42 | - `zlib` 43 | - `bzip2-libs` 44 | - `elfutils-libs` 45 | 46 | ### Build and install 47 | 48 | ```bash 49 | $ git clone https://github.com/oracle/oled-tools.git 50 | $ cd oled-tools 51 | $ make 52 | $ make install 53 | ``` 54 | 55 | `lkce` requires additional setup the first time - it is recommended to run 56 | the following command after oled-tools is installed: 57 | 58 | ```bash 59 | $ [ -f /etc/oled/lkce/lkce.conf ] || sudo oled lkce configure --default 60 | ``` 61 | 62 | ## Usage 63 | 64 | `oled-tools` must be run as root. After it has been installed, it can be run 65 | with 66 | 67 | ``` 68 | sudo oled [args] 69 | ``` 70 | 71 | Run `sudo oled --help` to see a list of subcommands supported and other options 72 | and `sudo oled {-h | --help}` to see help of specific commands. 73 | You can also consult man pages `oled(8)` and `oled-(8)`. 74 | 75 | ## Contributing 76 | 77 | This project welcomes contributions from the community. Before submitting a 78 | pull request, please [review our contribution guide](./CONTRIBUTING.md) 79 | 80 | ## Security 81 | 82 | Please consult the [security guide](./SECURITY.md) for our responsible security 83 | vulnerability disclosure process 84 | 85 | ## License 86 | 87 | oled-tools is licensed under [GPLv2](LICENSE.txt). 88 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Reporting security vulnerabilities 2 | 3 | Oracle values the independent security research community and believes that 4 | responsible disclosure of security vulnerabilities helps us ensure the security 5 | and privacy of all our users. 6 | 7 | Please do NOT raise a GitHub Issue to report a security vulnerability. If you 8 | believe you have found a security vulnerability, please submit a report to 9 | [secalert_us@oracle.com][1] preferably with a proof of concept. Please review 10 | some additional information on [how to report security vulnerabilities to Oracle][2]. 11 | We encourage people who contact Oracle Security to use email encryption using 12 | [our encryption key][3]. 13 | 14 | We ask that you do not use other channels or contact the project maintainers 15 | directly. 16 | 17 | Non-vulnerability related security issues including ideas for new or improved 18 | security features are welcome on GitHub Issues. 19 | 20 | ## Security updates, alerts and bulletins 21 | 22 | Security updates will be released on a regular cadence. Many of our projects 23 | will typically release security fixes in conjunction with the 24 | Oracle Critical Patch Update program. Additional 25 | information, including past advisories, is available on our [security alerts][4] 26 | page. 27 | 28 | ## Security-related information 29 | 30 | We will provide security related information such as a threat model, considerations 31 | for secure use, or any known security issues in our documentation. Please note 32 | that labs and sample code are intended to demonstrate a concept and may not be 33 | sufficiently hardened for production use. 34 | 35 | [1]: mailto:secalert_us@oracle.com 36 | [2]: https://www.oracle.com/corporate/security-practices/assurance/vulnerability/reporting.html 37 | [3]: https://www.oracle.com/security-alerts/encryptionkey.html 38 | [4]: https://www.oracle.com/security-alerts/ 39 | -------------------------------------------------------------------------------- /oled.man: -------------------------------------------------------------------------------- 1 | .TH OLED 8 "Nov 2024" "Oracle Linux Enhanced Diagnostics" 2 | 3 | .SH NAME 4 | oled - Interface to invoke other diagnostic tools 5 | 6 | .SH SYNOPSIS 7 | oled [-h | --help | -v | --version] [sub_command] [options] 8 | 9 | .SH DESCRIPTION 10 | OLED (Oracle Linux Enhanced Diagnostics) is a collection of diagnostic tools 11 | and scripts. The \fBoled\fR command is used to invoke these other tools/scripts. 12 | See usage below, for available options. 13 | 14 | .TP 15 | # oled --help 16 | usage: oled {-h | -v | COMMAND [ARGS]} 17 | 18 | Valid commands: 19 | lkce -- Linux Kernel Core Extractor 20 | memstate -- Capture and analyze memory usage statistics 21 | kstack -- Gather kernel stack based on the process status or PID 22 | syswatch -- Execute user-provided commands based on the CPU utilization 23 | scanfs -- Scan KVM images for corruption, supports XFS and EXT4 24 | vmcore_sz -- Estimating vmcore size before kernel dump 25 | 26 | optional arguments: 27 | -h, --help show this help message and exit 28 | -v, --version show program's version number and exit 29 | 30 | NOTE: Must run as root. 31 | 32 | Please check the man page of each sub-command to learn more about that tool and 33 | its usage. 34 | 35 | .SH EXAMPLES 36 | .TP 37 | 38 | # oled memstate -h 39 | usage: oled memstate [-h] [-p [PID]] [-s [FILE]] [-n [FILE]] [-a] [-v] 40 | [-f [INTERVAL]] 41 | 42 | memstate: Capture and analyze memory usage data on this system. 43 | 44 | optional arguments: 45 | -h, --help show this help message and exit 46 | -p [PID], --pss [PID] 47 | display per-process memory usage 48 | -s [FILE], --slab [FILE] 49 | analyze/display slab usage 50 | -n [FILE], --numa [FILE] 51 | analyze/display NUMA stats 52 | -a, --all display all data 53 | -v, --verbose verbose data capture; combine with other options 54 | -f [INTERVAL], --frequency [INTERVAL] 55 | interval at which data should be collected (default: 56 | 30s) 57 | 58 | .SH REPORTING BUGS 59 | .TP 60 | Please contact Oracle Linux Support to report any bugs for OLED tools. 61 | -------------------------------------------------------------------------------- /oled.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright (c) 2023, Oracle and/or its affiliates. 4 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 | # 6 | # This code is free software; you can redistribute it and/or modify it 7 | # under the terms of the GNU General Public License version 2 only, as 8 | # published by the Free Software Foundation. 9 | # 10 | # This code is distributed in the hope that it will be useful, but WITHOUT 11 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | # version 2 for more details (a copy is included in the LICENSE file that 14 | # accompanied this code). 15 | # 16 | # You should have received a copy of the GNU General Public License version 17 | # 2 along with this work; if not, see . 18 | # 19 | # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 | # or visit www.oracle.com if you need additional information or have any 21 | # questions. 22 | """oled-tools driver""" 23 | 24 | import argparse 25 | import sys 26 | import os 27 | from typing import Sequence 28 | 29 | # Oracle Linux Enhanced Diagnostic Tools 30 | MAJOR = "0" 31 | MINOR = "7" 32 | 33 | BINDIR = "/usr/libexec/oled-tools" 34 | 35 | # Valid oled subcomands 36 | OLED_CMDS = ( 37 | "kstack", "lkce", "memstate", "syswatch", "scanfs", "vmcore_sz") 38 | 39 | 40 | def parse_args(args: Sequence[str]) -> argparse.Namespace: 41 | """Parse CLI arguments.""" 42 | parser = argparse.ArgumentParser( 43 | formatter_class=argparse.RawDescriptionHelpFormatter, 44 | usage="%(prog)s {-h | -v | COMMAND [ARGS]}", 45 | description="""\ 46 | Valid commands: 47 | lkce -- Linux Kernel Core Extractor 48 | memstate -- Capture and analyze memory usage statistics 49 | kstack -- Gather kernel stack based on the process status or PID 50 | syswatch -- Execute user-provided commands based on the CPU utilization 51 | scanfs -- Scan KVM images for corruption, supports XFS and EXT4 52 | vmcore_sz -- Estimating vmcore size before kernel dump 53 | """, 54 | epilog="NOTE: Must run as root.") 55 | 56 | parser.add_argument( 57 | "-v", "--version", action="version", 58 | version=( 59 | f"Oracle Linux Enhanced Diagnostics (oled) v{MAJOR}.{MINOR} " 60 | "(developer preview release)")) 61 | parser.add_argument( 62 | "command", metavar="COMMAND", choices=OLED_CMDS, 63 | help=argparse.SUPPRESS) 64 | parser.add_argument( 65 | "args", metavar="ARGS", nargs=argparse.REMAINDER, 66 | help=argparse.SUPPRESS) 67 | 68 | return parser.parse_args(args) 69 | 70 | 71 | def main(args: Sequence[str]) -> None: 72 | """Main function.""" 73 | 74 | options = parse_args(args) 75 | 76 | # only allow root to execute subcommands 77 | if os.getuid() != 0: 78 | print("Run as root only", file=sys.stderr) 79 | sys.exit(1) 80 | 81 | cmd = options.command 82 | 83 | exec_path = os.path.join(BINDIR, cmd) 84 | prog_name = f"oled-{cmd}" 85 | exec_args = [prog_name] + options.args 86 | 87 | try: 88 | os.execv(exec_path, exec_args) # nosec 89 | except Exception: 90 | print(f"Error executing: {exec_path} {exec_args}", file=sys.stderr) 91 | raise 92 | 93 | 94 | if __name__ == "__main__": 95 | main(sys.argv[1:]) 96 | -------------------------------------------------------------------------------- /sbom_generation.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. 2 | 3 | # This OCI DevOps build specification file [1] generates a Software Bill of Materials (SBOM) of the repository. 4 | # The file is needed to run checks for third-party vulnerabilities and business approval according to Oracle’s GitHub policies. 5 | # [1] https://docs.oracle.com/en-us/iaas/Content/devops/using/build_specs.htm 6 | 7 | version: 0.1 8 | component: build 9 | timeoutInSeconds: 1000 10 | shell: bash 11 | env: 12 | variables: 13 | PYTHON_CMD: "python3" 14 | CDXGEN_DEBUG_MODE: "debug" 15 | steps: 16 | - type: Command 17 | name: "Download the version 10.10.0 of cdxgen globally" 18 | command: | 19 | npm install -g @cyclonedx/cdxgen@10.10.0 20 | - type: Command 21 | name: "Workaround to let cdxgen run on nodejs 16" 22 | command: | 23 | # cdxgen relies on a fourth-party dependency that cannot be executed in a Node.js environment running version 16 24 | # (as installed on the build runner instance) 25 | # This is a workaround to ensure cdxgen functions correctly, even in an older Node.js environment. 26 | cd /node/node-v16.14.2-linux-x64/lib/node_modules/@cyclonedx/cdxgen && \ 27 | npm install cheerio@v1.0.0-rc.12 28 | - type: Command 29 | name: "Generate SBOM for Python " 30 | command: | 31 | # Search the test or dev requirements files, so that test and dev py packages can be excluded in the generated SBOM 32 | files=$(find . -type f -regex ".*\(test.*requirements\|requirements.*test\|dev.*requirements\|requirements.*dev\).*\.txt") && \ 33 | if [ -n "$files" ]; then \ 34 | cdxgen -t python -o artifactSBOM.json --spec-version 1.4 \ 35 | --exclude "*{requirements,dev,test}*{requirements,dev,test}*.txt" --project-name "$(basename $OCI_PRIMARY_SOURCE_URL)" --no-recurse 36 | else \ 37 | cdxgen -t python -o artifactSBOM.json --spec-version 1.4 --project-name "$(basename $OCI_PRIMARY_SOURCE_URL)" --no-recurse 38 | fi \ 39 | outputArtifacts: 40 | - name: artifactSBOM 41 | type: BINARY 42 | location: ${OCI_PRIMARY_SOURCE_DIR}/artifactSBOM.json -------------------------------------------------------------------------------- /scripts/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020, Oracle and/or its affiliates. 2 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 | # 4 | # This code is free software; you can redistribute it and/or modify it 5 | # under the terms of the GNU General Public License version 2 only, as 6 | # published by the Free Software Foundation. 7 | # 8 | # This code is distributed in the hope that it will be useful, but WITHOUT 9 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11 | # version 2 for more details (a copy is included in the LICENSE file that 12 | # accompanied this code). 13 | # 14 | # You should have received a copy of the GNU General Public License version 15 | # 2 along with this work; if not, see . 16 | # 17 | # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 18 | # or visit www.oracle.com if you need additional information or have any 19 | # questions. 20 | 21 | SCRIPTSDIR := $(BINDIR)/scripts 22 | DOCSDIR := $(BINDIR)/scripts/docs 23 | 24 | all: 25 | @echo "all:$(CURDIR)" 26 | 27 | clean: 28 | @echo "clean:$(CURDIR)" 29 | 30 | install: 31 | @echo "install:$(CURDIR)" 32 | mkdir -p $(SCRIPTSDIR) 33 | mkdir -p $(DOCSDIR) 34 | #net 35 | install -m 755 $(CURDIR)/net/arp_origin.d $(SCRIPTSDIR) 36 | install -m 755 $(CURDIR)/net/arp_origin_example.txt $(DOCSDIR) 37 | install -m 755 $(CURDIR)/net/rds_bcopy_metric.d $(SCRIPTSDIR) 38 | install -m 755 $(CURDIR)/net/rds_bcopy_metric_example.txt $(DOCSDIR) 39 | install -m 755 $(CURDIR)/net/rds_check_tx_stall.d $(SCRIPTSDIR) 40 | install -m 755 $(CURDIR)/net/rds_check_tx_stall_example.txt $(DOCSDIR) 41 | install -m 755 $(CURDIR)/net/rds_conn2irq.d $(SCRIPTSDIR) 42 | install -m 755 $(CURDIR)/net/rds_conn2irq_example.txt $(DOCSDIR) 43 | install -m 755 $(CURDIR)/net/rds_egress_TP.d $(SCRIPTSDIR) 44 | install -m 755 $(CURDIR)/net/rds_egress_TP_example.txt $(DOCSDIR) 45 | install -m 755 $(CURDIR)/net/rds_rdma_lat.d $(SCRIPTSDIR) 46 | install -m 755 $(CURDIR)/net/rds_rdma_lat_example.txt $(DOCSDIR) 47 | install -m 755 $(CURDIR)/net/rds_rdma_xfer_rate.d $(SCRIPTSDIR) 48 | install -m 755 $(CURDIR)/net/rds_rdma_xfer_rate_example.txt $(DOCSDIR) 49 | install -m 755 $(CURDIR)/net/rds_tx_funccount.d $(SCRIPTSDIR) 50 | install -m 755 $(CURDIR)/net/rds_tx_funccount_example.txt $(DOCSDIR) 51 | install -m 755 $(CURDIR)/net/ping_lat.d $(SCRIPTSDIR) 52 | install -m 755 $(CURDIR)/net/ping_lat_example.txt $(DOCSDIR) 53 | #io 54 | install -m 755 $(CURDIR)/io/nvme_io_comp.d $(SCRIPTSDIR) 55 | install -m 755 $(CURDIR)/io/nvme_io_comp_example.txt $(DOCSDIR) 56 | install -m 755 $(CURDIR)/io/scsi_latency.d $(SCRIPTSDIR) 57 | install -m 755 $(CURDIR)/io/scsi_latency_example.txt $(DOCSDIR) 58 | install -m 755 $(CURDIR)/io/scsi_queue.d $(SCRIPTSDIR) 59 | install -m 755 $(CURDIR)/io/scsi_queue_example.txt $(DOCSDIR) 60 | #core 61 | install -m 755 $(CURDIR)/core/spinlock_time.d $(SCRIPTSDIR) 62 | install -m 755 $(CURDIR)/core/spinlock_time_example.txt $(DOCSDIR) 63 | @echo "scripts successfully installed" 64 | 65 | uninstall: 66 | @echo "uninstall:$(CURDIR)" 67 | rm -rf $(SCRIPTSDIR) 68 | rm -rf $(DOCSDIR) 69 | @echo "scripts successfully uninstalled" 70 | -------------------------------------------------------------------------------- /scripts/core/spinlock_time.d: -------------------------------------------------------------------------------- 1 | #!/usr/sbin/dtrace -Cqs 2 | 3 | /* 4 | * Copyright (c) 2023, Oracle and/or its affiliates. 5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 | * 7 | * This code is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License version 2 only, as 9 | * published by the Free Software Foundation. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, see . 19 | * 20 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 | * or visit www.oracle.com if you need additional information or have any 22 | * questions. 23 | */ 24 | 25 | /* 26 | * Author(s): Rama Nichanamatlu, Arumugam Kolappan 27 | * Purpose: Track 'the time interrupt is disabled' due to spin_lock_irq*() 28 | * kernel functions. Takes an argument[holdtime in ms] and prints the process 29 | * (and its call stack) which disables interrupt more than the given time. 30 | * Argument: Time in ms (Minimum value is 2) 31 | * 32 | * Start Bug: 32080059 33 | * Prerequisites: Refer to the file spinlock_time_example.txt 34 | * Sample output: Refer to the file spinlock_time_example.txt 35 | */ 36 | 37 | #define DT_VERSION_NUMBER_(M, m, u) \ 38 | ((((M) & 0xFF) << 24) | (((m) & 0xFFF) << 12) | ((u) & 0xFFF)) 39 | 40 | #if __SUNW_D_VERSION >= DT_VERSION_NUMBER_(2,0,0) 41 | #pragma D option lockmem=unlimited 42 | #endif 43 | 44 | #pragma D option cleanrate=50hz 45 | #pragma D option dynvarsize=16000000 46 | #pragma D option bufsize=16m 47 | 48 | dtrace:::BEGIN 49 | / $1 < 2 / 50 | { 51 | printf("Error: Argument should be >= 2 ms [%Y]\n", walltimestamp); 52 | exit(0); 53 | } 54 | 55 | dtrace:::BEGIN 56 | { 57 | printf("Processes holding spinlock_irq longer than %d ms [%Y]\n", $1, walltimestamp); 58 | printf("----------------------------------------------------------------------\n"); 59 | hold_time = $1 * 1000 * 1000; 60 | } 61 | 62 | /* 63 | * Use cpu number along with lock_pointer in the hash key (time[arg0, cpu]) to 64 | * handle the scenario: Second cpu acquires a lock before release_probe is fired 65 | * after first cpu unlocked it. 66 | */ 67 | lockstat:vmlinux:*spin_lock_irq*:spin-acquire 68 | { 69 | time[arg0, cpu] = timestamp; 70 | } 71 | 72 | lockstat:vmlinux:*:spin-release 73 | / time[arg0, cpu] && (this->nsec = timestamp - time[arg0, cpu]) >= hold_time / 74 | { 75 | printf("\n[%Y] time=%d ms lock=%p pid=%d cpu=%d cmd=%s\n", 76 | walltimestamp, this->nsec/1000000, 77 | arg0, pid, cpu, curthread->comm); 78 | stack(); 79 | time[arg0, cpu] = 0; 80 | 81 | /* Resetting the clause variable 'this->nsec' seems helping to avoid 82 | * 'dynamic variable drops with non-empty dirty list' 83 | * with Oracle Linux DTrace 1.0 84 | */ 85 | this->nsec = 0; 86 | } 87 | 88 | lockstat:vmlinux:*:spin-release 89 | / time[arg0, cpu] / 90 | { 91 | time[arg0, cpu] = 0; 92 | this->nsec = 0; 93 | } 94 | -------------------------------------------------------------------------------- /scripts/core/spinlock_time_example.txt: -------------------------------------------------------------------------------- 1 | Purpose: Track 'the time interrupt is disabled' due to spin_lock_irq*() 2 | kernel functions. Takes an argument[holdtime in ms] and prints the process 3 | (and its call stack) which disables interrupt more than the given time. 4 | 5 | Argument: Time in ms (Minimum value is 2) 6 | 7 | Output format: 8 | time= ms lock= pid= cpu= cmd= 9 | followed by stack dump 10 | 11 | Sample output: Shown below. 12 | 13 | # ./spinlock_time.d 1 14 | Error: Argument should be >= 2 ( millisec) [2023 Jan 18 10:15:38] 15 | 16 | 17 | # ./spinlock_time.d 2 18 | Processes holding spinlock_irq longer than 2 ms [2023 Jan 18 10:21:28] 19 | ---------------------------------------------------------------------- 20 | 21 | [2023 Jan 18 10:21:32] time=2 ms lock=ffffc41bff5083a0 pid=28352 cpu=39 cmd=osysmond.bin 22 | 23 | vmlinux`do_invalid_op+0x20 24 | vmlinux`invalid_op+0x11a 25 | vmlinux`_raw_spin_unlock_irqrestore+0x14 26 | iova`fq_flush_timeout+0x66 27 | vmlinux`call_timer_fn+0x3c 28 | vmlinux`run_timer_softirq+0x209 29 | vmlinux`__do_softirq+0xe1 30 | vmlinux`irq_exit+0xf6 31 | vmlinux`smp_apic_timer_interrupt+0x91 32 | vmlinux`apic_timer_interrupt+0x1c6 33 | vmlinux`__raw_spin_unlock+0x10 34 | vmlinux`dput+0xc9 35 | vmlinux`proc_fill_cache+0x81 36 | vmlinux`proc_readfd_common+0xe8 37 | vmlinux`proc_readfd+0x15 38 | vmlinux`iterate_dir+0x98 39 | vmlinux`SyS_getdents+0x98 40 | vmlinux`do_syscall_64+0x79 41 | vmlinux`entry_SYSCALL_64+0x191 42 | 43 | -------------------------------------------------------------------------------- /scripts/io/nvme_io_comp.d: -------------------------------------------------------------------------------- 1 | #!/usr/sbin/dtrace -qs 2 | 3 | /* 4 | * Copyright (c) 2024, Oracle and/or its affiliates. 5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 | * 7 | * This code is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License version 2 only, as 9 | * published by the Free Software Foundation. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, see . 19 | * 20 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 | * or visit www.oracle.com if you need additional information or have any 22 | * questions. 23 | * 24 | * Author(s): Rajan Shanmugavelu 25 | * Purpose: to measure nvme IO latency in microseconds (us). 26 | * The script requires 2 arguments: 27 | * - the reporting period (in secs) for latency 28 | * - the reporting period (in secs) for command completion 29 | * The DTrace 'fbt' and 'profile' modules need to be loaded 30 | * ('modprobe -a fbt profile') for UEK5. 31 | * Sample output: Refer to the file nvme_io_comp_example.txt 32 | */ 33 | 34 | #pragma D option dynvarsize=100m 35 | #pragma D option strsize=25 36 | 37 | string ncmd[uchar_t]; 38 | string stat[ushort_t]; 39 | 40 | dtrace:::BEGIN 41 | { 42 | printf("%d is latency interval, %d is cmd comp interval\n", $1, $2); 43 | 44 | ncmd[0x00] = "FLUSH"; 45 | ncmd[0x01] = "WRITE"; 46 | ncmd[0x02] = "READ"; 47 | ncmd[0x04] = "WRITE_UNCOR"; 48 | ncmd[0x05] = "COMPARE"; 49 | ncmd[0x08] = "WRITE_ZEROS"; 50 | ncmd[0x09] = "DSM"; 51 | ncmd[0x0c] = "VERIFY"; 52 | ncmd[0x0d] = "RESV_REG"; 53 | ncmd[0x0e] = "RESV_RPT"; 54 | ncmd[0x11] = "RESV_ACQ"; 55 | ncmd[0x15] = "RESV_REL"; 56 | 57 | stat[0x00] = "Success"; 58 | stat[0x01] = "Invalid Opcode"; 59 | stat[0x02] = "Invalid Field"; 60 | stat[0x03] = "DID Conflict"; 61 | stat[0x04] = "Data Xfer Error"; 62 | stat[0x06] = "Internal Error"; 63 | stat[0x07] = "Abort Request"; 64 | stat[0x08] = "Abort Queue"; 65 | stat[0x83] = "Resv Conflict"; 66 | stat[0x280] = "Write Fault"; 67 | stat[0x281] = "Read Error"; 68 | stat[0x287] = "Unwritten Block"; 69 | 70 | printf("Tracing... Hit Ctrl-C to end.\n"); 71 | } 72 | 73 | ::nvme_setup_cmd:entry 74 | { 75 | this->req = (struct request *) arg1; 76 | (this->req->rq_disk != NULL) ? cmnd[this->req] = (struct nvme_command *)arg2 : 0; 77 | (this->req->rq_disk != NULL) ? nvme_req_starttime[this->req] = timestamp : 0; 78 | } 79 | 80 | ::nvme_complete_rq:entry 81 | / this->start = (int64_t) (nvme_req_starttime[(struct request *) arg0]) / 82 | { 83 | this->comp_req = (struct request *) arg0; 84 | this->nvme_cmd = (struct nvme_command *) cmnd[this->comp_req]; 85 | this->comp_diskname = stringof(this->comp_req->rq_disk->disk_name); 86 | this->opcode = (uint8_t) this->nvme_cmd->rw.opcode & 0xff; 87 | this->nvme_req = (struct nvme_request *) (this->comp_req + 1); 88 | this->nvme_req_stat = (uint16_t) (this->nvme_req->status & 0x7ff); 89 | @opcount[this->comp_diskname, ncmd[this->opcode], 90 | stat[this->nvme_req_stat]] = count(); 91 | @lat_time[this->comp_diskname] = quantize((timestamp - this->start) / 1000); 92 | cmnd[this->comp_req] = NULL; 93 | nvme_req_starttime[this->comp_req] = 0; 94 | } 95 | 96 | tick-$1s, END 97 | { 98 | printf("\n\tSample Time : %-25Y\n", walltimestamp); 99 | printf("\t========================================================\n"); 100 | printa("\t\t%s %@5u\t(us)\n", @lat_time); 101 | printf("\t========================================================\n"); 102 | clear(@lat_time); 103 | } 104 | 105 | tick-$2s, END 106 | { 107 | printf("\n\tSample Time : %-25Y\n", walltimestamp); 108 | printf("\t=======================================================\n"); 109 | printf("\tDevice\t Command\t Status\t\tCount\n"); 110 | printf("\t=======================================================\n"); 111 | printa("\t%s %-12s %-20s %@d\n", @opcount); 112 | printf("\t=======================================================\n"); 113 | clear(@opcount); 114 | } 115 | -------------------------------------------------------------------------------- /scripts/io/nvme_io_comp_example.txt: -------------------------------------------------------------------------------- 1 | Below are sample output, the script gathers nvme IO statistics given a sampling 2 | interval and displays the summary ouptut in histogram format. The script takes 3 | 2 arguments, the first argument is sampling interval in seconds for latency, 4 | the second argument is interval time in seconds for summary of command completion counts. 5 | 6 | The left column of the histogram 'value' output is the latency time in microseconds 7 | and the right 'count' are the number of IO commands completed. 8 | 9 | # ./nvme-io-comp2.d 10 | dtrace: failed to compile script ./nvme-io-comp2.d: line 15: macro argument $2 is not defined 11 | 12 | # ./nvme-io-comp2.d 2 2 13 | Tracing... Hit Ctrl-C to end. 14 | 15 | Sample Time : 2022 Oct 26 12:03:32 16 | ======================================================== 17 | nvme0n1 18 | value ------------- Distribution ------------- count 19 | 4 | 0 20 | 8 |@@@ 1868 21 | 16 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 21266 22 | 32 |@@@@ 2777 23 | 64 |@ 829 24 | 128 |@ 615 25 | 256 | 215 26 | 512 | 17 27 | 1024 | 21 28 | 2048 | 12 29 | 4096 | 0 30 | (us) 31 | ======================================================== 32 | 33 | Sample Time : 2022 Oct 26 12:03:32 34 | ======================================================= 35 | Device Command Status Count 36 | ======================================================= 37 | nvme0n1 FLUSH Success 143 38 | nvme0n1 Success 360 <- NvME admin cmds 39 | nvme0n1 WRITE Success 13548 40 | nvme0n1 READ Success 13569 41 | ======================================================= 42 | 43 | Upon fault Injection. 44 | 45 | Sample Time : 2022 Oct 26 12:04:16 46 | ======================================================== 47 | nvme0n1 48 | value ------------- Distribution ------------- count 49 | 4 | 0 50 | 8 |@@@ 1999 51 | 16 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 19991 52 | 32 |@@@@ 2830 53 | 64 |@ 701 54 | 128 |@ 525 55 | 256 | 193 56 | 512 | 18 57 | 1024 | 30 58 | 2048 | 9 59 | 4096 | 3 60 | 8192 | 0 61 | 16384 | 0 62 | 32768 | 2 63 | 65536 | 0 64 | (us) 65 | ======================================================== 66 | 67 | Sample Time : 2022 Oct 26 12:04:16 68 | ======================================================= 69 | Device Command Status Count 70 | ======================================================= 71 | nvme0n1 DSM Success 0 72 | nvme0n1 RESV_ACQ Success 0 73 | nvme0n1 RESV_REG Success 0 74 | nvme0n1 RESV_REL Success 0 75 | nvme0n1 RESV_RPT Success 0 76 | nvme0n1 VERIFY Success 0 77 | nvme0n1 WRITE_UNCOR Success 0 78 | nvme0n1 WRITE_ZEROS Success 0 79 | nvme0n1 WRITE Invalid Opcode 1 80 | nvme0n1 READ Invalid Opcode 2 81 | nvme0n1 COMPARE Success 5 82 | nvme0n1 FLUSH Success 105 83 | nvme0n1 Success 357 <- NvME admin cmds 84 | nvme0n1 READ Success 12754 85 | nvme0n1 WRITE Success 13077 86 | ======================================================= 87 | 88 | 89 | -------------------------------------------------------------------------------- /scripts/io/scsi_latency.d: -------------------------------------------------------------------------------- 1 | #!/usr/sbin/dtrace -qs 2 | 3 | /* 4 | * Copyright (c) 2024, Oracle and/or its affiliates. 5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 | * 7 | * This code is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License version 2 only, as 9 | * published by the Free Software Foundation. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, see . 19 | * 20 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 | * or visit www.oracle.com if you need additional information or have any 22 | * questions. 23 | * 24 | * 25 | * Author(s): Rajan Shanmugavelu 26 | * Purpose: to measure SCSI Mid Layer IO latency in milliseconds (ms) and 27 | * to measure QLogic adapter layer IO latency in milliseconds(ms). 28 | * The script requires 1 arguments: 29 | * - the reporting period (in secs) for latency 30 | * The DTrace 'fbt' and 'profile' modules need to be loaded 31 | * ('modprobe -a fbt profile') for UEK5. 32 | * Sample output: Refer to the file scsi_latency_example.txt 33 | */ 34 | 35 | #pragma D option dynvarsize=100m 36 | #pragma D option strsize=25 37 | 38 | string opcode[ushort_t]; 39 | 40 | BEGIN 41 | { 42 | printf("Running %s with %d seconds interval\n", $0, $1); 43 | opcode[0x00] = "TUR"; 44 | opcode[0x08] = "Read(6)"; 45 | opcode[0x0a] = "Write(6)"; 46 | opcode[0x12] = "Inquiry"; 47 | opcode[0x25] = "Read Cap(10)"; 48 | opcode[0x28] = "Read(10)"; 49 | opcode[0x2a] = "Write(10)"; 50 | opcode[0x5e] = "Pers Resv In"; 51 | opcode[0xa0] = "Report Luns"; 52 | opcode[0xa3] = "Maint In"; 53 | 54 | printf("Hit Ctrl-C to quit...\n"); 55 | } 56 | 57 | ::scsi_dispatch_cmd_start 58 | { 59 | this->cmnd = (struct scsi_cmnd *) arg0; 60 | scsistarttime[this->cmnd] = timestamp; 61 | } 62 | 63 | fbt::scsi_done:entry, 64 | fbt::scsi_mq_done:entry 65 | / scsistarttime[(this->scsi_cmnd = (struct scsi_cmnd *) arg0)] / 66 | { 67 | this->opcode = this->scsi_cmnd->cmnd[0]; 68 | this->status = stringof((this->scsi_cmnd->result == 0) ? "Success" : "Failed"); 69 | this->start = (int64_t) scsistarttime[this->scsi_cmnd]; 70 | this->elasped = ((timestamp - this->start) / 1000000); 71 | @cmd_count[opcode[this->opcode], this->opcode, this->status] = count(); 72 | @lat[opcode[this->opcode], this->status] = quantize(this->elasped); 73 | scsistarttime[this->scsi_cmnd] = 0; 74 | } 75 | 76 | fbt::qla2xxx_queuecommand:entry 77 | { 78 | this->qla_cmd = (struct scsi_cmnd *)arg1; 79 | qla_starttime[this->qla_cmd] = timestamp; 80 | } 81 | 82 | fbt::qla2x00_sp_compl:entry 83 | / qla_starttime[(this->qla_comp_cmd = (struct scsi_cmnd *) ((srb_t *)arg0)->u.scmd.cmd)] / 84 | { 85 | this->qla_opcode = this->qla_comp_cmd->cmnd[0]; 86 | this->status = stringof((this->qla_comp_cmd->result == 0) ? "Success" : "Failed"); 87 | this->qla_start = (int64_t) qla_starttime[this->qla_comp_cmd]; 88 | this->qla_elapsed = (timestamp - this->qla_start) / 1000000; 89 | @qla_lat[opcode[this->qla_opcode], this->status] = quantize(this->qla_elapsed); 90 | qla_starttime[this->qla_comp_cmd] = 0; 91 | } 92 | 93 | 94 | END, 95 | tick-$1s 96 | { 97 | printf("\n Sample Time : %-25Y SCSI Mid layer latency\n", walltimestamp); 98 | printf("========================================================\n"); 99 | printa(" %-36s %-5s %@d \t(ms)\n ", @lat); 100 | printf("========================================================\n"); 101 | printf("\n Sample Time : %-25Y\n", walltimestamp); 102 | printf(" =============================================================\n"); 103 | printf(" Command OpCode Status Count\n"); 104 | printf(" =============================================================\n"); 105 | printa(" %-10s 0x%-2x %-10s %@d\n", @cmd_count); 106 | printf(" =============================================================\n"); 107 | printf("\n Sample Time : %-25Y Latency at Qlogic Adapter layer\n", walltimestamp); 108 | printf("========================================================\n"); 109 | printa(" %-36s %-5d %@d \t(ms)\n ", @qla_lat); 110 | printf("========================================================\n"); 111 | clear(@lat); 112 | clear(@cmd_count); 113 | clear(@qla_lat); 114 | } 115 | -------------------------------------------------------------------------------- /scripts/io/scsi_latency_example.txt: -------------------------------------------------------------------------------- 1 | Below are sample output, the script gathers SCSI IO statistics given a sampling 2 | interval and displays the summary ouptut in histogram format. The script takes 3 | 2 arguments, the first argument is sampling interval in seconds for latency, 4 | the second argument is latency threshold time in milli-seconds for IO completion. 5 | 6 | The left column of the histogram 'value' output is the latency time in milli-seconds 7 | and the right 'count' are the number of IO commands completed. 8 | 9 | # scsi-latency.d 5 1 (5 being sample interval, and 1 is threshold for IO completion in ms). 10 | sdbz 11 | value ------------- Distribution ------------- count 12 | -1 | 0 13 | 0 |@@@@@@@@@@@@@@@@@@@@@@ 16616 14 | 1 |@@@@@@@@@@@@@@@@ 12411 15 | 2 |@@ 1479 16 | 4 | 229 17 | 8 | 10 18 | 16 | 0 19 | (ms) 20 | sdef 21 | value ------------- Distribution ------------- count 22 | -1 | 0 23 | 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@ 29766 24 | 1 |@@@@@@@@@@@@ 14042 25 | 2 |@ 1073 26 | 4 | 186 27 | 8 | 2 28 | 16 | 0 29 | (ms) 30 | 31 | Below is a sample of abnormally higher latency of IO completion. 32 | 33 | # scsi-latency.d 5 50 34 | 2022 Oct 21 15:49:16 35 | ======================================================= 36 | sddb 7:0:2:229 37 | value ------------- Distribution ------------- count 38 | -1 | 0 39 | 0 |@@ 2 40 | 1 | 0 41 | 2 |@@@@@ 5 42 | 4 |@ 1 43 | 8 |@@ 2 44 | 16 | 0 45 | 32 | 0 46 | 64 | 0 47 | 128 | 0 48 | 256 | 0 49 | 512 | 0 50 | 1024 | 0 51 | 2048 | 0 52 | 4096 | 0 53 | 8192 | 0 54 | 16384 |@@@@@@@@@@@@@@@@@@@@@ 20 55 | 32768 |@@@@@@@@@ 9 56 | 65536 | 0 57 | (ms) 58 | ======================================================== 59 | 60 | -------------------------------------------------------------------------------- /scripts/io/scsi_queue.d: -------------------------------------------------------------------------------- 1 | #!/usr/sbin/dtrace -qs 2 | 3 | /* 4 | * Copyright (c) 2024, Oracle and/or its affiliates. 5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 | * 7 | * This code is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License version 2 only, as 9 | * published by the Free Software Foundation. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, see . 19 | * 20 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 | * or visit www.oracle.com if you need additional information or have any 22 | * questions. 23 | * 24 | * Author(s): Rajan Shanmugavelu 25 | * Purpose: to measure SCSI IO queue time in milliseconds (ms). 26 | * 27 | * The DTrace 'fbt' and 'profile' modules need to be loaded 28 | * ('modprobe -a fbt profile') for UEK5. 29 | * Sample output: Refer to the file scsi_queue_example.txt 30 | */ 31 | 32 | #pragma D option dynvarsize=100m 33 | #pragma D option strsize=25 34 | 35 | dtrace:::BEGIN 36 | { 37 | printf("Tracing... Hit Ctrl-C to end.\n"); 38 | } 39 | 40 | fbt::scsi_queue_insert:entry 41 | { 42 | start_time[arg0] = timestamp; 43 | } 44 | 45 | ::scsi_dispatch_cmd_start 46 | /this->start = start_time[arg0]/ 47 | { 48 | this->elapsed = (timestamp - this->start) / 1000; 49 | this->cmd = (struct scsi_cmnd *) arg0; 50 | this->scsi_device = (struct scsi_device *)this->cmd->device; 51 | this->device = (struct device) this->scsi_device->sdev_gendev; 52 | this->sd = stringof(this->cmd->request->rq_disk->disk_name); 53 | this->dev_name = stringof(this->device.kobj.name); 54 | 55 | @avg[this->sd, this->dev_name] = avg(this->elapsed/1000); 56 | @plot[this->sd, this->dev_name] = lquantize(this->elapsed / 1000, 0, 1000, 100); 57 | 58 | start_time[arg0] = 0; 59 | } 60 | 61 | dtrace:::END 62 | { 63 | printf("%Y", walltimestamp); 64 | printf("Wait queue time by disk (ms):\n"); 65 | printa("\n %-12s %-20s\n%@d", @plot); 66 | printf("\n\n %-12s %-20s %12s\n", "DEVICE", "NAME", "AVG_WAIT(us)"); 67 | printa(" %-12s %-20s %@12d\n", @avg); 68 | } 69 | 70 | -------------------------------------------------------------------------------- /scripts/net/arp_origin.d: -------------------------------------------------------------------------------- 1 | #!/usr/sbin/dtrace -Cqs 2 | 3 | /* 4 | * Copyright (c) 2022, Oracle and/or its affiliates. 5 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6 | * 7 | * This code is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License version 2 only, as 9 | * published by the Free Software Foundation. 10 | * 11 | * This code is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * version 2 for more details (a copy is included in the LICENSE file that 15 | * accompanied this code). 16 | * 17 | * You should have received a copy of the GNU General Public License version 18 | * 2 along with this work; if not, see . 19 | * 20 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 | * or visit www.oracle.com if you need additional information or have any 22 | * questions. 23 | */ 24 | 25 | /* 26 | * Author(s): Rama Nichanamatlu, Praveen Kumar Kannoju. 27 | * Purpose: This script detects and prints the details of all ARP requests, 28 | * replies, and ignored packets on all the network interfaces present on the 29 | * system where this script is being executed. 30 | * Prerequisites: Refer to the file arp_origin_example.txt 31 | * Sample output: Refer to the file arp_origin_example.txt 32 | */ 33 | 34 | #define DT_VERSION_NUMBER_(M, m, u) \ 35 | ((((M) & 0xFF) << 24) | (((m) & 0xFFF) << 12) | ((u) & 0xFFF)) 36 | 37 | #if __SUNW_D_VERSION >= DT_VERSION_NUMBER_(2,0,0) 38 | #pragma D option lockmem=unlimited 39 | #endif 40 | 41 | #define arp_protocol 0x0806 42 | #define arp_request_opcode 1 43 | #define arp_reply_opcode 2 44 | 45 | fbt:vmlinux:__dev_queue_xmit:entry 46 | / 47 | ntohs(((struct sk_buff *)arg0)->protocol) == arp_protocol && 48 | (this->arphdr = ((struct arphdr *)(((struct sk_buff *)arg0)->head + ((struct sk_buff *)arg0)->network_header))) && 49 | ntohs(this->arphdr->ar_op) == arp_request_opcode 50 | / 51 | { 52 | this->dev = ((struct net_device *) ((struct sk_buff *)arg0)->dev); 53 | this->ip_var = (u64)this->arphdr + sizeof(struct arphr) + this->arphdr->ar_hln + sizeof(this->arphdr->ar_op); 54 | this->sip = (ipaddr_t *)this->ip_var; 55 | this->tip = (ipaddr_t *)(this->ip_var + this->arphdr->ar_pln + this->arphdr->ar_hln); 56 | 57 | printf("%Y %s Send arp request: sip: %s, tip: %s\n", 58 | walltimestamp, this->dev->name, inet_ntoa(this->sip), 59 | inet_ntoa(this->tip)); 60 | } 61 | 62 | fbt:vmlinux:arp_rcv:entry 63 | / 64 | (this->arphdr = ((struct arphdr *)(((struct sk_buff *)arg0)->head + ((struct sk_buff *)arg0)->network_header))) && 65 | ntohs(this->arphdr->ar_op) == arp_reply_opcode 66 | / 67 | { 68 | this->dev = ((struct net_device *) ((struct sk_buff *)arg0)->dev); 69 | this->ip_var = (u64)this->arphdr + sizeof(struct arphr) + this->arphdr->ar_hln + sizeof(this->arphdr->ar_op); 70 | this->sip = (ipaddr_t *)this->ip_var; 71 | this->tip = (ipaddr_t *)(this->ip_var + this->arphdr->ar_pln + this->arphdr->ar_hln); 72 | 73 | printf("%Y %s Recv arp reply sip: %s tip: %s\n", 74 | walltimestamp, this->dev->name, inet_ntoa(this->sip), 75 | inet_ntoa(this->tip)); 76 | } 77 | 78 | fbt:vmlinux:arp_send:entry, 79 | fbt:vmlinux:arp_create:entry 80 | / arg0 == arp_request_opcode || arg0 == arp_reply_opcode / 81 | { 82 | this->tip = (__be32 *)alloca(4); 83 | *(this->tip) = arg2; 84 | this->sip = (__be32 *)alloca(4); 85 | *(this->sip) = arg4; 86 | 87 | printf("%Y %s Send arp %s sip: %s, tip: %s\n", 88 | walltimestamp, ((struct net_device *)arg3)->name, 89 | arg0 == 1 ? "request":arg0 == 2 ? "reply":"unknown", 90 | inet_ntoa((ipaddr_t *)this->sip), 91 | inet_ntoa((ipaddr_t *)this->tip)); 92 | 93 | } 94 | 95 | fbt:vmlinux:arp_ignore:entry 96 | { 97 | self->dev = (struct net_device*)((struct in_device *)arg0)->dev; 98 | self->sip = arg1; 99 | self->tip = arg2; 100 | } 101 | 102 | fbt:vmlinux:arp_ignore:return 103 | / self->dev != NULL / 104 | { 105 | this->tip = (__be32 *)alloca(4); 106 | *(this->tip) = self->tip; 107 | this->sip = (__be32 *)alloca(4); 108 | *(this->sip) = self->sip; 109 | 110 | printf("%Y %s Recv arp request %s sip: %s, tip: %s\n", 111 | walltimestamp, self->dev->name, 112 | arg1 == 1 ? "(Ignoring) " : "", 113 | inet_ntoa((ipaddr_t *)this->sip), 114 | inet_ntoa((ipaddr_t *)this->tip)); 115 | 116 | self->sip = 0; 117 | self->tip = 0; 118 | self->dev = 0; 119 | } 120 | -------------------------------------------------------------------------------- /scripts/net/arp_origin_example.txt: -------------------------------------------------------------------------------- 1 | Purpose: This script detects and prints the details of all ARP requests, 2 | replies, and ignored packets on all the network interfaces present on the 3 | system where this script is being executed. 4 | 5 | Arguments: None. 6 | 7 | Output format: each line lists 8 | 9 |