Ad Widget

Collapse

Finding CPU consumers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tof233
    Member
    • Nov 2010
    • 94

    #16
    I use both
    In your script I replaced all echo "${nodata}" by echo -en '\n' and still got the unsupported item problem.

    Comment

    • jerrylenk
      Member
      Zabbix Certified Specialist
      • May 2010
      • 62

      #17
      Originally posted by tof233
      However, I would like to remove the "." when there is no process over trigger (so empty result).
      Do you know what is the output for empty on text item (just returning nothing turn the item into unsupported)?
      I think zabbix server won't accept an empty string. It expects "something" or else it turns to unsupported. That is why I added the "." in the first place.
      Maybe a blank " " will work.

      The other thing I can think of:
      Having a SQL command run every few minutes, something like:
      delete from <values table> where <whatever the name> like ".";

      Jerry

      Comment

      • tof233
        Member
        • Nov 2010
        • 94

        #18
        Adding a space does the same than the ".".
        You are right, the only solution may be to directly delete empty values in the database.
        To conclude, may I suggest to add the possibility to return a "empty text" that won't be registered in database but will keep the item active?

        Comment

        • frater
          Senior Member
          • Oct 2010
          • 340

          #19
          Originally posted by tof233
          Adding a space does the same than the ".".
          You are right, the only solution may be to directly delete empty values in the database.
          To conclude, may I suggest to add the possibility to return a "empty text" that won't be registered in database but will keep the item active?
          I am just a user of Zabbix like you are...
          Feature suggestions can be made on https://support.zabbix.com/
          Zabbix agents on Linux, FreeBSD, Windows, AVM-Fritz!box, DD-WRT and QNAP

          Comment

          • tof233
            Member
            • Nov 2010
            • 94

            #20
            Here it is : https://support.zabbix.com/browse/ZBXNEXT-641

            Comment

            • frater
              Senior Member
              • Oct 2010
              • 340

              #21
              you are only describing what happens.this will not be seen as a problem.you need to tell them them what you want to happen.
              Zabbix agents on Linux, FreeBSD, Windows, AVM-Fritz!box, DD-WRT and QNAP

              Comment

              • hertell
                Member
                • Aug 2010
                • 31

                #22
                Originally posted by frater
                I do not understand why you want to do that. It means zabbix will stop monitoring the machine when it becomes idle, which is hopefully most of the time.

                But the answer is easy.
                Just don't give any command that outputs something and zabbix will turn it into unsupported.
                Hi folks,

                To minimize the load of zabbix having to run this script every 30 sec, why don't you run this script in a endless loop with a "sleep 30" in the end of the loop, and if there is any output, then use zabbix_sender to send the data to zabbix. This way ayou don't get the millions os rows with just a dot..

                just my .5 €ents

                Comment

                • frater
                  Senior Member
                  • Oct 2010
                  • 340

                  #23
                  Originally posted by hertell
                  Hi folks,

                  To minimize the load of zabbix having to run this script every 30 sec, why don't you run this script in a endless loop with a "sleep 30" in the end of the loop, and if there is any output, then use zabbix_sender to send the data to zabbix. This way ayou don't get the millions os rows with just a dot..

                  just my .5 €ents
                  It would require a totally different approach. Currently it is the zabbix-server that triggers the script to run (albeit through the agent).

                  It's possible to let the client do this with for instance zabbix_sender.
                  I personally prefer it to get triggered by cron though. Otherwise you'd need another check on that script as well. A check on cron should already be there.
                  Zabbix agents on Linux, FreeBSD, Windows, AVM-Fritz!box, DD-WRT and QNAP

                  Comment

                  • hertell
                    Member
                    • Aug 2010
                    • 31

                    #24
                    Originally posted by frater
                    It's possible to let the client do this with for instance zabbix_sender.
                    I personally prefer it to get triggered by cron though. Otherwise you'd need another check on that script as well. A check on cron should already be there.
                    It's just not any idea to have cron wake up every 60 sec. for starting a script. I think the best thing would to daemonize topcpu.sh..

                    Comment

                    • frater
                      Senior Member
                      • Oct 2010
                      • 340

                      #25
                      Originally posted by hertell
                      It's just not any idea to have cron wake up every 60 sec. for starting a script. I think the best thing would to daemonize topcpu.sh..
                      That's exactly what cron is for...
                      And it's not waking up, it's running already and it is more reliable that way and when someone else wants to know what things are running scheduled it's where they look for.

                      If some rare condition crashes the script it will never run until it gets restarted. You would need zabbix to check if the script is still running.
                      Like I said earlier, you should already have that for cron
                      Zabbix agents on Linux, FreeBSD, Windows, AVM-Fritz!box, DD-WRT and QNAP

                      Comment

                      • jerrylenk
                        Member
                        Zabbix Certified Specialist
                        • May 2010
                        • 62

                        #26
                        Hi everybody!

                        hertell's idea, running the script in the background permanently and have it use zabbix-sender only when there is something to report, is neat.

                        As long as the monitored server is not outside a firewall inhibiting any traffic to the zabbix-server unless the connection is coming from the zabbix-server.
                        In our case, the network administrator does not want to poke a hole into the firewall allowing any connection whatsoever FROM the DMZ to the inside LAN -- good decision, I think, but of course only passive checks are possible that way.

                        As to using cron: in my opinion a 1 minute interval is too long. OK, running it twice with 30s sleep in between can fix that.

                        But getting rid of the 'dots' is not that hard:
                        (well, maybe messing with the database in a production system might be risky...)

                        I have cron run this SQL command every few minutes:
                        Code:
                        DELETE FROM history_text WHERE value = '.' AND itemid IN (22695,23079);
                        The relevant itemIDs appear in the URL when viewing the 'latest data' history for the item.

                        Jerry

                        Comment

                        • liviusbr
                          Junior Member
                          • Jun 2013
                          • 6

                          #27
                          Process utilisation

                          Hi Guys,


                          1. I need to monitor a Linux Server CPU load and utilization.
                          Server is usually quad core. Can you guys send me the best syntax to use in order to view it nicely and comprehensive ?


                          2. Second thing I would like to do is to monitor a specific process, that runs on-demand. The thing is, this process sometimes runs in several threads in parallel (under the same name), and using the script I done I can only check the 1st process. Any trick or script to monitor all others ?

                          Comment

                          • vlam
                            Senior Member
                            Zabbix Certified Specialist
                            • Jun 2009
                            • 166

                            #28
                            Originally posted by tof233
                            Thank you for these scripts
                            I modified a little bit the first one so it displays the command.

                            Code:
                            #!/bin/bash
                            #####################################################
                            # topcpu.sh
                            # returns names of most CPU time consuming processes
                            # as reported by 'top'
                            #####################################################
                            # 05-07-2010 by Jerry Lenk
                            # Use at your own risk!
                            #####################################################
                            
                            # set limit to 1st argument, or 2% if not specified
                            lim=$1
                            test -z $lim && lim=2
                            
                            # run 2 iterations of top in batch mode with 1 s delay
                            top -b -d1 -n2 |\
                            gawk --assign lim=$lim  'BEGIN { reply=""}
                                    END { print reply, "." }
                                    # if reply is empty, at least a period is returned
                            
                                    # in 2nd iteration, first 3 lines
                                    # add columns 9 (%cpu) and 12 (process name)
                                    # to reply string, if cpu at least lim%
                                    itr == 2 && NR <= 3 && $9 >= lim { reply=reply; printf(" %s% ",$9);  system("ps  --no-headers -o args -p " $1)   }
                            
                                    # count iterations by header lines beginning with "PID"
                                    # reset linenumber
                                    $1 == "PID" { NR=0 ; itr +=1 }
                                   '
                            # Only 2nd iteration of top is of interest because
                            # load values are calculated since previous iteration
                            However, I would like to remove the "." when there is no process over trigger (so empty result).
                            Do you know what is the output for empty on text item (just returning nothing turn the item into unsupported)?

                            This works great but is it possible to be able to get the PID and the user running it also as part of this?

                            Sorry my scripting and stuff really sucks so that is why I am asking
                            4 Zabbix Frontend Servers (Load balanced)
                            2 Zabbix App Servers (HA)
                            2 Zabbix Database Servers (HA)
                            18 Zabbix Proxy Servers (HA)
                            3897 Deployed Zabbix Agents
                            6161 Values per second
                            X-Layer Integration
                            Jaspersoft report Servers (HA)

                            Comment

                            • jerrylenk
                              Member
                              Zabbix Certified Specialist
                              • May 2010
                              • 62

                              #29
                              Originally posted by vlam
                              This works great but is it possible to be able to get the PID and the user running it also as part of this?

                              Sorry my scripting and stuff really sucks so that is why I am asking
                              Hi vlam,

                              in the line that starts with " itr ==", edit the "system"-command like this:
                              Code:
                              system("ps --no-headers [B]-o pid,user,args[/B] -p " $1)

                              Comment


                              • jancs
                                jancs commented
                                Editing a comment
                                So, did something like this made into std Zabbix or it still requires to use the (above) scripts to hunt for the most cpu-consuming processes?
                            • roberdaniel
                              Junior Member
                              • Apr 2019
                              • 22

                              #30
                              Hello all.
                              Is this workaround still needed in 2022?

                              Comment

                              Working...