public void processIPPortMetrics(Long kbytes,Long iops,StoragePort port,Long sampleTime){
  StringMap dbMetrics=port.getMetrics();
  _log.info(String.format("IP PortMetrics %s %s kbytes %d iops %d sampleTime %d",port.getNativeGuid(),portName(port),kbytes,iops,sampleTime));
  StorageSystem system=_dbClient.queryObject(StorageSystem.class,port.getStorageDevice());
  Long iopsValue=MetricsKeys.getLong(MetricsKeys.iopsValue,dbMetrics);
  Long kbytesValue=MetricsKeys.getLong(MetricsKeys.kbytesValue,dbMetrics);
  Long lastSampleTimeValue=MetricsKeys.getLong(MetricsKeys.lastSampleTime,dbMetrics);
  Long kbytesDelta=kbytes - kbytesValue;
  if (kbytesDelta < 0) {
    _log.info("Kbytes rolled over - delta is negative: " + kbytesDelta);
  }
  Long iopsDelta=iops - iopsValue;
  Long portSpeed=port.getPortSpeed();
  if (portSpeed == 0) {
    _log.info("Port speed is zero- assuming 1 GBit: " + port.getNativeGuid());
    portSpeed=1L;
  }
  Long maxKBytesPerSecond=portSpeed * KBYTES_PER_GBIT;
  Long secondsDelta=(sampleTime - lastSampleTimeValue) / MSEC_PER_SEC;
  if (secondsDelta < 0) {
    secondsDelta=-secondsDelta;
  }
  if (kbytesDelta >= 0 && secondsDelta > 0 && secondsDelta < SECONDS_PER_YEAR) {
    computePercentBusyAverages(kbytesDelta / secondsDelta,maxKBytesPerSecond,iopsDelta,dbMetrics,port.getNativeGuid(),portName(port),sampleTime,system);
    List<StoragePort> portList=new ArrayList<StoragePort>();
    portList.add(port);
    updateStaticPortUsage(portList);
    Double portMetric=computePortMetric(port);
    MetricsKeys.putDouble(MetricsKeys.portMetric,portMetric,dbMetrics);
    MetricsKeys.putLong(MetricsKeys.lastProcessingTime,System.currentTimeMillis(),dbMetrics);
  }
  MetricsKeys.putLong(MetricsKeys.kbytesValue,kbytes,dbMetrics);
  MetricsKeys.putLong(MetricsKeys.iopsValue,iops,dbMetrics);
  MetricsKeys.putLong(MetricsKeys.lastSampleTime,sampleTime,dbMetrics);
  port.setMetrics(dbMetrics);
  _dbClient.persistObject(port);
}

public void processIPPortMetrics ( Long kbytes , Long iops , StoragePort port , Long sampleTime ) { StringMap dbMetrics = port . getMetrics ( ) ; _log . info ( String . format ( "IP PortMetrics %s %s kbytes %d iops %d sampleTime %d" , port . getNativeGuid ( ) , portName ( port ) , kbytes , iops , sampleTime ) ) ; StorageSystem system = _dbClient . queryObject ( StorageSystem . class , port . getStorageDevice ( ) ) ; Long iopsValue = MetricsKeys . getLong ( MetricsKeys . iopsValue , dbMetrics ) ; Long kbytesValue = MetricsKeys . getLong ( MetricsKeys . kbytesValue , dbMetrics ) ; Long lastSampleTimeValue = MetricsKeys . getLong ( MetricsKeys . lastSampleTime , dbMetrics ) ; Long kbytesDelta = kbytes - kbytesValue ; if ( kbytesDelta < 0 ) { _log . info ( "Kbytes rolled over - delta is negative: " + kbytesDelta ) ; } Long iopsDelta = iops - iopsValue ; Long portSpeed = port . getPortSpeed ( ) ; if ( portSpeed == 0 ) { _log . info ( "Port speed is zero- assuming 1 GBit: " + port . getNativeGuid ( ) ) ; portSpeed = 1L ; } Long maxKBytesPerSecond = portSpeed * KBYTES_PER_GBIT ; Long secondsDelta = ( sampleTime - lastSampleTimeValue ) / MSEC_PER_SEC ; if ( secondsDelta < 0 ) { secondsDelta = - secondsDelta ; } if ( kbytesDelta >= 0 && secondsDelta > 0 && secondsDelta < SECONDS_PER_YEAR ) { computePercentBusyAverages ( kbytesDelta / secondsDelta , maxKBytesPerSecond , iopsDelta , dbMetrics , port . getNativeGuid ( ) , portName ( port ) , sampleTime , system ) ; List < StoragePort > portList = new ArrayList < StoragePort > ( ) ; portList . add ( port ) ; updateStaticPortUsage ( portList ) ; Double portMetric = computePortMetric ( port ) ; MetricsKeys . putDouble ( MetricsKeys . portMetric , portMetric , dbMetrics ) ; MetricsKeys . putLong ( MetricsKeys . lastProcessingTime , System . currentTimeMillis ( ) , dbMetrics ) ; } MetricsKeys . putLong ( MetricsKeys . kbytesValue , kbytes , dbMetrics ) ; MetricsKeys . putLong ( MetricsKeys . iopsValue , iops , dbMetrics ) ; MetricsKeys . putLong ( MetricsKeys . lastSampleTime , sampleTime , dbMetrics ) ; port . setMetrics ( dbMetrics ) ; _dbClient . persistObject ( port ) ; }
process a port metric sample . the values passed in are compared with the previous sample that was captured and used to calculate deltas and are then converted to a port percent busy metric . short and long term averages for the port percent busy metric are updated .
