Results 1 to 12 of 12
  1. #1

    Question How to check VPS memory usage

    After some search in forums and google i found 2 ways of checking the memory used by VPS processes,

    1. is using this command (someone propsed this on midphase forums

    Code:
    grep oomguarpages /proc/user_beancounters | awk '{s=$2;t=$3;u=$4; {print "VPS Memory Usage\nCurrent Held: " s/256 "MB\nMax Held: " t/256 "MB\nBarrier: "u/256"MB" }}'


    2. is using this script

    Code:
    #!/bin/bash
    bean=`cat /proc/user_beancounters`
    guar=`echo "$bean" | grep vmguar | awk '{ print $4;}'`
    burst=`echo "$bean" | grep privvm | awk '{ print $5;}'`
    priv=`echo "$bean" | grep privvm | awk '{ print $2;}'`
    let total=guar/256
    let used=priv/256
    let burst=burst/256
    echo "VPS memory usage:"
    echo "Used: $used MB"
    echo "Total: $total MB"
    echo "Burstable to: $burst MB"
    the problem is that when i run them on my vps they appear to return different values,

    any idea wich is the most accurate (right), and maybe could give out some clear information about the oomguarpages.

    Also is there any command to display the memory used by a single proccess (including or not its threads) ??

  2. #2
    You don't need to use those scripts. Just do a
    Code:
    cat /proc/user_beancounters
    as root. You will get something that looks like that (sorry for the formatting):
    Code:
    Version: 2.5
           uid  resource           held    maxheld    barrier      limit    failcnt
         50719: kmemsize         617892     806084   10800000   12000000          0
                lockedpages           0          0        256        256          0
                privvmpages        3935       7887      61400      61400          0
                shmpages            640        672      12000      12000          0
                numproc               8         14        256        256          0
                physpages           964       1329          0 2147483647          0
                vmguarpages           0          0      61400      61400          0
                oomguarpages        964       1329      28800      28800          0
                numtcpsock            2          3        240        240          0
                numflock              2          4        160        160          0
                numpty                1          1         32         32          0
                numsiginfo            0          2        256        256          0
                tcpsndbuf          4456       7376    1440000    1600000          0
                tcprcvbuf             0       8552    1440000    1600000          0
                othersockbuf       2228       6456    1440000    1600000          0
                dgramrcvbuf           0       4276     108000     120000          0
                numothersock          2          8        256        256          0
                dcachesize        51660      59122    1080000    1200000          0
                numfile              98        130       3200       3200          0
                numiptent            14         14       1200       1200          0
    All the lines represent different parameters used to define the resources of you VPS. The first column shows the currently used resource, the second shows the maximum resource you have been using since your last reboot, the third shows the soft limit, the fourth shows the hard limit, and the last one shows the failures (how many times your VPS tried to reserve more resource than available).

    I am not aware of a command that shows the memory usage of a particular program, but you can look at the beancounters, start or stop the program, and look at the beancounters again to get an idea of how much resources this program uses.
    Spry VPS Hosting cPanel VPS, Plesk VPS, Webmin VPS, Shared, Domain Registration, Dedicated and Colo VPSLink Cheap VPS accounts CentOS, Fedora, RHEL, Gentoo, Debian, Ubuntu -- Dapper Drake, Slackware, OpenSUSE

  3. #3
    Join Date
    Dec 2004
    Location
    Butler,TN
    Posts
    2,416
    Hi!
    Mytop is the only program I am aware of that does this..it shows you mysql processes and mysql usage only..but in a "top" like fashion.

    To help you understand what these numbers mean...is beyond the scope of my time right now. However...I will make a FAQ about this..it is badly needed.

    Basically...the resources the vps is running out of are displayed at the far right of the screen..Failcnt. Depending on the host...you can ask them to increase a certain resource..sometimes they will..sometimes they won't.

    I've personally had more problems with stingy privvmpage allocations on vps's in the past. Running out of this resource can make installs fail most miserably.

    What it is is this: It is private (or potentially private) memory allocated and shared by applications you have running. There is another..but it's just not coming to mind at this time (more coffee!).

    Bryon
    Bryon L Harvey
    Soil Relocation Engineer

  4. #4
    Join Date
    Jan 2006
    Location
    Sydney, Australia
    Posts
    251
    Hopefully all these UBC mess will be over when hosts move to VZ3's SLM model, or when OpenVZ guys finally worked out how to virtualize /proc/meminfo...

    Scott

  5. #5
    Looks like I need to upgrade or do I?


    uid resource held maxheld barrier limit failcnt
    376: kmemsize 5941214 5955324 14807040 15237120 10226
    lockedpages 0 0 384 384 0
    privvmpages 98661 99138 196608 200540 7
    shmpages 859 859 32256 32256 0
    dummy 0 0 0 0 0
    numproc 81 81 360 360 514
    physpages 52112 52139 0 2147483647 0
    vmguarpages 0 0 49152 2147483647 0
    oomguarpages 58550 58577 49152 2147483647 0
    numtcpsock 32 35 540 540 0
    numflock 12 14 282 309 0
    numpty 1 1 24 24 0
    numsiginfo 0 1 384 384 0
    tcpsndbuf 6684 36340 2580480 4055040 0
    tcprcvbuf 0 43064 2580480 4055040 0
    othersockbuf 26300 29448 1689120 3145728 45187
    dgramrcvbuf 0 0 393216 393216 0
    numothersock 27 31 540 540 0
    dcachesize 601404 609440 3409920 3624960 0
    numfile 1561 1567 8730 8730 0
    dummy 0 0 0 0 0
    dummy 0 0 0 0 0
    dummy 0 0 0 0 0
    numiptent 59 59 192 192 0

  6. #6
    Join Date
    Dec 2004
    Location
    Butler,TN
    Posts
    2,416
    Hi!
    You are using more memory than allocated...but these allocations are quite high.
    Before you decide you must upgrade..I would suggest you shut down things that are running that you don't need first. If you don't feel you can do that by yourself..feel free to do the command:

    ps axv

    and post it here so we can see what processes are running and what's using the most memory. There are more commands to feed "ps"..but I think this will do.

    Bryon
    Bryon L Harvey
    Soil Relocation Engineer

  7. #7
    Quote Originally Posted by bryonhost1
    Hi!
    You are using more memory than allocated...but these allocations are quite high.
    Before you decide you must upgrade..I would suggest you shut down things that are running that you don't need first. If you don't feel you can do that by yourself..feel free to do the command:

    ps axv

    and post it here so we can see what processes are running and what's using the most memory. There are more commands to feed "ps"..but I think this will do.

    Bryon
    Thank you I will try this and post back the results. I am new to vps so is that the whole command to type in? "ps axv"

  8. #8
    This is what I have.
    PID TTY STAT TIME MAJFL TRS DRS RSS %MEM COMMAND
    1 ? Ss 0:11 0 26 1593 548 0.0 init
    30617 ? Ss 0:01 6 28 1495 604 0.0 syslogd -m 0
    30687 ? S 0:00 0 10 1437 460 0.0 /usr/sbin/courierlogger
    30693 ? S 0:00 1 13 1782 552 0.0 /usr/libexec/courier-aut
    31854 ? S 0:00 1 13 1782 552 0.0 /usr/libexec/courier-aut
    31856 ? S 0:00 0 13 1782 548 0.0 /usr/libexec/courier-aut
    31857 ? S 0:00 0 13 1782 564 0.0 /usr/libexec/courier-aut
    31858 ? S 0:00 0 13 1782 564 0.0 /usr/libexec/courier-aut
    31859 ? S 0:00 0 13 1782 564 0.0 /usr/libexec/courier-aut
    1588 ? Ss 0:00 1 138 1933 764 0.0 xinetd -stayalive -pidfi
    1615 ? S 0:00 0 573 1570 1008 0.0 /bin/sh /usr/bin/mysqld_
    1650 ? Sl 4:42 25 4000 149859 46264 0.5 /usr/sbin/mysqld --bas
    1959 ? S 0:00 0 10 1441 468 0.0 /usr/sbin/courierlogger
    1973 ? S 0:00 0 44 1515 512 0.0 /usr/lib/courier-imap/li
    1996 ? S 0:00 0 10 1441 352 0.0 /usr/sbin/courierlogger
    1997 ? S 0:00 0 44 1515 424 0.0 /usr/lib/courier-imap/li
    2002 ? S 0:00 3 10 1441 468 0.0 /usr/sbin/courierlogger
    2003 ? S 0:00 7 44 1515 484 0.0 /usr/lib/courier-imap/li
    2008 ? S 0:00 0 10 1441 352 0.0 /usr/sbin/courierlogger
    2012 ? S 0:00 0 44 1515 424 0.0 /usr/lib/courier-imap/li
    3184 ? Ss 0:08 10 659 6668 2000 0.0 /usr/sbin/exim -bd -q60m
    3252 ? Ss 0:00 0 659 6668 1960 0.0 /usr/sbin/exim -tls-on-c
    3290 ? S 0:42 0 829 2214 1448 0.0 antirelayd
    3908 ? Ss 0:33 9 829 24630 18776 0.2 /usr/bin/spamd -d --all
    4036 ? S 0:05 211 829 24894 21460 0.2 spamd child
    4037 ? S 0:02 292 829 24894 21456 0.2 spamd child
    5186 ? Ss 0:00 9 103 3724 1512 0.0 pure-ftpd (SERVER)
    5205 ? S 0:00 4 8 3559 768 0.0 /usr/sbin/pure-authd -s
    5253 ? Ss 0:01 72 36 2435 1028 0.0 crond
    5439 ? S 0:24 17 829 6742 4776 0.0 eximstats
    5694 ? S 0:01 154 829 6002 4472 0.0 cpbandwd
    9330 ? Ss 0:00 3 61 5114 2156 0.0 /usr/bin/stunnel-4.15loc
    9596 ? Ss 0:00 0 61 3982 1132 0.0 /usr/sbin/saslauthd -m /
    9653 ? S 0:00 0 61 3982 1132 0.0 /usr/sbin/saslauthd -m /
    13985 ? Ssl 0:00 0 269 39042 3040 0.0 /usr/sbin/named -u named
    9520 ? Ss 0:00 6 296 3711 1696 0.0 /usr/sbin/sshd
    29810 ? Ss 0:15 0 533 15586 7912 0.0 /usr/local/apache/bin/ht
    3087 ? Ss 0:00 0 659 6668 1968 0.0 /usr/sbin/exim -oX 26 -b
    16234 ? S 0:00 0 3552 8707 10784 0.1 cpsrvd - waiting for co
    22479 ? S 0:35 52 533 23478 16568 0.2 /usr/local/apache/bin/h
    1847 ? S 0:27 37 533 21010 13960 0.1 /usr/local/apache/bin/h
    3937 ? S 0:23 91 533 23294 16076 0.1 /usr/local/apache/bin/h
    18131 ? S 0:26 68 533 20986 13908 0.1 /usr/local/apache/bin/h
    7863 ? S 0:20 140 533 21546 14460 0.1 /usr/local/apache/bin/h
    21528 ? S 0:14 149 533 22926 15884 0.1 /usr/local/apache/bin/h
    26005 ? S 0:13 25 533 23314 16196 0.1 /usr/local/apache/bin/h
    3206 ? S 0:08 45 533 21462 14376 0.1 /usr/local/apache/bin/h
    7951 ? S 0:06 11 533 22226 15144 0.1 /usr/local/apache/bin/h
    5383 ? S 0:03 6 533 20986 13896 0.1 /usr/local/apache/bin/h
    11878 ? S 0:00 1 533 20314 13228 0.1 /usr/local/apache/bin/h
    17936 ? S 0:00 1 533 16278 8988 0.1 /usr/local/apache/bin/ht
    18316 ? S 0:00 0 533 20962 13872 0.1 /usr/local/apache/bin/h
    18324 ? S 0:00 4 533 17298 10072 0.1 /usr/local/apache/bin/h
    18325 ? S 0:00 0 533 19314 12140 0.1 /usr/local/apache/bin/h
    20288 ? Rs 0:00 5 296 6603 2272 0.0 sshd: root@pts/0
    21754 ? Ss 0:00 0 18 2925 1280 0.0 login -- root
    21771 pts/0 Ss 0:00 4 573 1574 1272 0.0 -bash
    21957 ? S 0:00 0 533 16278 8980 0.1 /usr/local/apache/bin/ht
    21971 ? S 0:00 0 533 15586 8004 0.0 /usr/local/apache/bin/ht
    21972 ? S 0:00 0 533 15586 7928 0.0 /usr/local/apache/bin/ht
    22001 ? S 0:00 0 533 15586 7928 0.0 /usr/local/apache/bin/ht
    22012 pts/0 R+ 0:00 0 56 2207 676 0.0 ps axv

  9. #9
    Join Date
    Jun 2003
    Location
    UK
    Posts
    6,616
    There is nothing there that would overally worry me but it looks like you are just using a lot of RAM on MySQL. Do you have some fairly large sites?
    Russ Foster - Industry Curmudgeon
    Freelance Sysadmin for Hire - email vaserv@gmail.com

  10. #10
    Quote Originally Posted by a2b2
    There is nothing there that would overally worry me but it looks like you are just using a lot of RAM on MySQL. Do you have some fairly large sites?
    I have my forums localracechat.com that uses a average 55gigs og BW a month I also have a few html websites that use a guest book but are not real busy. I have 2 other site that use 2-3 gigs of BW but no sql.

    For the past 2 days I have had to restart my vps because it gets hung up and my forums will not load. This was a reply from my host.

    It appears that Apache stuck in your VPS, I've restarted it for you. In
    > general stability of Apache depends on your configuration and what kind of
    > scripts are running. You may have either problems with configuration (there
    > should be error/warning reports in Apache's log file located at
    > /usr/local/apache/logs/error_log) or there is a good chance that you have
    > some (broken) scripts with, say, memory leaks that take all Apache processes
    > and do not release them until web server is completely restarted.
    > Also it might be a good idea to enable internal cPanel's monitoring for
    > the "httpd" service - this monitoring module was specifically designed by
    > cPanel to catch possible problems with hosting services (including Apache)
    > and restart them. You may enable Apache service monitoring by going to WHM
    > >> Service Configuration >> Service Manager, check the "Monitor" checkbox on
    > the "httpd" line and click "Save". Hope this helps.
    I did enable internal cPanel's monitoring for the "httpd" service.. I think. But what do I do with it? What is it supose to do? I did look at the error logs as they sugested and noticed a few files that were being called up but not there. This weekend I am going to go through my forums and clean a few things up and see if it helps out. Any other ideas? Thanks for the comments. One more thing would it be better to run the "ps axv" command when the site is busy or does it matter?

  11. #11
    Join Date
    Jun 2003
    Location
    UK
    Posts
    6,616
    Your best bet would be to just buy some more RAM from the VPS as that will give you some breathing space as you tidy things up.
    Russ Foster - Industry Curmudgeon
    Freelance Sysadmin for Hire - email vaserv@gmail.com

  12. #12
    Quote Originally Posted by a2b2
    Your best bet would be to just buy some more RAM from the VPS as that will give you some breathing space as you tidy things up.

    Do you think it would be a good thing to switch to Direct Admin or Plesk as well since they do not use the resourses cPanel does?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •