Ad Widget

Collapse

Monitoring MongoDB? (mikoomi plugin)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chubz
    Junior Member
    • Jul 2012
    • 11

    #1

    Monitoring MongoDB? (mikoomi plugin)

    Hi all, I am new to zabbix so please bear with me

    So I got my zabbix server set up, its monitoring stuff no problem. All those pretty graphs and what not. Now I'm trying to monitor MongoDB on it. I have zabbix server and mongodb installed on the same machine. Mongo is using port 27017 and zabbix is using 10050. I am running this on fedora 14. I am using zabbix 2.0 and mongodb 1.8.1 When I add the host to be monitored, I try to retrieve data but its not retrieving any data. On the dashboard, it says that "No Data Received in 5 minutes". In fact whenever i try to do zabbix_get to any item, I get the following error. "zabbix_get [12270]: Get value error: ZBX_TCP_READ() failed: [104] Connection reset by peer"

    Any help/knowledge would be appreciated!

    Andrew
  • bcarpio
    Member
    • Jun 2008
    • 96

    #2
    Tell us more

    Andrew,

    Can you tell us more about where you have your mikoomi-mongodb-plugin.php and mikoomi_mongodb_plugin.sh files?

    These need to be on the server and located in the directory "ExternalScripts" which is defined in your zabbix_serverd.conf file.

    If these files are in the "ExternalScripts" directory make sure they are owned by the zabbix user and group and make sure they are executable.

    I had some issues with the mikoomi_mongodb_plugin.sh so I had to change it here are my changes:



    Make sure BASE_DIR is updated to reflect your environment. If you change the mikoomi_mongodb_plugin.sh to the one I just posted you need to go into your zabbix GUI and go to your "Template_MongoDB", filter on Type: "External Check" and change the Key value to: mikoomi_mongodb_plugin.sh["{HOSTNAME}"]

    Once you do that you should be good to go.. make sure to run the mikoomi_mongodb_plugin.sh with the HOSTNAME configured in zabbix for the host and if it works you should be good.

    Comment

    • chubz
      Junior Member
      • Jul 2012
      • 11

      #3
      My two files for the plugin are located here
      /etc/zabbix/externalscripts/mikoomi-mongodb-plugin.php
      /etc/zabbix/externalscripts/mikoomi-mongodb-plugin.sh

      Also did you been zabbix_agentd.conf? Because I couldn't find zabbix_serverd.conf anywhere. (Even in agentd.conf file I didn't find any parameter "ExternalScripts")

      And lastly, when you say to change the key value to "mikoomi_mongodb_plugin.sh["{HOSTNAME}"]" Am I supposed to rename the HOSTNAME in it? You lost me a little when you said "make sure to run the mikoomi_mongodb_plugin.sh with the HOSTNAME configured in zabbix for the host and if it works you should be good"

      Also am I supposed to change any of the macros?

      Sorry I'm still learning :x

      Thanks for helping me out
      Andrew
      Last edited by chubz; 03-07-2012, 23:44.

      Comment

      • bcarpio
        Member
        • Jun 2008
        • 96

        #4
        Ummm

        Are the mikoomi scripts on the zabbix server? If not they need to be. Also I mistyped earlier, you need to look in zabbix_server.conf on the zabbix server for the "ExternalScripts" value and make sure the Mikoomi scripts are in that path.

        When I say change the key to "mikoomi_mongodb_plugin.sh["{HOSTNAME}"]" don't change the {HOSTNAME} that is a macro and gets translated by the script.

        Also if your script is mikoomi-mongodb-plugin.sh then change the key to

        "mikoomi-mongodb-plugin.sh["{HOSTNAME}"]"

        When I said to run mikoomi-mongodb-plugin.sh, do that from the command line and feed it an actual hostname yes.. don't use the macro in that case.

        Comment

        • chubz
          Junior Member
          • Jul 2012
          • 11

          #5
          Yes they are in the correct directory. When I run the script, what kind of output am I supposed to get? I just keep getting "0" Also do I need to keep the other two macros for the template? Or get rid of those?

          Comment

          • bcarpio
            Member
            • Jun 2008
            • 96

            #6
            Output

            Its good you are getting a 0. If the script ran properly there should be two files in /tmp one is a .data file and the other is a .log file. The .data file is the data that was sent to zabbix using zabbix_sender (the php script calls zabbix_sender) and .log file is the result of the zabbix_sender command.

            You should also see data populate in the Zabbix GUI for the host.

            Comment

            • chubz
              Junior Member
              • Jul 2012
              • 11

              #7
              I think my zabbix sender is not working properly. I ran the script and there was no .data file in my tmp folder. I checked the script if it was written right, where the data and log files go. It was just never written I believe. Also does this plugin use zabbix_get ? Because I keep getting connection refused.

              Comment

              • bcarpio
                Member
                • Jun 2008
                • 96

                #8
                Zabbix_sender is not the problem

                Your zabbix_sender isn't the problem if there is no .data file. The php script creates the data file. I am not sure what else I can do to help you, you need to provide way more info in your posts like what the exact command your running is etc..

                Comment

                • chubz
                  Junior Member
                  • Jul 2012
                  • 11

                  #9
                  Okay I fixed some stuff. I see my .data and .log files in /tmp. But they are empty. Are they supposed to be empty? I'm on my zabbix GUI and I see that it still isn't collecting any data. Hmmm. Does zabbix_agetnd.conf need to be modified at all?

                  Comment

                  • andreslucena
                    Junior Member
                    • Nov 2011
                    • 5

                    #10
                    Originally posted by chubz
                    I see my .data and .log files in /tmp. But they are empty. Are they supposed to be empty?
                    No, they aren't supposed to be empty.
                    • .data is the file prepared to zabbix_sender with a "Hostname Key Value" format.
                    • .log is the output of the script, showing information about zabbix_sender activity


                    Originally posted by chubz
                    Does zabbix_agetnd.conf need to be modified at all?
                    No as far as I know.

                    It seems like the PHP script isn't executing well. Have you follow the plugin installation process? Specially the dependencies section.

                    You should try executing the command yourself and see the output.

                    Also you should check out the zabbix_server log and see for some errors.

                    Comment

                    • chubz
                      Junior Member
                      • Jul 2012
                      • 11

                      #11
                      I'm pretty positive I installed all the dependencies correctly...

                      You should try executing the command yourself and see the output.
                      What do you mean? Sorry can you give an example?

                      This is just part of the log.

                      7121:20120702:110523.013 executing housekeeper
                      7121:20120702:110525.755 housekeeper deleted: 13824 records from history and trends, 0 records of deleted items, 0 events, 0 alerts, 0 sessions
                      7121:20120702:120526.177 executing housekeeper
                      7121:20120702:120528.720 housekeeper deleted: 13824 records from history and trends, 0 records of deleted items, 0 events, 0 alerts, 0 sessions
                      7126:20120702:123504.288 item [MongoDB:mikoomi-mongodb-plugin.sh[-h {$SERVER} -p {$PORT} -z {HOSTNAME}]] became not supported: /usr/share/zabbix/externalscripts/mikoomi-mongodb-plugin.sh: [2] No such file or directory
                      7121:20120702:130529.123 executing housekeeper
                      7121:20120702:130531.863 housekeeper deleted: 13824 records from history and trends, 0 records of deleted items, 0 events, 0 alerts, 0 sessions

                      ...

                      5546:20120706:180008.125 item [MongoDB:mikoomi-mongodb-plugin.sh["{HOSTNAME}"]] became not supported: timeout while executing a shell script
                      5521:20120706:180049.902 enabling Zabbix agent checks on host [Zabbix server]: host became available
                      5544:20120706:180303.791 item [MongoDB:mikoomi-mongodb-plugin.sh["{HOSTNAME}"]] became supported
                      5546:20120706:181606.241 item [MongoDB:mikoomi-mongodb-plugin.sh["{HOSTNAME}"]] became not supported: timeout while executing a shell script

                      Comment

                      • andreslucena
                        Junior Member
                        • Nov 2011
                        • 5

                        #12
                        Originally posted by chubz
                        What do you mean? Sorry can you give an example?
                        You need to run this, with the correct parameters:

                        mikoomi-mongodb-plugin.sh -h {$SERVER} -p {$PORT} -z {HOSTNAME}


                        Originally posted by chubz
                        7126:20120702:123504.288 item [MongoDB:mikoomi-mongodb-plugin.sh[-h {$SERVER} -p {$PORT} -z {HOSTNAME}]] became not supported: /usr/share/zabbix/externalscripts/mikoomi-mongodb-plugin.sh: [2] No such file or directory
                        Here is the problem: you're not putting the ExternalScript configuration right in zabbix_server. You can set it up right or move the script to the folder where it's trying to find it (/usr/share/zabbix/externalscripts/)

                        Comment

                        • chubz
                          Junior Member
                          • Jul 2012
                          • 11

                          #13
                          Okay so I ended up starting all over from a clean slate of fedora 14 on a VM.

                          I ran the script and I have a data file with the data. But the log file gives me this.


                          Code:
                          mikoomi-mongodb-plugin.php:Successfully connected to mongoDB using connect string localhost:27017
                          zabbix_sender [1216]: Warning: [line 39] 'Key value' required
                          
                          zabbix_sender [1216]: Warning: [line 41] 'Key value' required
                          
                          zabbix_sender [1216]: Warning: [line 42] 'Key value' required
                          
                          zabbix_sender [1216]: Warning: [line 43] 'Key value' required
                          
                          zabbix_sender [1216]: Warning: [line 44] 'Key value' required
                          
                          zabbix_sender [1216]: Warning: [line 45] 'Key value' required
                          
                          zabbix_sender [1216]: Warning: [line 46] 'Key value' required
                          
                          zabbix_sender [1216]: Warning: [line 47] 'Key value' required
                          
                          zabbix_sender [1216]: Warning: [line 48] 'Key value' required
                          
                          zabbix_sender [1216]: Warning: [line 66] 'Key value' required
                          
                          zabbix_sender [1216]: Warning: [line 68] 'Key value' required
                          
                          zabbix_sender [1217]: DEBUG: answer [{
                          
                              "response":"success",
                          
                              "info":"Processed 0 Failed 62 Total 62 Seconds spent 0.000852"}]
                          
                          info from server: "Processed 0 Failed 62 Total 62 Seconds spent 0.000852"
                          
                          sent: 62; skipped: 11; total: 73
                          Here is my data file

                          Code:
                          localhost mongodb_version 1.6.4
                          localhost uptime 4955
                          localhost globalLock_lockTime 55441
                          localhost globalLock_currentQueue_total 0
                          localhost globalLock_currentQueue_readers 0
                          localhost globalLock_currentQueue_writers 0
                          localhost mem_bits 64
                          localhost mem_resident 19
                          localhost mem_virtual 628
                          localhost connections_current 1
                          localhost connections_available 818
                          localhost extra_info_heap_usage 1.33
                          localhost extra_info_page_faults 60
                          localhost indexCounters_btree_accesses 1
                          localhost indexCounters_btree_hits 1
                          localhost indexCounters_btree_misses 0
                          localhost indexCounters_btree_resets 0
                          localhost indexCounters_btree_missRatio 0
                          localhost backgroundFlushing_flushes 82
                          localhost backgroundFlushing_total_ms 1030
                          localhost backgroundFlushing_average_ms 12.560975609756
                          localhost backgroundFlushing_last_ms 2
                          localhost cursors_totalOpen 0
                          localhost cursors_clientCursors_size 0
                          localhost cursors_timedOut 0
                          localhost opcounters_insert 1
                          localhost opcounters_query 5
                          localhost opcounters_update 0
                          localhost opcounters_delete 0
                          localhost opcounters_getmore 0
                          localhost opcounters_command 15
                          localhost asserts_regular 0
                          localhost asserts_warning 0
                          localhost asserts_msg 0
                          localhost asserts_user 0
                          localhost asserts_rollovers 0
                          localhost network_inbound_traffic_mb 0
                          localhost network_outbound_traffic_mb 0
                          localhost network_requests 
                          localhost write_backs_queued 0
                          localhost logging_commits 
                          localhost logging_journal_writes_mb 
                          localhost logging_datafile_writes_mb 
                          localhost logging_commits_in_writelock 
                          localhost logging_early_commits 
                          localhost logging_log_buffer_prep_time_ms 
                          localhost logging_journal_write_time_ms 
                          localhost logging_datafile_write_time_ms 
                          localhost db_count 3
                          localhost totalSize_mb 208
                          localhost database_info admin: collections=3, objects=5, indexes=1, avgObjSize=54.4, dataSize=272, indexSize=8192, storageSize=11776, numExtents=3, fileSize=201326592 || local: collections=0, objects=0, indexes=0, avgObjSize=NAN, dataSize=0, indexSize=0, storageSize=0, numExtents=0, fileSize=0 || 
                          localhost is_sharded No
                          localhost total_collection_count 3
                          localhost total_object_count 5
                          localhost total_index_count 1
                          localhost db_collections admin=3 || local=0 || 
                          localhost db_objects admin=5 || local=0 || 
                          localhost db_indexes admin=1 || local=0 || 
                          localhost db_avgObjSize admin=54.4 || local=NAN || 
                          localhost db_dataSize admin=272 || local=0 || 
                          localhost db_indexSize admin=8192 || local=0 || 
                          localhost db_storageSize admin=11776 || local=0 || 
                          localhost db_numExtents admin=3 || local=0 || 
                          localhost db_fileSize admin=201326592 || local=0 || 
                          localhost is_replica_set Yes
                          localhost replica_set_name 
                          localhost replica_set_member_count 0
                          localhost replica_set_hosts 
                          localhost repl_member_attention_state_count 0
                          localhost repl_member_attention_state_info empty
                          localhost mongoDB_plugin_data_collection_time 0
                          localhost mongoDB_plugin_version 0.3
                          localhost mongoDB_plugin_checksum ea0ab41f03bff785772dfaf9efe85f80
                          So those lines from the log file that were giving me errors correspond to the line number in the data file. (network_requests, logging_commits, logging_journal_writes_mb, logging_datafile_writes_mb, logging_data file_writes_mb, logging_commits_in_writelock, logging_early_commits, logging_log_buffer_prep_time_ms, logging_journal_write_time_ms, logging_datafile_write_time_ms, localhost replica_set_name, localhost replica_set_hosts)
                          Any ideas? Is there something I need to change in the php script? Perhaps the syntax is wrong or something in the script? I do not know php well...

                          Zabbix gui still shows that "No data received in 5 minutes" Even though my script did gather most of the data. And my log did say it sent most of it. And still, no data populated on my zabbix GUI. Is something wrong with my zabbix sender? How come I can't send data to my GUI? If my data did send to zabbix, and my GUI is just not showing it, how can I check the data? If I have mysql linked up to my zabbix, should it be in one of the databases?

                          Should I be using any macros at all?
                          Last edited by chubz; 11-07-2012, 23:04.

                          Comment

                          • jdehnert
                            Junior Member
                            • Jun 2011
                            • 10

                            #14
                            Same issue

                            I'm running int the same issue with my Zabbix server and the latest Mikoomi MongoDB scripts.

                            I'm running Zabbix 2.0.4 on Centos 6.3, installed via yum.

                            The basic Linux OS templates are working fine. My files are in /etc/zabbix/externalscripts/ and the permissions are set so that they are owned and executable by zabbix.

                            If I run the shell script by hand...
                            ./mikoomi-mongodb-plugin.sh -D -h dev-web-1 -p 27017 -z dev-web-1
                            it returns "0" and creates 2 files in /tmp. The data one seems to have data, but the log file has the following message...
                            mikoomi-mongodb-plugin.php:Successfully connected to mongoDB using connect string 10.183.37.168:27017
                            sh: zabbix_sender: command not found

                            I'm using the shell script that came with the the php file. I could switch to the posted simplified version, but I'm not sure what I need to point the BASE_DIR variable to exactly.

                            There also seemed to be 2 macros that were already set. Here is what the macros section looks like now...



                            So $HOSTNAME and $PORT were already there when I went to install the other 3 macros.

                            One other item that might be causing me grief. When I went to import the template, it threw out an error about Memory already existing in a template. I edited the XML file an changed "Memory" to "MongoDB Memory" and the resolved the conflict and allowed me to import the template. I don't think this could be causing a problem as it was just an Application Name holding 5 trappers that are different from the apps in the system default templates, but it merits mentioning in case I'm really wrong about that.

                            I hope this thread is still being monitored so I don't have to run through this again in a new one.

                            Comment

                            • robnc63
                              Junior Member
                              • Feb 2013
                              • 3

                              #15
                              Just now trying to get this to work, myself.

                              Tried to execute the "default" version of mikoomi-mongodb-plugin.sh:

                              HTML Code:
                              $ ./mikoomi-mongodb-plugin.sh mymongo.mydomain.com 27017 myuser mypassword "MongoDB Zabbix"
                              PHP Warning:  Module 'mysql' already loaded in Unknown on line 0
                              
                              mikoomi-mongodb-plugin.php Version 0.3
                              Usage : mikoomi-mongodb-plugin.php [-D] [-h <mongoDB Server Host>] [-p <mongoDB Port>] [-u <username>] [-x <password>] -z <Zabbix_Name>
                              where
                                 -D = Run in detail/debug mode
                                 -h = Hostname or IP address of server running mongoDBB
                                 -p = Port number on which to connect to the mongod or mongos process
                                 -z = Name (hostname) of mongoDB instance or cluster in the Zabbix UI
                                 -u = User name for database authentication
                                 -x = Password for database authentication
                              0
                              I verified that nothing was written to the /tmp folder (expected, based on the output).

                              I then updated the mikoomi-mongodb-plugin.sh file to match bcarpio's version (editing the BASE_DIR to match the environment for my system).

                              Code:
                              #!/bin/bash
                              BASE_DIR=/usr/local/zabbix/externalscripts
                              /usr/bin/php $BASE_DIR/mikoomi-mongodb-plugin.php -h $1 -p 27017 -z $1
                              echo 0
                              and tested it:

                              HTML Code:
                              $ ./mikoomi-mongodb-plugin.sh mymongo.mydomain.com 27017 myuser mypassword "MongoDB Zabbix"
                              PHP Warning:  Module 'mysql' already loaded in Unknown on line 0
                              0
                              After doing this, I now see the .data and .log files written to the /tmp folder. So far, so good.

                              Here's the bit that is confusing me:

                              If you change the mikoomi_mongodb_plugin.sh to the one I just posted you need to go into your zabbix GUI and go to your "Template_MongoDB", filter on Type: "External Check" and change the Key value to: mikoomi_mongodb_plugin.sh["{HOSTNAME}"]
                              I'm really confused by this, as I have no idea what this means. If I log into the Zabbix GUI and navigate to Configuration->Templates and then click on the "Template MongoDB" template, I do not see how to "filter" on "anything". I see a "Search" field (but that's use for searching for templates), and links for "Applications", "Items", "Triggers", "Graphs", "Screens" and "Discovery Rules". I've looked through all of these and I have no clue what was meant by "change the key".

                              For the Host linked to that template, I have defined the following macros (based on the setup documentation in GitHub):

                              {$MONGODB_HOSTNAME}
                              {$MONGODB_PASS}
                              {$MONGODB_PORT}
                              {$MONGODB_USER}
                              {$MONGODB_ZABBIX_NAME}

                              Does "change the key" actually mean "change the macro"? Can someone step me through this part?

                              I'm using Zabbix 2.0.3 if that is of any help.

                              Comment

                              Working...