Skip to content

Instantly share code, notes, and snippets.

@misterdjules
Created September 14, 2017 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save misterdjules/31a7c40b0cf792c2bfe2dc089e0c6911 to your computer and use it in GitHub Desktop.
Save misterdjules/31a7c40b0cf792c2bfe2dc089e0c6911 to your computer and use it in GitHub Desktop.
#!/usr/sbin/dtrace -s
#pragma D option quiet
moray*:::query-start
/copyinstr(arg1) == "SELECT name FROM buckets_config LIMIT 1"/
{
printf("arg1: %s\n", copyinstr(arg1));
starts[copyinstr(arg0)] = timestamp;
}
moray*:::query-done
/starts[copyinstr(arg0)]/
{
this->l = (timestamp - starts[copyinstr(arg0)]) / 1000;
this->t = walltimestamp % 1000000000;
printf("[%Y.%09d] Query %5s (%d) done < (%dus)\n",
walltimestamp, this->t, copyinstr(arg0), timestamp, this->l);
starts[copyinstr(arg0)] = 0;
this->l = 0;
this->t = 0;
}
bunyan*:::log-debug
/json(copyinstr(arg0), "msg") == "ping: entered"/
{
this->ping_start = timestamp;
}
bunyan*:::log-debug
/json(copyinstr(arg0), "msg") == "ping: done"/
{
this->l = (timestamp - this->ping_start) / 1000;
this->t = walltimestamp % 1000000000;
printf("%09d (%dus)\n", this->t, this->l);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment