title: How can I log "show processlist" when there are more than n queries?
body: <p>Our mysql processes can sometimes get backlogged and processes begin queuing up.  I'd like to debug when and why this occurs by logging the processlist during slow times.</p>
  
  <p>I'd like to run <code>show full processlist;</code> via a cron job and save output to text file if there are more than <code>50</code> rows returned.</p>
  
  <p>Can you point me in the right direction?</p>
  
  <p>For example:</p>
  
  <pre><code>echo "show full processlist;" | mysql -uroot &gt; processlist-`date +%F-%H-%M`.log
  </code></pre>
  
  <p>I'd like to run that only when the result contains the text <code>50 rows in set</code> (or greater than <code>50</code> rows).</p>