FAQ

[mongodb-user] Activate profiler from the shell

Alejandro Fernandez
Feb 25, 2012 at 12:35 am
Hi all,

I am running MongoDB 2.0.2, 64 bits on Debian (from the official repo). I
am trying to activate the profiler from the shell, but it is not working. I
am probably missing something utterly stupid, but i have to say I am
stumped: I have googled for a solution but apparently nobody else has this
problem.

Following http://www.mongodb.org/display/DOCS/Database+Profiler:
db.version() 2.0.2
db.setProfilingLevel(2)
{ "was" : 2, "slowms" : 100, "ok" : 1 }
db.getProfilingLevel() 2
db.getProfilingStatus()
{ "was" : 2, "slowms" : 100 }
show profile
db.system.profile is empty
Use db.setProfilingLevel(2) will enable profiling
Use db.system.profile.find() to show raw profile entries
[... various queries later, both from the shell and using the PHP driver
...]
show profile
db.system.profile is empty
Use db.setProfilingLevel(2) will enable profiling
Use db.system.profile.find() to show raw profile entries

I have also tried level 1 with several ms thresholds. I have not tried
activating profiling using the PHP driver, but from the docs it should be
possible to activate it from the shell. Is it so? What can be the issue?

TIA,

Alex.

--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongodb-user@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
reply

Search Discussions

12 responses

  • Jeff Lee at Feb 25, 2012 at 1:02 am
    You may want to be sure that your shell is connected to the same database
    as your php app is connecting to.

    show dbs
    use [dbname]
    db.system.profile.find()

    On Fri, Feb 24, 2012 at 4:33 PM, Alejandro Fernandez wrote:

    Hi all,

    I am running MongoDB 2.0.2, 64 bits on Debian (from the official repo). I
    am trying to activate the profiler from the shell, but it is not working. I
    am probably missing something utterly stupid, but i have to say I am
    stumped: I have googled for a solution but apparently nobody else has this
    problem.

    Following http://www.mongodb.org/display/DOCS/Database+Profiler:
    db.version() 2.0.2
    db.setProfilingLevel(2)
    { "was" : 2, "slowms" : 100, "ok" : 1 }
    db.getProfilingLevel() 2
    db.getProfilingStatus()
    { "was" : 2, "slowms" : 100 }
    show profile
    db.system.profile is empty
    Use db.setProfilingLevel(2) will enable profiling
    Use db.system.profile.find() to show raw profile entries
    [... various queries later, both from the shell and using the PHP driver
    ...]
    show profile
    db.system.profile is empty
    Use db.setProfilingLevel(2) will enable profiling
    Use db.system.profile.find() to show raw profile entries

    I have also tried level 1 with several ms thresholds. I have not tried
    activating profiling using the PHP driver, but from the docs it should be
    possible to activate it from the shell. Is it so? What can be the issue?

    TIA,

    Alex.

    --
    You received this message because you are subscribed to the Google Groups
    "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to
    mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/mongodb-user?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Alexinblue at Feb 25, 2012 at 2:03 pm

    Jeff Lee wrote:
    You may want to be sure that your shell is connected to the same database
    as your php app is connecting to.

    show dbs
    use [dbname]
    db.system.profile.find()
    Confirmed: I have only one db with content, and it is the one I am
    connecting to, both from the PHP app and the shell.

    In any case, and to double-check, I am also doing queries from the shell
    and they do not show up in system.profile (nor in "show profile").

    Alex.

    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-user/-/Gf_FGpUuUCoJ.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Eliot Horowitz at Feb 25, 2012 at 4:23 pm
    Did you look in the server log for any error?
    On Sat, Feb 25, 2012 at 9:03 AM, alexinblue wrote:
    Jeff Lee wrote:
    You may want to be sure that your shell is connected to the same database
    as your php app is connecting to.

    show dbs
    use [dbname]
    db.system.profile.find()
    Confirmed: I have only one db with content, and it is the one I am
    connecting to, both from the PHP app and the shell.

    In any case, and to double-check, I am also doing queries from the shell and
    they do not show up in system.profile (nor in "show profile").

    Alex.

    --
    You received this message because you are subscribed to the Google Groups
    "mongodb-user" group.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/mongodb-user/-/Gf_FGpUuUCoJ.

    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to
    mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/mongodb-user?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Alejandro Fernandez at Feb 25, 2012 at 4:31 pm

    On Sat, Feb 25, 2012 at 5:23 PM, Eliot Horowitz wrote:

    Did you look in the server log for any error?
    Hum, no errors there, but a lot of queries with duration info, i.e. the
    missing profiling information. E.g.:
    query xxx.yyy ntoreturn:1 nreturned:1 reslen:220 0ms
    Is this information supposed to come out in the server logs? The
    documentation says that it should be stored in a capped collection, but
    maybe there is a switch somewhere... and I changed it unknowingly.

    Alex.

    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Adam C at Feb 27, 2012 at 12:17 pm
    Alex,

    When you connect via the shell you are by default in the test database
    and may be setting the profiling on that and getting nothing back
    because there are no operations actually hitting that database. Each
    database will have its own system.profile capped collection. So, can
    you try the following, sub in your own values for dbname and
    collection name:

    use <dbname>
    db.setProfilingLevel(2)
    db.<collection>.findOne()
    db.system.profile.findOne()

    Unless you have other operations hitting the collection, the final
    command should show you the execution of the findOne() command
    immediately preceding it.

    Because the "show profile" helper the most recent 5 profiled events
    that took at least 1ms to execute, it can miss extremely fast queries
    (when I ran the above first I ran show profile instead of the
    findOne() and came up empty because the response is sub 1ms).

    I have used the above on 2.0.2 to successfully grab profiling lines.

    Adam
    On Feb 25, 4:31 pm, Alejandro Fernandez wrote:
    On Sat, Feb 25, 2012 at 5:23 PM, Eliot Horowitz wrote:
    Did you look in the server log for any error?
    Hum, no errors there, but a lot of queries with duration info, i.e. the
    missing profiling information. E.g.:
    query xxx.yyy ntoreturn:1 nreturned:1 reslen:220 0ms
    Is this information supposed to come out in the server logs? The
    documentation says that it should be stored in a capped collection, but
    maybe there is a switch somewhere... and I changed it unknowingly.

    Alex.
    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Alejandro Fernandez at Feb 27, 2012 at 12:29 pm
    Hi Adam,

    Thanks for your reply.
    On Mon, Feb 27, 2012 at 1:17 PM, Adam C wrote:

    Alex,

    When you connect via the shell you are by default in the test database
    and may be setting the profiling on that and getting nothing back
    because there are no operations actually hitting that database. Each
    database will have its own system.profile capped collection. So, can
    you try the following, sub in your own values for dbname and
    collection name:

    use <dbname>
    db.setProfilingLevel(2)
    db.<collection>.findOne()
    db.system.profile.findOne()

    Unless you have other operations hitting the collection, the final
    command should show you the execution of the findOne() command
    immediately preceding it.

    Because the "show profile" helper the most recent 5 profiled events
    that took at least 1ms to execute, it can miss extremely fast queries
    (when I ran the above first I ran show profile instead of the
    findOne() and came up empty because the response is sub 1ms).

    I have used the above on 2.0.2 to successfully grab profiling lines.
    No luck here, transcript follows:

    ---8<---8<---8<---
    MongoDB shell version: 2.0.2
    connecting to: moveinblue
    use moveinblue
    switched to db moveinblue
    db.setProfilingLevel(2)
    { "was" : 0, "slowms" : 100, "ok" : 1 }
    db.xxx.findOne()
    {
    [... contents follows ...]
    }
    db.system.profile.findOne() null
    db.system.profile.find()
    ---8<---8<---8<---

    Alex.

    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Adam C at Feb 27, 2012 at 3:46 pm
    Alex,

    Can you run the getCmdLineOpts command as show here and post the
    output?

    http://www.mongodb.org/display/DOCS/getCmdLineOpts+command

    Thanks,

    Adam.
    On Feb 27, 12:29 pm, Alejandro Fernandez wrote:
    Hi Adam,

    Thanks for your reply.








    On Mon, Feb 27, 2012 at 1:17 PM, Adam C wrote:
    Alex,
    When you connect via the shell you are by default in the test database
    and may be setting the profiling on that and getting nothing back
    because there are no operations actually hitting that database.  Each
    database will have its own system.profile capped collection.  So, can
    you try the following, sub in your own values for dbname and
    collection name:
    use <dbname>
    db.setProfilingLevel(2)
    db.<collection>.findOne()
    db.system.profile.findOne()
    Unless you have other operations hitting the collection, the final
    command should show you the execution of the findOne() command
    immediately preceding it.
    Because the "show profile" helper the most recent 5 profiled events
    that took at least 1ms to execute, it can miss extremely fast queries
    (when I ran the above first I ran show profile instead of the
    findOne() and came up empty because the response is sub 1ms).
    I have used the above on 2.0.2 to successfully grab profiling lines.
    No luck here, transcript follows:

    ---8<---8<---8<---
    MongoDB shell version: 2.0.2
    connecting to: moveinblue> use moveinblue

    switched to db moveinblue> db.setProfilingLevel(2)

    { "was" : 0, "slowms" : 100, "ok" : 1 }> db.xxx.findOne()

    {
    [... contents follows ...]}
    db.system.profile.findOne() null
    db.system.profile.find()
    ---8<---8<---8<---

    Alex.
    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Alexinblue at Feb 27, 2012 at 11:20 pm
    Hi again,
    On Feb 27, 4:46 pm, Adam C wrote:
    Alex,

    Can you run the getCmdLineOpts command as show here and post the
    output?

    http://www.mongodb.org/display/DOCS/getCmdLineOpts+command
    Sure thing!

    ---8<---8<---8<---
    use admin
    switched to db admin
    db.runCommand({getCmdLineOpts: 1})
    {
    "argv" : [
    "/usr/bin/mongod",
    "--dbpath",
    "/var/moveinblue/mongodb",
    "--logpath",
    "/var/log/mongodb/mongodb.log",
    "run",
    "--config",
    "/path/to/config/mongodb.conf"
    ],
    "parsed" : {
    "auth" : "true",
    "bind_ip" : "127.0.0.1",
    "command" : [
    "run"
    ],
    "config" : "/path/to/config/mongodb.conf",
    "cpu" : "true",
    "dbpath" : "/path/to/db/mongodb",
    "journal" : "true",
    "logappend" : "true",
    "logpath" : "/var/log/mongodb/mongodb.log",
    "rest" : "true",
    "vvvvv" : "true"
    },
    "ok" : 1
    }
    ---8<---8<---8<---

    Hmmm, I thought I had disabled the rest interface... Anyway the port
    cannot be accessed from the outside.

    Thanks for all the help, guys. I suppose it must be very annoying to
    debug issues like this remotely -- but it helps infinitely.

    Alex.

    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Adam C at Feb 28, 2012 at 2:39 am
    I see you have auth enabled - I think you are hitting this bug in
    2.0.2:

    https://jira.mongodb.org/browse/SERVER-4754

    No fix available for it yet unfortunately, but we are working on it.

    Adam
    On Feb 27, 11:20 pm, alexinblue wrote:
    Hi again,
    On Feb 27, 4:46 pm, Adam C wrote:

    Alex,
    Can you run the getCmdLineOpts command as show here and post the
    output?
    http://www.mongodb.org/display/DOCS/getCmdLineOpts+command
    Sure thing!

    ---8<---8<---8<---> use admin

    switched to db admin> db.runCommand({getCmdLineOpts: 1})

    {
    "argv" : [
    "/usr/bin/mongod",
    "--dbpath",
    "/var/moveinblue/mongodb",
    "--logpath",
    "/var/log/mongodb/mongodb.log",
    "run",
    "--config",
    "/path/to/config/mongodb.conf"
    ],
    "parsed" : {
    "auth" : "true",
    "bind_ip" : "127.0.0.1",
    "command" : [
    "run"
    ],
    "config" : "/path/to/config/mongodb.conf",
    "cpu" : "true",
    "dbpath" : "/path/to/db/mongodb",
    "journal" : "true",
    "logappend" : "true",
    "logpath" : "/var/log/mongodb/mongodb.log",
    "rest" : "true",
    "vvvvv" : "true"
    },
    "ok" : 1}

    ---8<---8<---8<---

    Hmmm, I thought I had disabled the rest interface... Anyway the port
    cannot be accessed from the outside.

    Thanks for all the help, guys. I suppose it must be very annoying to
    debug issues like this remotely -- but it helps infinitely.

    Alex.
    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Alexinblue at Feb 28, 2012 at 7:04 am

    On Feb 28, 3:39 am, Adam C wrote:
    I see you have auth enabled - I think you are hitting this bug in
    2.0.2:

    https://jira.mongodb.org/browse/SERVER-4754

    No fix available for it yet unfortunately, but we are working on it.
    Ah, OK. Thanks a lot!

    Alex.

    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Tuure Laurinolli at Apr 11, 2012 at 11:36 am
    Hi,

    I seem to be suffering from the same problem re: no profiling output despite enabling profiling from shell. Mongostat shows that queries are being performed, yet nothing ends up in the profile.

    Basic information:
    show dbs
    admin (empty)
    database 0.203125GB
    local (empty)
    use database
    switched to db database
    db.getProfilingStatus()
    { "was" : 2, "slowms" : 100 }
    db.system.profile.find()
    show profile
    db.system.profile is empty
    Use db.setProfilingLevel(2) will enable profiling
    Use db.system.profile.find() to show raw profile entries

    My getCmdLineOpts looks as follows:
    use admin
    switched to db admin
    db.runCommand({getCmdLineOpts: 1})
    {
    "argv" : [
    "/usr/sbin/mongod",
    "--quiet",
    "-f",
    "/etc/mongodb.conf"
    ],
    "parsed" : {
    "auth" : "true",
    "bind_ip" : "127.0.0.1",
    "config" : "/etc/mongodb.conf",
    "dbpath" : "/var/lib/mongodb",
    "fork" : "true",
    "logappend" : "true",
    "logpath" : "/var/log/mongodb/mongodb.log",
    "nohttpinterface" : "true",
    "quiet" : true
    },
    "ok" : 1
    }


    On Feb 27, 2012, at 17:46 , Adam C wrote:

    Alex,

    Can you run the getCmdLineOpts command as show here and post the
    output?

    http://www.mongodb.org/display/DOCS/getCmdLineOpts+command

    Thanks,

    Adam.
    On Feb 27, 12:29 pm, Alejandro Fernandez wrote:
    Hi Adam,

    Thanks for your reply.








    On Mon, Feb 27, 2012 at 1:17 PM, Adam C wrote:
    Alex,
    When you connect via the shell you are by default in the test database
    and may be setting the profiling on that and getting nothing back
    because there are no operations actually hitting that database. Each
    database will have its own system.profile capped collection. So, can
    you try the following, sub in your own values for dbname and
    collection name:
    use <dbname>
    db.setProfilingLevel(2)
    db.<collection>.findOne()
    db.system.profile.findOne()
    Unless you have other operations hitting the collection, the final
    command should show you the execution of the findOne() command
    immediately preceding it.
    Because the "show profile" helper the most recent 5 profiled events
    that took at least 1ms to execute, it can miss extremely fast queries
    (when I ran the above first I ran show profile instead of the
    findOne() and came up empty because the response is sub 1ms).
    I have used the above on 2.0.2 to successfully grab profiling lines.
    No luck here, transcript follows:

    ---8<---8<---8<---
    MongoDB shell version: 2.0.2
    connecting to: moveinblue> use moveinblue

    switched to db moveinblue> db.setProfilingLevel(2)

    { "was" : 0, "slowms" : 100, "ok" : 1 }> db.xxx.findOne()

    {
    [... contents follows ...]}
    db.system.profile.findOne() null
    db.system.profile.find()
    ---8<---8<---8<---

    Alex.
    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
  • Scott Hernandez at Apr 11, 2012 at 2:31 pm
    Please create a new topic/thread for this with the output from these commands:

    db.getSiblingDB("admin").system.users.stats()
    use database
    db.system.profile.stats()
    db.setProfilingLevel(2)
    db.system.profile.stats()
    db.system.profile.find()
    db.system.profile.find()
    db.system.profile.stats()

    Also, include the version you are using of the server. db.serverStatus()

    On Wed, Apr 11, 2012 at 7:36 AM, Tuure Laurinolli
    wrote:
    Hi,

    I seem to be suffering from the same problem re: no profiling output despite enabling profiling from shell. Mongostat shows that queries are being performed, yet nothing ends up in the profile.

    Basic information:
    show dbs
    admin   (empty)
    database        0.203125GB
    local   (empty)
    use database
    switched to db database
    db.getProfilingStatus()
    { "was" : 2, "slowms" : 100 }
    db.system.profile.find()
    show profile
    db.system.profile is empty
    Use db.setProfilingLevel(2) will enable profiling
    Use db.system.profile.find() to show raw profile entries

    My getCmdLineOpts looks as follows:
    use admin
    switched to db admin
    db.runCommand({getCmdLineOpts: 1})
    {
    "argv" : [
    "/usr/sbin/mongod",
    "--quiet",
    "-f",
    "/etc/mongodb.conf"
    ],
    "parsed" : {
    "auth" : "true",
    "bind_ip" : "127.0.0.1",
    "config" : "/etc/mongodb.conf",
    "dbpath" : "/var/lib/mongodb",
    "fork" : "true",
    "logappend" : "true",
    "logpath" : "/var/log/mongodb/mongodb.log",
    "nohttpinterface" : "true",
    "quiet" : true
    },
    "ok" : 1
    }


    On Feb 27, 2012, at 17:46 , Adam C wrote:

    Alex,

    Can you run the getCmdLineOpts command as show here and post the
    output?

    http://www.mongodb.org/display/DOCS/getCmdLineOpts+command

    Thanks,

    Adam.

    On Feb 27, 12:29 pm, Alejandro Fernandez <alejan...@moveinblue.com>
    wrote:
    Hi Adam,

    Thanks for your reply.








    On Mon, Feb 27, 2012 at 1:17 PM, Adam C wrote:
    Alex,
    When you connect via the shell you are by default in the test database
    and may be setting the profiling on that and getting nothing back
    because there are no operations actually hitting that database.  Each
    database will have its own system.profile capped collection.  So, can
    you try the following, sub in your own values for dbname and
    collection name:
    use <dbname>
    db.setProfilingLevel(2)
    db.<collection>.findOne()
    db.system.profile.findOne()
    Unless you have other operations hitting the collection, the final
    command should show you the execution of the findOne() command
    immediately preceding it.
    Because the "show profile" helper the most recent 5 profiled events
    that took at least 1ms to execute, it can miss extremely fast queries
    (when I ran the above first I ran show profile instead of the
    findOne() and came up empty because the response is sub 1ms).
    I have used the above on 2.0.2 to successfully grab profiling lines.
    No luck here, transcript follows:

    ---8<---8<---8<---
    MongoDB shell version: 2.0.2
    connecting to: moveinblue> use moveinblue

    switched to db moveinblue> db.setProfilingLevel(2)

    { "was" : 0, "slowms" : 100, "ok" : 1 }> db.xxx.findOne()

    {
    [... contents follows ...]}
    db.system.profile.findOne() null
    db.system.profile.find()
    ---8<---8<---8<---

    Alex.
    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com.
    To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.

Related Discussions