zoukankan      html  css  js  c++  java
  • Tap into your Linux system with SystemTap

    https://major.io/2010/12/07/tap-into-your-linux-system-with-systemtap/

    One of the most interesting topics I’ve seen so far during my RHCA training at Rackspace this week isSystemTap. In short, SystemTap allows you to dig out a bunch of details about your running system relatively easily. It takes scripts, converts them to C, builds a kernel module, and then runs the code within your script.

    HOLD IT: The steps below are definitely not meant for those who are new to Linux. Utilizing SystemTap on a production system is a bad idea — it can chew up significant resources while it runs and it can also cause a running system to kernel panic if you’re not careful with the packages you install.

    These instructions will work well with Fedora, CentOS and Red Hat Enterprise Linux. Luckily, the SystemTap folks put together some instructions for Debian and Ubuntu as well.

    Before you can start working with SystemTap on your RPM-based distribution, you’ll need to get some prerequisites together:

    WHOA THERE: Ensure that the kernel-devel and kernel-debuginfo* packages that you install via yum match up with your running kernel. If there’s a newer kernel available from your yum repo, yum will pull that one. If it’s been a while since you updated, you’ll either need to upgrade your current kernel to the latest and reboot or you’ll need to hunt down the corresponding kernel-devel and kernel-debuginfo* packages from a repository. Installing the wrong package version can lead to kernel panics. Also, bear in mind that the debuginfo packages are quite large: almost 200MB in Red Hat/CentOS and almost 300MB in Fedora.

    You can’t write the script in just any language. SystemTap uses an odd syntax to get things going:

    Just run the script with stap:

    The systemtap-testsuite package gives you a tubload of extremely handy SystemTap scripts. For example:

    The iotime.stp script dumps out the reads and writes occurring on the system in real time. After starting the script above, I accessed my cacti instance on the server and immediately started seeing some reads as apache began picking up PHP files to parse.

    Consider a situation in which you need to decrease interrupts on a Linux machine. This is vital for laptops and systems that need to remain in low power states. Some might suggest powertop for that, but why not give SystemTap a try?

    On this particular system, it’s pretty obvious that the ethernet interface is causing a lot of interrupts.

    If you want more examples, keep hunting around in the systemtap-testsuite package (remember rpm -ql systemtap-testsuite) or review the giant list of examples on SystemTap’s site.

    Thanks again to Phil Hopkins at Rackspace for giving us a detailed explanation of system profiling during training.

  • 相关阅读:
    Linux开发工具之Makefile(上)
    Linux shell入门基础(八)
    Linux开发工具之gcc
    Linux shell入门基础(七)
    Linux shell入门基础(六)
    Linux shell入门基础(五)
    Linux shell入门基础(四)
    随机洗牌算法
    Windows中查找文件被何进程使用
    哲学家进餐问题解析
  • 原文地址:https://www.cnblogs.com/zengkefu/p/5838377.html
Copyright © 2011-2022 走看看