AnsweredAssumed Answered

Groovy script to identify non scanning agents

Question asked by Richard Mines on Jan 4, 2018
Latest reply on Feb 15, 2018 by Richard Mines

We have a persistent issue where Cloud Agents check in fine, but sometimes stop performing scans, and need to be either re-installed or have their VM module bounced. This is seemingly a known issue where the manifest is getting corrupted for some reason.

 

I'm looking to tag assets impacted by this so I can both track them more easily, as well as exclude them from reporting (as their data is unreliable). I have most of a groovy script for this:

 

// Skip testing on any webapps
if(asset.getAssetType()!=Asset.AssetType.HOST) return false;
// Skip non Cloud Agent based records
if (!asset.hasTag("Cloud Agent")) return false;
// Skip Agents not marked as Active.
if (!asset.hasTag("Agent Active")) return false;
// Skip if asset is less than days_old days old.
ignore_younger_than = 3
// Get today's date minus X days.
def today = new Date();
if (today.minus(asset.getCreated().toDate()) < ignore_younger_than) return false;
// Tag asset if Last Scan Date is more than scan_stale_threshold days old.
scan_stale_threshold = 30
return today.minus(asset.lastVmScanDate().toDate()) > scan_stale_threshold;

 

The syntax for that final test seems to be wrong and I can't seem to fix it. Can anyone help me get to the bottom of this?

Outcomes