OpenVZ Forum


Home » General » Discussions » OpenVZ cpu / mem monitor
OpenVZ cpu / mem monitor [message #6062] Thu, 07 September 2006 14:42 Go to next message
jasonaward is currently offline  jasonaward
Messages: 9
Registered: September 2006
Junior Member
As I've found through posts like this...

http://forum.openvz.org/index.php?t=msg&goto=2687#msg_26 87

... is that in order to calculate the CPU usage of an individual VPS, you had to do some calculation based on the vestats file.

So, being that I needed a utility to do this calculation so I could optimize my individual VPS, I created one. Into it, I added the individual VPS memory usage.

Maybe this will be of some interest to the more curious people, so I'll post it:

http://www.cubedthree.com/projects/openvz/openvzmon.c

If you have any questions, comments or suggestions about how to modify or improve the utility, they would be very much appreciated!

[Updated on: Thu, 21 September 2006 14:01]

Report message to a moderator

Re: OpenVZ cpu / mem monitor [message #6704 is a reply to message #6062] Thu, 21 September 2006 14:04 Go to previous messageGo to next message
jasonaward is currently offline  jasonaward
Messages: 9
Registered: September 2006
Junior Member
For those of you who care, I made a couple of changes to the monitor. They include:

1) added optional parameter -n which is the number of iterations of information the monitor will display before terminating (similar to the normal 'top' n parameter)

2) added optional parameter -d which is the delay between refreshes in seconds as an integer value (similar to the normal 'top' d parameter) -- which is good when you're debugging something, set -d1.

3) added optional parameter -o which is only used for debugging purposes. When using this parameter it outputs a debug.txt file containing the jiffies consumed for each user/nice/syst/idle. Not really useful unless you find a bug and want to report it to me. Wink

The link above should still work.

Let me know if you guys have any questions or comments. Thanks!
Re: OpenVZ cpu / mem monitor [message #6711 is a reply to message #6062] Thu, 21 September 2006 18:28 Go to previous messageGo to next message
jason|xoxide is currently offline  jason|xoxide
Messages: 20
Registered: September 2006
Location: Exton, PA
Junior Member
I just downloaded your file and while it's a nice start, there seem to be a few bugs.

First off, the CPU usage doesn't work at all. It shows 100% idle no matter what is happening.

Next, free memory seems to be displaying KB, not MB (used RAM appear to be correct) and that makes the percentages break and always show 100% free.

Keep up the work though, as this will be a pretty useful app.


Re: OpenVZ cpu / mem monitor [message #6716 is a reply to message #6711] Thu, 21 September 2006 20:35 Go to previous messageGo to next message
jasonaward is currently offline  jasonaward
Messages: 9
Registered: September 2006
Junior Member
The CPU usage was corrected sometime this afternoon. Smile It should work correctly now.

As for the memory, it's working for everyone else who has tested it, but that doesn't mean it's working correctly for you. It's calculated based on your barrier in your /proc/user_beancounters file. it's based off of the first script found here:

http://wiki.vpslink.com/index.php?title=Memory_Utilization_S cript

If you are having issues with it, however, if possible, please post your user_beancounters file, and we can go from there (or at least the lines vmguar and privvm).

Thanks!

[Updated on: Thu, 21 September 2006 20:36]

Report message to a moderator

Re: OpenVZ cpu / mem monitor [message #6718 is a reply to message #6062] Thu, 21 September 2006 20:48 Go to previous messageGo to next message
jason|xoxide is currently offline  jason|xoxide
Messages: 20
Registered: September 2006
Location: Exton, PA
Junior Member
Well, that explains why the memory isn't working for me. I assumed that that figure was read from the systems physical memory and swap. I'm oversubscribing the server since I'm the only one who is using it. I know that all of the services aren't going to make me run out of memory and I'm too lazy to map out exactly what each VM is going to need. No matter, I know how much RAM+Swap I have so the current usage is really all I need to see.

As to the CPU usage, has the .c file in the first post been updated yet? If so, it's still not working for me as I just downloaded it again and recompiled. While building PHP in a VM, I see a steady 100% idle.


Re: OpenVZ cpu / mem monitor [message #6792 is a reply to message #6718] Fri, 22 September 2006 13:46 Go to previous messageGo to next message
jasonaward is currently offline  jasonaward
Messages: 9
Registered: September 2006
Junior Member
Thanks for the information.

I'm not really sure why the CPU isn't working for you. If you'd like me to take a look into it, please run the following:

openvzmon -d1 -n60 -o

And post or message me the resulting debug.txt file. Smile
Re: OpenVZ cpu / mem monitor [message #6793 is a reply to message #6792] Fri, 22 September 2006 14:10 Go to previous messageGo to next message
jason|xoxide is currently offline  jason|xoxide
Messages: 20
Registered: September 2006
Location: Exton, PA
Junior Member
The contents of "debug.txt" are:

EDIT: Code snipped, attachment added.
  • Attachment: debug.txt
    (Size: 5.38KB, Downloaded 597 times)


[Updated on: Fri, 22 September 2006 14:20]

Report message to a moderator

Re: OpenVZ cpu / mem monitor [message #6964 is a reply to message #6793] Thu, 28 September 2006 18:30 Go to previous messageGo to next message
jasonaward is currently offline  jasonaward
Messages: 9
Registered: September 2006
Junior Member
Is this really right?

CPU MHz:22349.016000

I also see a separate problem with variable overflow. I will fix it shortly. Smile
Re: OpenVZ cpu / mem monitor [message #6968 is a reply to message #6062] Thu, 28 September 2006 20:11 Go to previous messageGo to next message
jason|xoxide is currently offline  jason|xoxide
Messages: 20
Registered: September 2006
Location: Exton, PA
Junior Member
The system has Dual Xeon 7030 CPUs which means 8 logical cores at 2800MHz each. It seems that that number comes from the sum of the frequency of all of the logical cores.

Re: OpenVZ cpu / mem monitor [message #7031 is a reply to message #6062] Sun, 01 October 2006 02:42 Go to previous messageGo to next message
kir is currently offline  kir
Messages: 1645
Registered: August 2005
Location: Moscow, Russia
Senior Member

I suggest you to add a page at wiki.openvz.org about your utility.

Also, as long as it will stabilize a bit, let me know and I will put it to http://download.openvz.org/contrib/utils/


Kir Kolyshkin
http://static.openvz.org/userbars/openvz-developer.png
Re: OpenVZ cpu / mem monitor [message #7034 is a reply to message #6968] Sun, 01 October 2006 12:51 Go to previous messageGo to next message
jasonaward is currently offline  jasonaward
Messages: 9
Registered: September 2006
Junior Member
Okay, I make a couple of modifications which should take care of the overflow I was seeing in the debug file and should correct any calculations.

The one thing i did notice from the debug file was this:

331 331 0 0 699 699 869323984949371 869346351937203

The first two are user_jiffies (at previous check and currently), the second are nice_jiffies, the third are system_jiffies, and the fourth is the idle cycles counter. You'll notice in the debug file that over the 60 second run, it appears as though you consumed no user/nice/system jiffies. Though isn't completely shocking since the counter uses 22349MHz as your CPU total speed, but it would give an indication as to why you would be seeing 100% idle time. Try running this latest fix of the monitor while consuming CPU cycles and let me know if it works correctly now.

Thanks!
Re: OpenVZ cpu / mem monitor [message #7059 is a reply to message #6062] Mon, 02 October 2006 16:11 Go to previous messageGo to next message
jason|xoxide is currently offline  jason|xoxide
Messages: 20
Registered: September 2006
Location: Exton, PA
Junior Member
Ok, I just downloaded and tried it again. It seems like the used memory reporting is broken as now it shows a steady 92.26MB used.

The CPU usage seems to work sometimes. For example, when building an RPM, I get a user percentage of 40-50. However, running an OPTIMIZE on a MySQL table shows 0% (even though top shows it as eating 100% of a single core).


Re: OpenVZ cpu / mem monitor [message #7062 is a reply to message #7059] Mon, 02 October 2006 16:54 Go to previous messageGo to next message
jasonaward is currently offline  jasonaward
Messages: 9
Registered: September 2006
Junior Member
I didn't change anything with the memory reporting, and it still works on my end. Though that doesn't mean much. Wink

I'm wondering how the user_beancounters file works with multi-core processors. It's quite possible that it does not present the same viewpoint that the cpuinfo file does. Calculating through cpuinfo simply adds up the value of the individual cores (processors * cores per processor * cpu speed). That part I'm comfortable is correct. The part I don't know is whether or not user_beancounters displays with the same point of reference.

I suppose that would be a question, though, for the OpenVZ developers (or for myself by digging through the OpenVZ code).
Re: OpenVZ cpu / mem monitor [message #7996 is a reply to message #6062] Thu, 02 November 2006 15:45 Go to previous message
jasonaward is currently offline  jasonaward
Messages: 9
Registered: September 2006
Junior Member
A couple of minor changes to th openvzmon tool.

1) Bug fix with debug file. File was be created (empty) even when the -o option wasn't given. This has been corrected.

2) Monitor now displays memory usage immediately upon execution. Before, it would wait until it had cpu statistics to report as well before displaying memory stats.

3) Added a new flag (-m) that, when provided, will only display the memory usage by the system and then immediately terminate. This is for the times when you need to know memory usage only and don't want the delay in cpu stat calculation or to be forced to terminate the application manually.
Previous Topic: Binary Sharing with OpenVZ?
Next Topic: Use OpenVZ for vps template creation for Virtuozzo?
Goto Forum:
  


Current Time: Sat Nov 16 13:53:41 GMT 2024

Total time taken to generate the page: 0.03056 seconds