Sponsored Content
Top Forums Shell Programming and Scripting Shell script for logging cpu and memory usage of a Linux process Post 302806231 by Chubler_XL on Sunday 12th of May 2013 11:27:17 PM
Old 05-13-2013
You were very close with your original script, all you needed was:

Code:
top -b | awk -v redis="$REDIS_PID" -v logstash="$LOGSTASH_PID" '
    $12 ~ redis || $12 ~ logstash {print $1","$9","$10","$12}'

To add time just pass another variable in with the time:

Code:
top -b | awk -v redis="$REDIS_PID" -v logstash="$LOGSTASH_PID" -v logtime="$(date +%T)" '
    $12 ~ redis || $12 ~ logstash {print logtime","$1","$9","$10","$12}'


Last edited by Chubler_XL; 05-13-2013 at 12:31 AM.. Reason: Added details of how to print time
 

10 More Discussions You Might Find Interesting

1. Programming

Monitor CPU usage and Memory Usage

how can i monitor usages of CPU, Memory, Hard disk etc. under SUN Solaries through a c program or java program i want to store that data into database so i can show it graphically thanks in advance (2 Replies)
Discussion started by: Gajanad Bihani
2 Replies

2. UNIX for Dummies Questions & Answers

cpu, memory and virtual memory usage

Hi All, Does anyone know what the best commands in the UNIX command line are for obtaining this info: current CPU usage memory usage virtual memory usage preferably with date and time parameters too? thanks ocelot (4 Replies)
Discussion started by: ocelot
4 Replies

3. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

4. Solaris

current CPU usage, memory usage, disk I/O oid(snmp)

Hi, I want to monitor the current cpu usage, monitor usage , disk I/o and network utlization for solaris using SNMP. I want the oids for above tasks. can you please tell me that Thank you (2 Replies)
Discussion started by: S_venkatesh
2 Replies

5. AIX

How to monitor the IBM AIX server for I/O usage,memory usage,CPU usage,network..?

How to monitor the IBM AIX server for I/O usage, memory usage, CPU usage, network usage, storage usage? (3 Replies)
Discussion started by: laknar
3 Replies

6. UNIX for Advanced & Expert Users

How to find out memory & cpu usage of a process

Hi, By using time command we can determine the execution time of a process or command. bash-2.04$ time ls -l total 0 -rw-r--r-- 1 admin tac 0 Oct 6 04:46 file1 -rw-r--r-- 1 admin tac 0 Oct 6 04:46 file2 real 0m0.002s user 0m0.000s sys 0m0.001s... (5 Replies)
Discussion started by: learn more
5 Replies

7. AIX

How to trace cpu/memory usage for a process

I don't know when the process will start and end, I need write a script to trace it's cpu/memory usage when it is runing. How to write this script? (2 Replies)
Discussion started by: rainbow_bean
2 Replies

8. Shell Programming and Scripting

shell script to alert cpu memory and disk usage help please

Hi all can any one help me to script monitoring CPU load avg when reaches threshold value and disk usage if it exceeds some % tried using awk but when df -h out put is in two different lines awk doesnt work for the particular output in two different line ( output for df -h is in two... (7 Replies)
Discussion started by: robo
7 Replies

9. Shell Programming and Scripting

Script for CPU usage -Linux

Hi all I was wondering if its possible to write a script to keep CPU usage at 90%-95%? for a single cpu linux server? I have a perl script I run on servers with multple cpu's and all I do is max all but one cpu to get into the 90'% utilised area. I now need a script that raises the CPU to... (4 Replies)
Discussion started by: sudobash
4 Replies

10. Shell Programming and Scripting

Help with Shell script that monitors CPU Usage

I'm a newbie to shell scripting, I was given this script to modify. This script that monitors when CPU Usage is too high based off the top command. The comparison is not working as it should. Its comparing a decimal to a regualar interger. When it send me an email, it send an email and ignores the... (21 Replies)
Discussion started by: mhannor
21 Replies
Test::Mock::Redis(3pm)					User Contributed Perl Documentation				    Test::Mock::Redis(3pm)

NAME
Test::Mock::Redis - use in place of Redis for unit testing VERSION
Version 0.08 SYNOPSIS
Test::Mock::Redis can be used in place of Redis for running tests without needing a running redis instance. use Test::Mock::Redis; my $redis = Test::Mock::Redis->new(server => 'whatever'); $redis->set($key, 'some value'); $redis->get($key); ... This module is designed to function as a drop in replacement for Redis.pm for testing purposes. See perldoc Redis and the redis documentation at <http://redis.io> SUBROUTINES
/METHODS new Create a new Test::Mock::Redis object. It can be used in place of a Redis object for unit testing. It accepts the "server" argument, just like Redis.pm's new. TODO
Lots! Not all Redis functionality is implemented. The test files that output "TODO" are still to be done. The top of all test files [except 01-basic.t] has the list of commands tested or to-be tested in the file. Those marked with an "x" are pretty well-tested. Those marked with an "o" need help. Those that are unmarked have no tests, or are un- implemented. For example: x AUTH <--- has some tests o KEYS <--- only partially tested and/or implemented ZINTERSTORE <--- not tested (or maybe not implemented) Beyond that, it would be neat to add methods to inspect how often keys were accessed and get other information that allows the module user to confirm that their code interacted with redis (or Test::Mock::Redis) as they expected. AUTHOR
Jeff Lavallee, "<jeff at zeroclue.com>" SEE ALSO
The real Redis.pm client whose interface this module mimics: <http://search.cpan.org/dist/Redis> BUGS
Please report any bugs or feature requests to "bug-mock-redis at rt.cpan.org", or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Mock-Redis <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Mock-Redis>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. SUPPORT
You can find documentation for this module with the perldoc command. perldoc Test::Mock::Redis You can also look for information at: o RT: CPAN's request tracker http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Mock-Redis <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Mock-Redis> o AnnoCPAN: Annotated CPAN documentation http://annocpan.org/dist/Test-Mock-Redis <http://annocpan.org/dist/Test-Mock-Redis> o CPAN Ratings http://cpanratings.perl.org/d/Test-Mock-Redis <http://cpanratings.perl.org/d/Test-Mock-Redis> o Search CPAN http://search.cpan.org/dist/Test-Mock-Redis/ <http://search.cpan.org/dist/Test-Mock-Redis/> ACKNOWLEDGEMENTS
Salvatore Sanfilippo for redis, of course! Dobrica Pavlinusic & Pedro Melo for Redis.pm LICENSE AND COPYRIGHT
Copyright 2011 Jeff Lavallee. This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information. perl v5.14.2 2012-04-16 Test::Mock::Redis(3pm)
All times are GMT -4. The time now is 08:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy