Sponsored Content
Top Forums Shell Programming and Scripting [Solved] need to get cpu usage with 1 request Post 302693511 by grauzikas on Wednesday 29th of August 2012 10:06:01 AM
Old 08-29-2012
[Solved] need to get cpu usage with 1 request

Hello,

i`m creating an script that collect`s data from virtual machines about cpu usage and store that data into RRD.

so everything now works fine, but it takes long time if in machine is a lot of virtual`s.

so i want to make my script to collect information with 1 request. at this time i`m collecting data like this:

Code:
cpu=`vzctl exec $veid top -bn2 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%\id.*/\1/" | tail -n1 | \
awk '{print 100-$1}'`
wa=`vzctl exec $veid top -bn2 | grep "Cpu(s)" | awk '{print $6/1}' | tail -n1`

i use top -bn2 so it takes second line from top ( because the first line do not show proper value ) and if there is about 30 virtual machines to go all script around it takes some time, becose there are 2 requests: 1 for cpu ( us+sy+ni+hi+si+st ) and second to get wa

so if there is posible to get with 1 request those 2 variables then script would run twice faster

thanks for any advice and sorry for my bad english .

Last edited by vbe; 08-29-2012 at 11:14 AM.. Reason: typos...
 

10 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

cpu usage

hi, In response to your cpu usage answer I too read sys/sysinfo.h but , if we put these values to access the repective time fields in the array pst_cpu_time which is a member of the structure pst_dynamic values doesn't seem to match, why is like this? (0 Replies)
Discussion started by: sushaga
0 Replies

2. 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

3. SuSE

Request:- Could some do a poll of Linux version usage?

I don't know nearly enough about what versions of Open/Free Linux are available. I was wondering if someone would create a new poll of all the major recent(ish) distros so we can see the percentage of people's preferred distro? I've only ever used Suse and have been very happy with it, but... (0 Replies)
Discussion started by: Mark Ward
0 Replies

4. UNIX for Dummies Questions & Answers

cpu usage

when i got the cpu usage values of the all process running in my sytem i see that 140% of the cpu is used. (using ps aux command) i have a 4 cpu system. can we say that averagely 35% of each cpu is used? and if i want to speak more precisely, how can i find out that, which cpu is used at... (4 Replies)
Discussion started by: gfhgfnhhn
4 Replies

5. Programming

CPU usage and memory usage

Please tell me solaris functions/api for getting following information 1- Function that tells how much memory used by current process 2- Function that tells how much memory used by all running processes 3- Function that tells how much CPU is used by current process 4- Function that tells how... (1 Reply)
Discussion started by: mansoorulhaq
1 Replies

6. 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

7. 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

8. Solaris

Multi CPU Solaris system shows 100% CPU usage.

Hello Friends, On one of my Solaris 10 box, CPU usage shows 100% using "sar", "vmstat". However, it has 4 CPUs and prstat and glance are not showing enough processes to justify high CPU utilization. ========================================================================= $ prstat -a ... (4 Replies)
Discussion started by: mahive
4 Replies

9. 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

10. HP-UX

CPU Usage

Hi Experts, We encountered problem in one of the production system where some processes were taking higher CPU and after some time it came back to normal.. From system prespective, is there any way to check why processes took more cpu during that particular period. (16 Replies)
Discussion started by: sai_2507
16 Replies
grammar::me_intro(n)					   Grammar operations and usage 				      grammar::me_intro(n)

__________________________________________________________________________________________________________________________________________________

NAME
grammar::me_intro - Introduction to virtual machines for parsing token streams DESCRIPTION
This document is an introduction to and overview of the basic facilities for the parsing and/or matching of token streams. One possibility often used for the token domain are characters. The packages themselves all provide variants of one virtual machine, called a match engine (short ME), which has all the facilities needed for the matching and parsing of a stream, and which are either controlled directly, or are customized with a match program. The virtual machine is basically a pushdown automaton, with additional elements for backtracking and/or handling of semantic data and construction of abstract syntax trees (AST). Because of the high degree of similarity in the actual implementations of the aforementioned virtual machine and the data structures they receive and generate these common parts are specified in a separate document which will be referenced by the documentation for packages actually implementing it. The relevant documents are: grammar::me_vm Virtual machine specification. grammar::me_ast Specification of various representations used for abstract syntax trees. grammar::me::util Utility commands. grammar::me::tcl Singleton ME virtual machine implementation tied to Tcl for control flow and stacks. Hardwired for pull operation. Uninteruptible during processing. grammar::me::cpu Object-based ME virtual machine implementation with explicit control flow, and stacks, using bytecodes. Suspend/Resumable. Push/pull operation. grammar::me::cpu::core Core functionality for state manipulation and stepping used in the bytecode based implementation of ME virtual machines. BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category gram- mar_me of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation. KEYWORDS
CFG, CFL, LL(k), PEG, TPDL, context-free grammar, context-free languages, expression, grammar, matching, parsing, parsing expression gram- mar, push down automaton, recursive descent, top-down parsing languages, transducer, virtual machine CATEGORY
Grammars and finite automata COPYRIGHT
Copyright (c) 2005 Andreas Kupries <andreas_kupries@users.sourceforge.net> grammar_me 0.1 grammar::me_intro(n)
All times are GMT -4. The time now is 10:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy