Skip to content

Commit

Permalink
syncing with saas
Browse files Browse the repository at this point in the history
  • Loading branch information
alphadev4 committed Nov 8, 2024
1 parent 6a3597d commit 18251d5
Show file tree
Hide file tree
Showing 250 changed files with 5,630 additions and 461 deletions.
3 changes: 2 additions & 1 deletion collectors/aws/apigateway/getClientCertificate.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ module.exports = function(AWSConfig, collection, retries, callback) {
collection.apigateway.getClientCertificate[AWSConfig.region][stage.clientCertificateId].err = err;
return pCb();
}
collection.apigateway.getClientCertificate[AWSConfig.region][stage.clientCertificateId].data = data;
if (data) collection.apigateway.getClientCertificate[AWSConfig.region][stage.clientCertificateId].data = data;

pCb();
});

Expand Down
2 changes: 1 addition & 1 deletion collectors/aws/apigateway/getIntegration.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
return mCb();
}

collection.apigateway.getIntegration[AWSConfig.region][api.id][resource.id][methodKey].data = data;
if (data) collection.apigateway.getIntegration[AWSConfig.region][api.id][resource.id][methodKey].data = data;
mCb();
});
}, function(){
Expand Down
2 changes: 1 addition & 1 deletion collectors/aws/appmesh/describeVirtualGateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
collection.appmesh.describeVirtualGateway[AWSConfig.region][gateway.virtualGatewayName].err = err;
}

collection.appmesh.describeVirtualGateway[AWSConfig.region][gateway.virtualGatewayName].data = data;
if (data) collection.appmesh.describeVirtualGateway[AWSConfig.region][gateway.virtualGatewayName].data = data;
pCb();
});

Expand Down
2 changes: 1 addition & 1 deletion collectors/aws/autoscaling/describeLaunchConfigurations.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
if (err) {
collection.autoscaling.describeLaunchConfigurations[AWSConfig.region][asg.AutoScalingGroupARN].err = err;
}
collection.autoscaling.describeLaunchConfigurations[AWSConfig.region][asg.AutoScalingGroupARN].data = data;
if (data) collection.autoscaling.describeLaunchConfigurations[AWSConfig.region][asg.AutoScalingGroupARN].data = data;

cb();
});
Expand Down
2 changes: 1 addition & 1 deletion collectors/aws/cloudfront/getDistribution.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
if (err) {
collection.cloudfront.getDistribution[AWSConfig.region][distribution.Id].err = err;
}
collection.cloudfront.getDistribution[AWSConfig.region][distribution.Id].data = data;
if (data) collection.cloudfront.getDistribution[AWSConfig.region][distribution.Id].data = data;
cb();
});

Expand Down
2 changes: 1 addition & 1 deletion collectors/aws/cloudwatch/getEcMetricStatistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
if (err) {
collection.cloudwatch.getEcMetricStatistics[AWSConfig.region][cluster.CacheClusterId].err = err;
}
collection.cloudwatch.getEcMetricStatistics[AWSConfig.region][cluster.CacheClusterId].data = data;
if (data) collection.cloudwatch.getEcMetricStatistics[AWSConfig.region][cluster.CacheClusterId].data = data;
cb();
});

Expand Down
2 changes: 1 addition & 1 deletion collectors/aws/cloudwatch/getEsMetricStatistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
if (err) {
collection.cloudwatch.getEsMetricStatistics[AWSConfig.region][domain.DomainName].err = err;
}
collection.cloudwatch.getEsMetricStatistics[AWSConfig.region][domain.DomainName].data = data;
if (data) collection.cloudwatch.getEsMetricStatistics[AWSConfig.region][domain.DomainName].data = data;
cb();
});

Expand Down
2 changes: 1 addition & 1 deletion collectors/aws/cloudwatch/getRdsMetricStatistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
if (err) {
collection.cloudwatch.getRdsMetricStatistics[AWSConfig.region][instance.DBInstanceIdentifier].err = err;
}
collection.cloudwatch.getRdsMetricStatistics[AWSConfig.region][instance.DBInstanceIdentifier].data = data;
if (data) collection.cloudwatch.getRdsMetricStatistics[AWSConfig.region][instance.DBInstanceIdentifier].data = data;
cb();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
if (err) {
collection.cloudwatch.getRdsReadIOPSMetricStatistics[AWSConfig.region][instance.DBInstanceIdentifier].err = err;
}
collection.cloudwatch.getRdsReadIOPSMetricStatistics[AWSConfig.region][instance.DBInstanceIdentifier].data = data;
if (data) collection.cloudwatch.getRdsReadIOPSMetricStatistics[AWSConfig.region][instance.DBInstanceIdentifier].data = data;
cb();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
if (err) {
collection.cloudwatch.getRdsWriteIOPSMetricStatistics[AWSConfig.region][instance.DBInstanceIdentifier].err = err;
}
collection.cloudwatch.getRdsWriteIOPSMetricStatistics[AWSConfig.region][instance.DBInstanceIdentifier].data = data;
if (data) collection.cloudwatch.getRdsWriteIOPSMetricStatistics[AWSConfig.region][instance.DBInstanceIdentifier].data = data;
cb();
});

Expand Down
2 changes: 1 addition & 1 deletion collectors/aws/cloudwatch/getredshiftMetricStatistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
if (err) {
collection.cloudwatch.getredshiftMetricStatistics[AWSConfig.region][cluster.ClusterIdentifier].err = err;
}
collection.cloudwatch.getredshiftMetricStatistics[AWSConfig.region][cluster.ClusterIdentifier].data = data;
if (data) collection.cloudwatch.getredshiftMetricStatistics[AWSConfig.region][cluster.ClusterIdentifier].data = data;
cb();
});

Expand Down
2 changes: 1 addition & 1 deletion collectors/aws/codebuild/batchGetProjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
if (err) {
collection.codebuild.batchGetProjects[AWSConfig.region][project].err = err;
}
collection.codebuild.batchGetProjects[AWSConfig.region][project].data = data;
if (data) collection.codebuild.batchGetProjects[AWSConfig.region][project].data = data;
cb();
});
}, function(){
Expand Down
2 changes: 1 addition & 1 deletion collectors/aws/connect/instanceAttachmentStorageConfigs.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
if (err) {
collection.connect.instanceAttachmentStorageConfigs[AWSConfig.region][instance.Id].err = err;
}
collection.connect.instanceAttachmentStorageConfigs[AWSConfig.region][instance.Id].data = data;
if (data) collection.connect.instanceAttachmentStorageConfigs[AWSConfig.region][instance.Id].data = data;
cb();
});
}, function(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
if (err) {
collection.connect.listInstanceCallRecordingStorageConfigs[AWSConfig.region][instance.Id].err = err;
}
collection.connect.listInstanceCallRecordingStorageConfigs[AWSConfig.region][instance.Id].data = data;
if (data) collection.connect.listInstanceCallRecordingStorageConfigs[AWSConfig.region][instance.Id].data = data;
cb();
});
}, function(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
if (err) {
collection.connect.listInstanceChatTranscriptStorageConfigs[AWSConfig.region][instance.Id].err = err;
}
collection.connect.listInstanceChatTranscriptStorageConfigs[AWSConfig.region][instance.Id].data = data;
if (data) collection.connect.listInstanceChatTranscriptStorageConfigs[AWSConfig.region][instance.Id].data = data;
cb();
});
}, function(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
if (err) {
collection.connect.listInstanceExportedReportStorageConfigs[AWSConfig.region][instance.Id].err = err;
}
collection.connect.listInstanceExportedReportStorageConfigs[AWSConfig.region][instance.Id].data = data;
if (data) collection.connect.listInstanceExportedReportStorageConfigs[AWSConfig.region][instance.Id].data = data;
cb();
});
}, function(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
if (err) {
collection.connect.listInstanceMediaStreamStorageConfigs[AWSConfig.region][instance.Id].err = err;
}
collection.connect.listInstanceMediaStreamStorageConfigs[AWSConfig.region][instance.Id].data = data;
if (data) collection.connect.listInstanceMediaStreamStorageConfigs[AWSConfig.region][instance.Id].data = data;
cb();
});
}, function(){
Expand Down
2 changes: 1 addition & 1 deletion collectors/aws/dynamodb/describeContinuousBackups.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
if (err) {
collection.dynamodb.describeContinuousBackups[AWSConfig.region][table].err = err;
}
collection.dynamodb.describeContinuousBackups[AWSConfig.region][table].data = data;
if (data) collection.dynamodb.describeContinuousBackups[AWSConfig.region][table].data = data;
cb();
});
}, function(){
Expand Down
2 changes: 1 addition & 1 deletion collectors/aws/dynamodb/describeTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
if (err) {
collection.dynamodb.describeTable[AWSConfig.region][table].err = err;
}
collection.dynamodb.describeTable[AWSConfig.region][table].data = data;
if (data) collection.dynamodb.describeTable[AWSConfig.region][table].data = data;
cb();
});
}, function(){
Expand Down
2 changes: 1 addition & 1 deletion collectors/aws/dynamodb/listBackups.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
if (err) {
collection.dynamodb.listBackups[AWSConfig.region][table].err = err;
}
collection.dynamodb.listBackups[AWSConfig.region][table].data = data;
if (data) collection.dynamodb.listBackups[AWSConfig.region][table].data = data;
cb();
});
}, function(){
Expand Down
2 changes: 1 addition & 1 deletion collectors/aws/ec2/describeSnapshotAttribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
if (err) {
collection.ec2.describeSnapshotAttribute[AWSConfig.region][snapshot.SnapshotId].err = err;
}
collection.ec2.describeSnapshotAttribute[AWSConfig.region][snapshot.SnapshotId].data = data;
if (data) collection.ec2.describeSnapshotAttribute[AWSConfig.region][snapshot.SnapshotId].data = data;
cb();
});
}, function(){
Expand Down
21 changes: 15 additions & 6 deletions collectors/aws/ec2/describeSnapshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ module.exports = function(AWSConfig, collection, retries, callback) {
var ec2 = new AWS.EC2(AWSConfig);
var sts = new AWS.STS(AWSConfig);
var paginating = false;
var maxSnapshots = 30000; // Limit the collection to 30,000 snapshots
var createdTime = new Date();
createdTime.setDate(createdTime.getDate() - 30);

helpers.makeCustomCollectorCall(sts, 'getCallerIdentity', {}, retries, null, null, null, function(stsErr, stsData) {
if (stsErr || !stsData.Account) {
Expand Down Expand Up @@ -38,16 +41,22 @@ module.exports = function(AWSConfig, collection, retries, callback) {
if (err) {
collection.ec2.describeSnapshots[AWSConfig.region].err = err;
} else if (data) {
if (paginating && data.Snapshots && data.Snapshots.length &&
const filteredSnapshots = data.Snapshots? data.Snapshots.filter(snapshot => {
return new Date(snapshot.StartTime) > createdTime;
}) : [];

if (paginating && filteredSnapshots && filteredSnapshots.length &&
collection.ec2.describeSnapshots[AWSConfig.region].data &&
collection.ec2.describeSnapshots[AWSConfig.region].data.length) {
collection.ec2.describeSnapshots[AWSConfig.region].data = collection.ec2.describeSnapshots[AWSConfig.region].data.concat(data.Snapshots);
collection.ec2.describeSnapshots[AWSConfig.region].data.length &&
collection.ec2.describeSnapshots[AWSConfig.region].data.length < maxSnapshots) {
collection.ec2.describeSnapshots[AWSConfig.region].data = collection.ec2.describeSnapshots[AWSConfig.region].data.concat(filteredSnapshots);
} else if (!paginating) {
collection.ec2.describeSnapshots[AWSConfig.region].data = data.Snapshots;
collection.ec2.describeSnapshots[AWSConfig.region].data = filteredSnapshots;
}
if (data.NextToken &&
if (data.NextToken && data.NextToken.length &&
collection.ec2.describeSnapshots[AWSConfig.region].data &&
collection.ec2.describeSnapshots[AWSConfig.region].data.length) {
collection.ec2.describeSnapshots[AWSConfig.region].data.length &&
collection.ec2.describeSnapshots[AWSConfig.region].data.length < maxSnapshots) {
paginating = true;
return execute(data.NextToken);
}
Expand Down
2 changes: 1 addition & 1 deletion collectors/aws/ec2/describeSubnets.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
collection.ec2.describeSubnets[AWSConfig.region][vpc.VpcId].err = err;
}

collection.ec2.describeSubnets[AWSConfig.region][vpc.VpcId].data = data;
if (data) collection.ec2.describeSubnets[AWSConfig.region][vpc.VpcId].data = data;

cb();
});
Expand Down
2 changes: 1 addition & 1 deletion collectors/aws/ecs/describeCluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
collection.ecs.describeCluster[AWSConfig.region][cluster].err = err;
}

collection.ecs.describeCluster[AWSConfig.region][cluster].data = data;
if (data) collection.ecs.describeCluster[AWSConfig.region][cluster].data = data;

cb();
});
Expand Down
2 changes: 1 addition & 1 deletion collectors/aws/ecs/describeContainerInstances.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
collection.ecs.describeContainerInstances[AWSConfig.region][containerInstance].err = err;
}

collection.ecs.describeContainerInstances[AWSConfig.region][containerInstance].data = data;
if (data) collection.ecs.describeContainerInstances[AWSConfig.region][containerInstance].data = data;

ccb();
});
Expand Down
2 changes: 1 addition & 1 deletion collectors/aws/ecs/describeServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
collection.ecs.describeServices[AWSConfig.region][service].err = err;
}

collection.ecs.describeServices[AWSConfig.region][service].data = data;
if (data) collection.ecs.describeServices[AWSConfig.region][service].data = data;

ccb();
});
Expand Down
2 changes: 1 addition & 1 deletion collectors/aws/ecs/describeTasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
collection.ecs.describeTasks[AWSConfig.region][task].err = err;
}

collection.ecs.describeTasks[AWSConfig.region][task].data = data;
if (data) collection.ecs.describeTasks[AWSConfig.region][task].data = data;

ccb();
});
Expand Down
6 changes: 3 additions & 3 deletions collectors/aws/ecs/listContainerInstances.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ module.exports = function(AWSConfig, collection, retries, callback) {
helpers.makeCustomCollectorCall(ecs, 'listContainerInstances', params, retries, null, null, null, function(err, data) {
if (err) {
collection.ecs.listContainerInstances[AWSConfig.region][cluster].err = err;
} else if (data && data.containerInstanceArns) {
collection.ecs.listContainerInstances[AWSConfig.region][cluster].data = data.containerInstanceArns;
}

collection.ecs.listContainerInstances[AWSConfig.region][cluster].data = data.containerInstanceArns;

cb();
});
}, function(){
callback();
});
};
};
5 changes: 2 additions & 3 deletions collectors/aws/ecs/listServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ module.exports = function(AWSConfig, collection, retries, callback) {
if (err) {
collection.ecs.listServices[AWSConfig.region][cluster].err = err;
}

collection.ecs.listServices[AWSConfig.region][cluster].data = data.serviceArns;
if (data && data.serviceArns) collection.ecs.listServices[AWSConfig.region][cluster].data = data.serviceArns;

cb();
});
}, function(){
callback();
});
};
};
5 changes: 2 additions & 3 deletions collectors/aws/ecs/listTasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ module.exports = function(AWSConfig, collection, retries, callback) {
helpers.makeCustomCollectorCall(ecs, 'listTasks', params, retries, null, null, null, function(err, data) {
if (err) {
collection.ecs.listTasks[AWSConfig.region][cluster].err = err;
} else if (data && data.taskArns) {
collection.ecs.listTasks[AWSConfig.region][cluster].data = data.taskArns;
}

collection.ecs.listTasks[AWSConfig.region][cluster].data = data.taskArns;

cb();
});
}, function(){
Expand Down
2 changes: 1 addition & 1 deletion collectors/aws/elasticache/describeCacheSubnetGroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
if (err) {
collection.elasticache.describeCacheSubnetGroups[AWSConfig.region][cluster.CacheSubnetGroupName].err = err;
}
collection.elasticache.describeCacheSubnetGroups[AWSConfig.region][cluster.CacheSubnetGroupName].data = data;
if (data) collection.elasticache.describeCacheSubnetGroups[AWSConfig.region][cluster.CacheSubnetGroupName].data = data;
cb();
});
}, function(){
Expand Down
2 changes: 1 addition & 1 deletion collectors/aws/elb/describeInstanceHealth.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
if (err) {
collection.elb.describeInstanceHealth[AWSConfig.region][lb.DNSName].err = err;
}
collection.elb.describeInstanceHealth[AWSConfig.region][lb.DNSName].data = data;
if (data) collection.elb.describeInstanceHealth[AWSConfig.region][lb.DNSName].data = data;
cb();
});
}, function(){
Expand Down
2 changes: 1 addition & 1 deletion collectors/aws/elb/describeLoadBalancerAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
if (err) {
collection.elb.describeLoadBalancerAttributes[AWSConfig.region][lb.DNSName].err = err;
}
collection.elb.describeLoadBalancerAttributes[AWSConfig.region][lb.DNSName].data = data;
if (data) collection.elb.describeLoadBalancerAttributes[AWSConfig.region][lb.DNSName].data = data;
cb();
});
}, function(){
Expand Down
2 changes: 1 addition & 1 deletion collectors/aws/elb/describeLoadBalancerPolicies.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
helpers.makeCustomCollectorCall(elb, 'describeLoadBalancerPolicies', params, retries, null, null, null, function(err, data) {
if (err) {
collection.elb.describeLoadBalancerPolicies[AWSConfig.region][policy.DNSName].err = err;
} else {
} else if (data) {
collection.elb.describeLoadBalancerPolicies[AWSConfig.region][policy.DNSName].data = data;
}

Expand Down
2 changes: 1 addition & 1 deletion collectors/aws/elb/describeTags.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function(AWSConfig, collection, retries, callback) {
collection.elb.describeTags[AWSConfig.region][lb.LoadBalancerName].err = err;
}

collection.elb.describeTags[AWSConfig.region][lb.LoadBalancerName].data = data;
if (data) collection.elb.describeTags[AWSConfig.region][lb.LoadBalancerName].data = data;
cb();
});
}, function(){
Expand Down
Loading

0 comments on commit 18251d5

Please sign in to comment.