code: public final Collection<Metric> gatherMetrics(final ICommandLine cl) throws MetricGatheringException {
          LOG.debug(getContext(), "check_mysql_query gather metrics");
          List<Metric> metrics = new ArrayList<Metric>();
          Mysql mysql = new Mysql(cl);
          Connection conn = null;
          try {
              conn = mysql.getConnection();
          } catch (ClassNotFoundException e) {
              LOG.error(getContext(), "Mysql driver library not found into the classpath" + ": download and put it in the same directory " + "of this plugin");
              throw new MetricGatheringException("CHECK_MYSQL_QUERY - CRITICAL: Error accessing the " + "MySQL server - JDBC driver not installed",
                      Status.CRITICAL, e);
          } catch (Exception e) {
              LOG.error(getContext(), "Error accessing the MySQL server", e);
              throw new MetricGatheringException("CHECK_MYSQL_QUERY - CRITICAL: Error accessing " + "the MySQL server - " + e.getMessage(),
                      Status.CRITICAL, e);
          }
  
          String query = cl.getOptionValue("query");
          Statement st = null;
          ResultSet set = null;
          try {
              st = conn.createStatement();
              st.execute(query);
              set = st.getResultSet();
              BigDecimal value = null;
              if (set.first()) {
                  value = set.getBigDecimal(1);
              }
  
              metrics.add(new Metric("rows", "CHECK_MYSQL_QUERY - Returned value is " + (value != null ? value.longValue() : null), value, null, null));
  
          } catch (SQLException e) {
              
              String message = e.getMessage();
              LOG.warn(getContext(), "Error executing plugin CheckMysqlQuery : " + message, e);
              throw new MetricGatheringException("CHECK_MYSQL_QUERY - CRITICAL: " + message, Status.CRITICAL, e);
          } finally {
              DBUtils.closeQuietly(set);
              DBUtils.closeQuietly(st);
              DBUtils.closeQuietly(conn);
          }
  
          return metrics;
      }
docs: Execute and gather metrics.
  
  @param cl
  the command line
  @throws MetricGatheringException
  on any error gathering metrics
  @return the metrics