Skip to content

Instantly share code, notes, and snippets.

@kellymclaughlin
Last active October 2, 2017 20:32
Show Gist options
  • Save kellymclaughlin/cf55a8749c0b5437fee9555ad573ad66 to your computer and use it in GitHub Desktop.
Save kellymclaughlin/cf55a8749c0b5437fee9555ad573ad66 to your computer and use it in GitHub Desktop.
#!/usr/sbin/dtrace -qs
/*
* USAGE : pgwrites.d
*
* DESCRIPTION:
* Count buffer and wal dirty writes over time
*
*/
dtrace:::BEGIN
{
/* starting values */
bufferwrite = 0;
walwrite = 0;
bufferwrite_total = 0;
walwrite_total = 0;
seconds_total = 0;
}
postgresql*:::buffer-write-dirty-start
{
bufferwrite++;
}
postgresql*:::wal-buffer-write-dirty-start
{
walwrite++;
}
profile:::tick-1s
/seconds_total % 25 == 0/
{
printf("Buffer dirty writes: %6d WAL dirty writes: %6d\n",
bufferwrite, walwrite);
}
profile:::tick-1s
{
bufferwrite_total += bufferwrite;
walwrite_total += walwrite;
seconds_total++;
bufferwrite = 0;
walwrite = 0;
}
dtrace:::END
{
printf("\nAverage count/sec\n");
printf("Avg buffer writes: %6d Avg WAL writes: %6d\n",
bufferwrite_total/seconds_total,
walwrite_total/seconds_total);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment