CPU > 80% - how can I debug?











up vote
0
down vote

favorite












I am running a laravel application on a Ubuntu 14.04 digital ocean vps and I am using New Relic to monitor the server.



I got an email alert that my CPU usage was above 80%. I logged in to New Relic and now it's showing my CPU usage at 99% for 18 hours now. But when I log into my shell and run 'top' the CPU usage of the processes don't even sum up to 10%.



What could be wrong? Which are other commands I could run to check the real usage and what is using it so much? (Perhaps an infinite loop on the application?)



This is my htop result:



enter image description here



And this is htop after shift+K



enter image description here



Any links or help would be greatly appreciated.










share|improve this question




















  • 1




    My first question is: What properly written PHP process has a run-duration of 1h24 minutes?
    – Otheus
    Nov 6 '15 at 19:31










  • Maybe Otheus's attitude would make sense if we were in the 90's, but 'Why are you using PHP for that' this is totally not the way to respond to a unix system admin question
    – karimkorun
    Jul 16 at 13:44

















up vote
0
down vote

favorite












I am running a laravel application on a Ubuntu 14.04 digital ocean vps and I am using New Relic to monitor the server.



I got an email alert that my CPU usage was above 80%. I logged in to New Relic and now it's showing my CPU usage at 99% for 18 hours now. But when I log into my shell and run 'top' the CPU usage of the processes don't even sum up to 10%.



What could be wrong? Which are other commands I could run to check the real usage and what is using it so much? (Perhaps an infinite loop on the application?)



This is my htop result:



enter image description here



And this is htop after shift+K



enter image description here



Any links or help would be greatly appreciated.










share|improve this question




















  • 1




    My first question is: What properly written PHP process has a run-duration of 1h24 minutes?
    – Otheus
    Nov 6 '15 at 19:31










  • Maybe Otheus's attitude would make sense if we were in the 90's, but 'Why are you using PHP for that' this is totally not the way to respond to a unix system admin question
    – karimkorun
    Jul 16 at 13:44















up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am running a laravel application on a Ubuntu 14.04 digital ocean vps and I am using New Relic to monitor the server.



I got an email alert that my CPU usage was above 80%. I logged in to New Relic and now it's showing my CPU usage at 99% for 18 hours now. But when I log into my shell and run 'top' the CPU usage of the processes don't even sum up to 10%.



What could be wrong? Which are other commands I could run to check the real usage and what is using it so much? (Perhaps an infinite loop on the application?)



This is my htop result:



enter image description here



And this is htop after shift+K



enter image description here



Any links or help would be greatly appreciated.










share|improve this question















I am running a laravel application on a Ubuntu 14.04 digital ocean vps and I am using New Relic to monitor the server.



I got an email alert that my CPU usage was above 80%. I logged in to New Relic and now it's showing my CPU usage at 99% for 18 hours now. But when I log into my shell and run 'top' the CPU usage of the processes don't even sum up to 10%.



What could be wrong? Which are other commands I could run to check the real usage and what is using it so much? (Perhaps an infinite loop on the application?)



This is my htop result:



enter image description here



And this is htop after shift+K



enter image description here



Any links or help would be greatly appreciated.







performance cpu






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 6 '15 at 19:11

























asked Nov 6 '15 at 17:12









raphadko

1186




1186








  • 1




    My first question is: What properly written PHP process has a run-duration of 1h24 minutes?
    – Otheus
    Nov 6 '15 at 19:31










  • Maybe Otheus's attitude would make sense if we were in the 90's, but 'Why are you using PHP for that' this is totally not the way to respond to a unix system admin question
    – karimkorun
    Jul 16 at 13:44
















  • 1




    My first question is: What properly written PHP process has a run-duration of 1h24 minutes?
    – Otheus
    Nov 6 '15 at 19:31










  • Maybe Otheus's attitude would make sense if we were in the 90's, but 'Why are you using PHP for that' this is totally not the way to respond to a unix system admin question
    – karimkorun
    Jul 16 at 13:44










1




1




My first question is: What properly written PHP process has a run-duration of 1h24 minutes?
– Otheus
Nov 6 '15 at 19:31




My first question is: What properly written PHP process has a run-duration of 1h24 minutes?
– Otheus
Nov 6 '15 at 19:31












Maybe Otheus's attitude would make sense if we were in the 90's, but 'Why are you using PHP for that' this is totally not the way to respond to a unix system admin question
– karimkorun
Jul 16 at 13:44






Maybe Otheus's attitude would make sense if we were in the 90's, but 'Why are you using PHP for that' this is totally not the way to respond to a unix system admin question
– karimkorun
Jul 16 at 13:44












3 Answers
3






active

oldest

votes

















up vote
0
down vote













I had a similar problem and I did run TOP command in background and redirect it to a txt file



top > top.txt &



Thank you can see which process waste your CPU






share|improve this answer




























    up vote
    0
    down vote













    There are a few options. My preference is the program htop which isn't generally installed by default but is available for almost all distros. It gives you the same info as top but with a MUCH richer feature set. It's great for interactively finding the problem process but it's not great for scripting. If you want to incorporate something into a monitoring script the command ps -eo pid,pcpu,comm will be your friend. It prints all of the current processes along with their PID and CPU usage in a fairly easy-to-parse format.






    share|improve this answer





















    • htop shows the same as top, the sum of all usage is about 9%. the other command ps... shows everything at 0.0, some at 0.2
      – raphadko
      Nov 6 '15 at 17:41










    • What is the load average on the server (it's shown in the top right corner of htop)?
      – David King
      Nov 6 '15 at 17:54










    • 1.22, 1.30, 1.31
      – raphadko
      Nov 6 '15 at 18:10










    • and CPU that show on top of htop, shows 100%
      – raphadko
      Nov 6 '15 at 18:10










    • edited the question with more information
      – raphadko
      Nov 6 '15 at 18:22


















    up vote
    0
    down vote













    I'm not sure what's going on, but my guess is that the individual process's %CPU column isn't telling you what you think it tells you. From top's manpage:



      k: %CPU  --  CPU usage
    The task’s share of the elapsed CPU time since the last screen update,
    expressed as a percentage of total CPU time.


    Let's say you're refreshing every 4 seconds. The total CPU time it consumed in those 2 seconds is 6% over those 4 seconds. But let's say in one of those seconds, it spurted and used 24% of CPU time. I'm not saying this is happening, but it could be.



    I am happy with top here. I can see CPU usage broken down by CPU and further by user, sys, nice, idle, wait (on I/O), servicing hardware and software interrupts (hi, si). You can probably get this in htop as well. As long as you have 1 CPU that is at least 20% idle, there's little to actually worry about, unless your fan is bothering you. But if you're worried, maybe what's happening is %wait and %hi/%si are very high, in which case no individual process is having a high CPU usage, but rather, the kernel is very very busy for some reason.






    share|improve this answer





















    • You can get detailed cpu time in htop via the setup menu but idle is never included in cpu usage stats. If the cpu was 20% idle that would show up in htop even without detailed stats
      – David King
      Nov 6 '15 at 21:14











    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f241309%2fcpu-80-how-can-i-debug%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    I had a similar problem and I did run TOP command in background and redirect it to a txt file



    top > top.txt &



    Thank you can see which process waste your CPU






    share|improve this answer

























      up vote
      0
      down vote













      I had a similar problem and I did run TOP command in background and redirect it to a txt file



      top > top.txt &



      Thank you can see which process waste your CPU






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        I had a similar problem and I did run TOP command in background and redirect it to a txt file



        top > top.txt &



        Thank you can see which process waste your CPU






        share|improve this answer












        I had a similar problem and I did run TOP command in background and redirect it to a txt file



        top > top.txt &



        Thank you can see which process waste your CPU







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 6 '15 at 17:24









        Federi

        44821229




        44821229
























            up vote
            0
            down vote













            There are a few options. My preference is the program htop which isn't generally installed by default but is available for almost all distros. It gives you the same info as top but with a MUCH richer feature set. It's great for interactively finding the problem process but it's not great for scripting. If you want to incorporate something into a monitoring script the command ps -eo pid,pcpu,comm will be your friend. It prints all of the current processes along with their PID and CPU usage in a fairly easy-to-parse format.






            share|improve this answer





















            • htop shows the same as top, the sum of all usage is about 9%. the other command ps... shows everything at 0.0, some at 0.2
              – raphadko
              Nov 6 '15 at 17:41










            • What is the load average on the server (it's shown in the top right corner of htop)?
              – David King
              Nov 6 '15 at 17:54










            • 1.22, 1.30, 1.31
              – raphadko
              Nov 6 '15 at 18:10










            • and CPU that show on top of htop, shows 100%
              – raphadko
              Nov 6 '15 at 18:10










            • edited the question with more information
              – raphadko
              Nov 6 '15 at 18:22















            up vote
            0
            down vote













            There are a few options. My preference is the program htop which isn't generally installed by default but is available for almost all distros. It gives you the same info as top but with a MUCH richer feature set. It's great for interactively finding the problem process but it's not great for scripting. If you want to incorporate something into a monitoring script the command ps -eo pid,pcpu,comm will be your friend. It prints all of the current processes along with their PID and CPU usage in a fairly easy-to-parse format.






            share|improve this answer





















            • htop shows the same as top, the sum of all usage is about 9%. the other command ps... shows everything at 0.0, some at 0.2
              – raphadko
              Nov 6 '15 at 17:41










            • What is the load average on the server (it's shown in the top right corner of htop)?
              – David King
              Nov 6 '15 at 17:54










            • 1.22, 1.30, 1.31
              – raphadko
              Nov 6 '15 at 18:10










            • and CPU that show on top of htop, shows 100%
              – raphadko
              Nov 6 '15 at 18:10










            • edited the question with more information
              – raphadko
              Nov 6 '15 at 18:22













            up vote
            0
            down vote










            up vote
            0
            down vote









            There are a few options. My preference is the program htop which isn't generally installed by default but is available for almost all distros. It gives you the same info as top but with a MUCH richer feature set. It's great for interactively finding the problem process but it's not great for scripting. If you want to incorporate something into a monitoring script the command ps -eo pid,pcpu,comm will be your friend. It prints all of the current processes along with their PID and CPU usage in a fairly easy-to-parse format.






            share|improve this answer












            There are a few options. My preference is the program htop which isn't generally installed by default but is available for almost all distros. It gives you the same info as top but with a MUCH richer feature set. It's great for interactively finding the problem process but it's not great for scripting. If you want to incorporate something into a monitoring script the command ps -eo pid,pcpu,comm will be your friend. It prints all of the current processes along with their PID and CPU usage in a fairly easy-to-parse format.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 6 '15 at 17:38









            David King

            2,813421




            2,813421












            • htop shows the same as top, the sum of all usage is about 9%. the other command ps... shows everything at 0.0, some at 0.2
              – raphadko
              Nov 6 '15 at 17:41










            • What is the load average on the server (it's shown in the top right corner of htop)?
              – David King
              Nov 6 '15 at 17:54










            • 1.22, 1.30, 1.31
              – raphadko
              Nov 6 '15 at 18:10










            • and CPU that show on top of htop, shows 100%
              – raphadko
              Nov 6 '15 at 18:10










            • edited the question with more information
              – raphadko
              Nov 6 '15 at 18:22


















            • htop shows the same as top, the sum of all usage is about 9%. the other command ps... shows everything at 0.0, some at 0.2
              – raphadko
              Nov 6 '15 at 17:41










            • What is the load average on the server (it's shown in the top right corner of htop)?
              – David King
              Nov 6 '15 at 17:54










            • 1.22, 1.30, 1.31
              – raphadko
              Nov 6 '15 at 18:10










            • and CPU that show on top of htop, shows 100%
              – raphadko
              Nov 6 '15 at 18:10










            • edited the question with more information
              – raphadko
              Nov 6 '15 at 18:22
















            htop shows the same as top, the sum of all usage is about 9%. the other command ps... shows everything at 0.0, some at 0.2
            – raphadko
            Nov 6 '15 at 17:41




            htop shows the same as top, the sum of all usage is about 9%. the other command ps... shows everything at 0.0, some at 0.2
            – raphadko
            Nov 6 '15 at 17:41












            What is the load average on the server (it's shown in the top right corner of htop)?
            – David King
            Nov 6 '15 at 17:54




            What is the load average on the server (it's shown in the top right corner of htop)?
            – David King
            Nov 6 '15 at 17:54












            1.22, 1.30, 1.31
            – raphadko
            Nov 6 '15 at 18:10




            1.22, 1.30, 1.31
            – raphadko
            Nov 6 '15 at 18:10












            and CPU that show on top of htop, shows 100%
            – raphadko
            Nov 6 '15 at 18:10




            and CPU that show on top of htop, shows 100%
            – raphadko
            Nov 6 '15 at 18:10












            edited the question with more information
            – raphadko
            Nov 6 '15 at 18:22




            edited the question with more information
            – raphadko
            Nov 6 '15 at 18:22










            up vote
            0
            down vote













            I'm not sure what's going on, but my guess is that the individual process's %CPU column isn't telling you what you think it tells you. From top's manpage:



              k: %CPU  --  CPU usage
            The task’s share of the elapsed CPU time since the last screen update,
            expressed as a percentage of total CPU time.


            Let's say you're refreshing every 4 seconds. The total CPU time it consumed in those 2 seconds is 6% over those 4 seconds. But let's say in one of those seconds, it spurted and used 24% of CPU time. I'm not saying this is happening, but it could be.



            I am happy with top here. I can see CPU usage broken down by CPU and further by user, sys, nice, idle, wait (on I/O), servicing hardware and software interrupts (hi, si). You can probably get this in htop as well. As long as you have 1 CPU that is at least 20% idle, there's little to actually worry about, unless your fan is bothering you. But if you're worried, maybe what's happening is %wait and %hi/%si are very high, in which case no individual process is having a high CPU usage, but rather, the kernel is very very busy for some reason.






            share|improve this answer





















            • You can get detailed cpu time in htop via the setup menu but idle is never included in cpu usage stats. If the cpu was 20% idle that would show up in htop even without detailed stats
              – David King
              Nov 6 '15 at 21:14















            up vote
            0
            down vote













            I'm not sure what's going on, but my guess is that the individual process's %CPU column isn't telling you what you think it tells you. From top's manpage:



              k: %CPU  --  CPU usage
            The task’s share of the elapsed CPU time since the last screen update,
            expressed as a percentage of total CPU time.


            Let's say you're refreshing every 4 seconds. The total CPU time it consumed in those 2 seconds is 6% over those 4 seconds. But let's say in one of those seconds, it spurted and used 24% of CPU time. I'm not saying this is happening, but it could be.



            I am happy with top here. I can see CPU usage broken down by CPU and further by user, sys, nice, idle, wait (on I/O), servicing hardware and software interrupts (hi, si). You can probably get this in htop as well. As long as you have 1 CPU that is at least 20% idle, there's little to actually worry about, unless your fan is bothering you. But if you're worried, maybe what's happening is %wait and %hi/%si are very high, in which case no individual process is having a high CPU usage, but rather, the kernel is very very busy for some reason.






            share|improve this answer





















            • You can get detailed cpu time in htop via the setup menu but idle is never included in cpu usage stats. If the cpu was 20% idle that would show up in htop even without detailed stats
              – David King
              Nov 6 '15 at 21:14













            up vote
            0
            down vote










            up vote
            0
            down vote









            I'm not sure what's going on, but my guess is that the individual process's %CPU column isn't telling you what you think it tells you. From top's manpage:



              k: %CPU  --  CPU usage
            The task’s share of the elapsed CPU time since the last screen update,
            expressed as a percentage of total CPU time.


            Let's say you're refreshing every 4 seconds. The total CPU time it consumed in those 2 seconds is 6% over those 4 seconds. But let's say in one of those seconds, it spurted and used 24% of CPU time. I'm not saying this is happening, but it could be.



            I am happy with top here. I can see CPU usage broken down by CPU and further by user, sys, nice, idle, wait (on I/O), servicing hardware and software interrupts (hi, si). You can probably get this in htop as well. As long as you have 1 CPU that is at least 20% idle, there's little to actually worry about, unless your fan is bothering you. But if you're worried, maybe what's happening is %wait and %hi/%si are very high, in which case no individual process is having a high CPU usage, but rather, the kernel is very very busy for some reason.






            share|improve this answer












            I'm not sure what's going on, but my guess is that the individual process's %CPU column isn't telling you what you think it tells you. From top's manpage:



              k: %CPU  --  CPU usage
            The task’s share of the elapsed CPU time since the last screen update,
            expressed as a percentage of total CPU time.


            Let's say you're refreshing every 4 seconds. The total CPU time it consumed in those 2 seconds is 6% over those 4 seconds. But let's say in one of those seconds, it spurted and used 24% of CPU time. I'm not saying this is happening, but it could be.



            I am happy with top here. I can see CPU usage broken down by CPU and further by user, sys, nice, idle, wait (on I/O), servicing hardware and software interrupts (hi, si). You can probably get this in htop as well. As long as you have 1 CPU that is at least 20% idle, there's little to actually worry about, unless your fan is bothering you. But if you're worried, maybe what's happening is %wait and %hi/%si are very high, in which case no individual process is having a high CPU usage, but rather, the kernel is very very busy for some reason.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 6 '15 at 19:44









            Otheus

            3,344931




            3,344931












            • You can get detailed cpu time in htop via the setup menu but idle is never included in cpu usage stats. If the cpu was 20% idle that would show up in htop even without detailed stats
              – David King
              Nov 6 '15 at 21:14


















            • You can get detailed cpu time in htop via the setup menu but idle is never included in cpu usage stats. If the cpu was 20% idle that would show up in htop even without detailed stats
              – David King
              Nov 6 '15 at 21:14
















            You can get detailed cpu time in htop via the setup menu but idle is never included in cpu usage stats. If the cpu was 20% idle that would show up in htop even without detailed stats
            – David King
            Nov 6 '15 at 21:14




            You can get detailed cpu time in htop via the setup menu but idle is never included in cpu usage stats. If the cpu was 20% idle that would show up in htop even without detailed stats
            – David King
            Nov 6 '15 at 21:14


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f241309%2fcpu-80-how-can-i-debug%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            サソリ

            広島県道265号伴広島線

            Setup Asymptote in Texstudio