# BClinux.ctl: Linux Specific Code for Background Collection (Sampling) # $Id: BClinux.ctl,v 1.3 2013/11/05 14:29:10 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/SAMPLE/BClinux.ctl,v 1.3 2013/11/05 14:29:10 RDA Exp $ # # Change History # 20131105 MSC Improve code consistency. =head1 NAME SAMPLE:BClinux - Submodule for Linux-Specific Background Collections =head1 DESCRIPTION This module contains the operating system-specific code for the sampling modules. =cut # Make the module persistent keep $KEEP_BLOCK # Get the calling module var ($MODULE,$FACTOR) = @arg import $TOC,$TOP #------------------------------------------------------------------------------ =head1 CONTRIBUTION TO THE NPRF MODULE Collected information: =over 4 =item o C =item o C =item o C =item o C =item o C =item o C =item o C =item o C =item o C =item o C =item o The last F raw data file if C setting value is true =back =cut if compare('eq',$MODULE,'NPRF') {# Collect the performance information thread {import $FACTOR report iostat call writeCommand('iostat -x 1 1',true,$FACTOR) } thread {import $FACTOR report lsof call writeCommand('lsof -S 2',true,$FACTOR) } thread {import $FACTOR report meminfo call writeFile('/proc/meminfo') } thread {import $FACTOR report mpstat call writeCommand('mpstat -P ALL',true,$FACTOR) } thread {import $FACTOR report netstat call writeCommand('netstat -s',true,$FACTOR) } thread {import $FACTOR report ps call writeCommand('ps -elf',true,$FACTOR) } thread {import $FACTOR report slabinfo call writeFile('/proc/slabinfo') } thread {import $FACTOR report top call writeCommand('top -b -n 1',true,$FACTOR) } thread {import $FACTOR report uptime call writeCommand('uptime',true,$FACTOR) } thread {import $FACTOR report vmstat call writeCommand('vmstat 1 1',true,$FACTOR) } # Get the last sar raw data file if and(${B_SAR_DATA},not(isFiltered())) {var ($fil) = grepDir('/var/log/sa','^sa\d+$','pt') if $fil {data basename($fil) call writeData($fil) } } # Specify the trace route command var \$CMD = $arg[2] var $CMD = 'traceroute -r -F -m1 %s 2>&1' } #------------------------------------------------------------------------------ =head1 CONTRIBUTION TO THE RPRF MODULE Requests kernel information using the following commands: =over 4 =item o C/proc/sysrq-trigger> =item o C/proc/sysrq-trigger> =item o C/proc/sysrq-trigger> =back =cut elsif compare('eq',$MODULE,'RPRF') {# Get kernel information if createBuffer('LOG','R','/var/log/messages') {report sysrq # Execute system requests call command("echo '?' >/proc/sysrq-trigger") sleep 2 call command("echo 't' >/proc/sysrq-trigger") sleep 2 call command("echo 'm' >/proc/sysrq-trigger") sleep 2 call command("echo 'w' >/proc/sysrq-trigger") sleep 2 call command("echo '?' >/proc/sysrq-trigger") sleep 2 # Extract the output from the system log var ($min,$max) = grepBuffer('LOG',' kernel: SysRq : HELP : ','o',-2) if and($min,$max) {# Define a macro to switch to another report macro switch_report {var ($rpt) = @arg if isCreated(true) write '' if $rpt {report $rpt prefix write '' } } # Filter the lines call switch_report('sysrq_t') call setPos('LOG',field(':',0,$min)) while getLine('LOG') {var $lin = chomp(last) # Detect a new report if match($lin,' kernel: SysRq : Show Memory') call switch_report('sysrq_m') elsif match($lin,' kernel: SysRq : Show CPUs') call switch_report('sysrq_w') elsif match($lin,' kernel: SysRq : HELP : ') break # Filter the lines if match($lin,' kernel: ') write replace($lin,'^.* kernel: ') } call switch_report() } # Close the buffer call deleteBuffer('LOG') } } #------------------------------------------------------------------------------ =begin credits =over 14 =item OSwatcher: Carl Davis. =item shtriage: Greg Marsden. =item sys_watcher: John Sobecki. =back =end credits =head1 COPYRIGHT NOTICE Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. =head1 TRADEMARK NOTICE Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. =cut