mirror of https://github.com/apache/cloudstack.git
VM has wrong network statistics with multiple nics in shared networks (#4741)
If vm has multiple nics belonging to different shared networks then wrong statistics will be collected since network id is not considred as primary key. Make the change so that primary key contains network id so that traffic belonging to that corresponding network is shown If network id is not added to primary key then all the traffic of all shared networks will show up in one nic. Co-authored-by: Rakesh Venkatesh <rakeshv@apache.org>
This commit is contained in:
parent
073a54bd6e
commit
3c2360c9d2
|
|
@ -68,7 +68,7 @@ public class UsageNetworkDaoImpl extends GenericDaoBase<UsageNetworkVO, Long> im
|
|||
long aggBytesSent = rs.getLong(9);
|
||||
long eventTimeMillis = rs.getLong(10);
|
||||
if (hostId != 0) {
|
||||
returnMap.put(zoneId + "-" + accountId + "-Host-" + hostId, new UsageNetworkVO(accountId, zoneId, hostId, hostType, networkId, bytesSent,
|
||||
returnMap.put(zoneId + "-" + accountId + "-Host-" + hostId + "-Network-" + networkId, new UsageNetworkVO(accountId, zoneId, hostId, hostType, networkId, bytesSent,
|
||||
bytesReceived, aggBytesReceived, aggBytesSent, eventTimeMillis));
|
||||
} else {
|
||||
returnMap.put(zoneId + "-" + accountId, new UsageNetworkVO(accountId, zoneId, hostId, hostType, networkId, bytesSent, bytesReceived,
|
||||
|
|
|
|||
|
|
@ -774,3 +774,6 @@ ALTER TABLE cloud.user_vm_deploy_as_is_details MODIFY value text NOT NULL;
|
|||
UPDATE cloud.user_vm_details SET value='' WHERE value IS NULL;
|
||||
ALTER TABLE cloud.user_vm_details MODIFY value varchar(5120) NOT NULL;
|
||||
|
||||
ALTER TABLE cloud_usage.usage_network DROP PRIMARY KEY, ADD PRIMARY KEY (`account_id`,`zone_id`,`host_id`,`network_id`,`event_time_millis`);
|
||||
ALTER TABLE `cloud`.`user_statistics` DROP INDEX `account_id`, ADD UNIQUE KEY `account_id` (`account_id`,`data_center_id`,`public_ip_address`,`device_id`,`device_type`, `network_id`);
|
||||
ALTER TABLE `cloud_usage`.`user_statistics` DROP INDEX `account_id`, ADD UNIQUE KEY `account_id` (`account_id`,`data_center_id`,`public_ip_address`,`device_id`,`device_type`, `network_id`);
|
||||
|
|
|
|||
|
|
@ -669,7 +669,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
|
|||
if (userStats != null) {
|
||||
for (UserStatisticsVO userStat : userStats) {
|
||||
if (userStat.getDeviceId() != null) {
|
||||
String hostKey = userStat.getDataCenterId() + "-" + userStat.getAccountId() + "-Host-" + userStat.getDeviceId();
|
||||
String hostKey = userStat.getDataCenterId() + "-" + userStat.getAccountId() + "-Host-" + userStat.getDeviceId() + "-Network-" + userStat.getNetworkId();
|
||||
UserStatisticsVO hostAggregatedStat = aggregatedStats.get(hostKey);
|
||||
if (hostAggregatedStat == null) {
|
||||
hostAggregatedStat =
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ public class NetworkUsageParser {
|
|||
long zoneId = usageNetwork.getZoneId();
|
||||
String key = "" + zoneId;
|
||||
if (usageNetwork.getHostId() != 0) {
|
||||
key += "-Host" + usageNetwork.getHostId();
|
||||
key += "-Host" + usageNetwork.getHostId() + "-Network-" + usageNetwork.getNetworkId();
|
||||
}
|
||||
NetworkInfo networkInfo = networkUsageByZone.get(key);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue