Plugins Health Check
Below are instructions to run the Plugins health check script.
Download script
Create the plugins-health-check.js from the bottom.
By default, the script will search for all plugins. To search by 1 or more plugins, modify the script, and enter the plugin name(s). For example:
var plugins = ['sw_swimlane_util', 'sw_swimlane_email'];
Swimlane Platform Installer (SPI) & Helm
- Save the Swimlane namespace an env variable: NOTE: For SPI, enter default for <SWIMLANE_NAMESPACE>
export NS=<SWIMLANE_NAMESPACE>
- Save the mongo primary into an env variable:
- For Standalone:
export MONGO_PRIMARY=swimlane-sw-mongo-0
- For HA:
- Use the command below to lookup the PRIMARY:
kubectl -n $NS exec swimlane-sw-mongo-0 -- mongo -u Admin -p --authenticationDatabase admin --tls --tlsAllowInvalidCertificates admin --eval="rs.isMaster();" | grep primary
- Replace <MONGO_PRIMARY_POD> with name of the pod (ex: swimlane-sw-mongo-#) from the previous step:
export MONGO_PRIMARY=<MONGO_PRIMARY_POD>
- Copy the file plugins-health-check.js in the PRIMARY mongo container:
kubectl -n $NS cp plugins-health-check.js $MONGO_PRIMARY:/tmp/
- Run the file plugins-health-check.js inside the mongo PRIMARY container:
kubectl -n $NS exec $MONGO_PRIMARY -- mongo --quiet Swimlane -u Admin -p --authenticationDatabase admin --tls --tlsAllowInvalidCertificates /tmp/plugins-health-check.js | tee plugins-health-check-results.txt
- The output will be available in plugins-health-check-results.txt
Sample Results:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Plugin : sw_microsoft_exchange
========================================================================================================================================================
PackageDescriptors:
db.PackageDescriptors.find({"_id": {$regex:'sw_microsoft_exchange'}})
========================================================================================================================================================
|-- Version: 5.1.1
|-- PythonVersion: 3.6
========================================================================================================================================================
AssetDescriptors:
db.AssetDescriptors.find({"PackageDescriptor.Name": {$regex:'sw_microsoft_exchange'}})
========================================================================================================================================================
|-- Version: 5.1.1
|-- PackageDescriptor.
| |-- Version: 5.1.1
| |-- PythonVersion: 3.6
========================================================================================================================================================
AvailableActionDescriptors:
db.AvailableActionDescriptors.find({"PackageDescriptor.Name": {$regex:'sw_microsoft_exchange'}})
========================================================================================================================================================
|-- Name: Delete Emails
|-- _id: aMebJ1vsrwguvfLGT
|-- Version: 5.1.1
|-- AssetDependencyVersion: 5.1.1
|-- PackageDescriptor.
| |-- Version: 5.1.1
| |-- PythonVersion: 3.6
|-- Name: Get Email Metadata
|-- _id: aPV76XJq7cuRC1xMm
|-- Version: 5.1.1
|-- AssetDependencyVersion: 5.1.1
|-- PackageDescriptor.
| |-- Version: 5.1.1
| |-- PythonVersion: 3.6
|-- Name: Move Email to Folder
|-- _id: aQRy2Mn9DBIxHTS2X
|-- Version: 5.1.1
|-- AssetDependencyVersion: 5.1.1
|-- PackageDescriptor.
| |-- Version: 5.1.1
| |-- PythonVersion: 3.6
|-- Name: Reply/Forward Email
|-- _id: aROnzCFTIkiSMuxjI
|-- Version: 5.1.1
|-- AssetDependencyVersion: 5.1.1
|-- PackageDescriptor.
| |-- Version: 5.1.1
| |-- PythonVersion: 3.6
|-- Name: Send An Email
|-- _id: aSLdv1inOJ6ySLSP3
|-- Version: 5.1.1
|-- AssetDependencyVersion: 5.1.1
|-- PackageDescriptor.
| |-- Version: 5.1.1
| |-- PythonVersion: 3.6
|-- Name: Set Email Category
|-- _id: aTITqsB6TsWTXmy4p
|-- Version: 5.1.1
|-- AssetDependencyVersion: 5.1.1
|-- PackageDescriptor.
| |-- Version: 5.1.1
| |-- PythonVersion: 3.6
========================================================================================================================================================
Assets:
db.Assets.find({"Descriptor.PackageDescriptor.Name": {$regex:'sw_microsoft_exchange'}})
========================================================================================================================================================
|-- _id: aHTKy7BqMc_RE8ZEj
|-- Name: Microsoft Exchange
|-- Descriptor.
| |-- Name: Microsoft Exchange
| |-- Version: 5.1.1
| |-- PackageDescriptor.
| | -- Name: sw_microsoft_exchange
| | -- Version: 5.1.1
| | -- PythonVersion: 3.6
========================================================================================================================================================
fs.files:
db.fs.files.find({"filename": {$regex:'sw_microsoft_exchange'}})
========================================================================================================================================================
|-- _id: a23Ktt58vO6n1_oHR
|-- filename: sw_microsoft_exchange_5.1.1.swimbundle
========================================================================================================================================================
NON Forked Tasks:
db.Tasks.find({"Action._t": "PackagedAction", "Action.Descriptor.PackageDescriptor.Name": {$regex:'sw_microsoft_exchange'}})
========================================================================================================================================================
Task #1: Get Exchange Metadata
|-- _id: aMRuAuAE0Q9GHNXQc
|-- Action.
| |-- PackageDescriptorId: aJgq9w8wg3l1rxdQ5 (match NOT found)
| |-- AssetId: aHTKy7BqMc_RE8ZEj (match found)
| | -- Descriptor.
| | | -- _id: aJgq9w8wg3l1rxdQ5
| | | -- Name: Get Email Metadata
| | | -- AssetDependencyVersion: 5.1.1
| | | -- PackageDescriptor.
| | | | -- Version: 5.1.1
| | | | -- PythonVersion: 3.6
Task #2: Move Email
|-- _id: aJBC40S_SH_TSS2Kv
|-- Action.
| |-- PackageDescriptorId: aQRy2Mn9DBIxHTS2X (match found)
| |-- AssetId: null (match NOT found)
| | -- Descriptor.
| | | -- _id: aQRy2Mn9DBIxHTS2X
| | | -- Name: Move Email to Folder
| | | -- AssetDependencyVersion: 5.1.1
| | | -- PackageDescriptor.
| | | | -- Version: 5.1.1
| | | | -- PythonVersion: 3.6
========================================================================================================================================================
Forked Tasks:
db.Tasks.find({"Action.ForkedFromPackage": {$exists: true}, "Action.ForkedFromPackage": {$regex:'sw_microsoft_exchange'}})
========================================================================================================================================================
Task #1: Fork Exchange Delete Email
|-- _id: aNzHNjCvOuXxpx5ht
|-- Action.
| |-- _t: Python36Action
| |-- AssetId: aHTKy7BqMc_RE8ZEj (match found)
| |-- AssetDependencyVersion: 5.1.1
| |-- Descriptor.
| | -- ActionType: python36
Task #2: test move folder
|-- _id: aU_WP_4MGiL949Jf3
|-- Action.
| |-- _t: Python36Action
| |-- AssetId: aHTKy7BqMc_RE8ZEj (match found)
| |-- AssetDependencyVersion: 5.1.1
| |-- Descriptor.
| | -- ActionType: python36
Save the code below as plugin-health-check.js
db = db.getSiblingDB('Swimlane');
// Default : search all plugins
var plugins = [];
// To search by 1 or more plugins
// 1. uncomment the next line and enter the plugin name
//var plugins = ['sw_xxx', 'sw_xxx'];
var assets = []
var availableActionDescriptors = []
var indent = "\t|-- ";
var indent2 = "\t|\t|-- ";
var indent3 = "\t|\t|\t-- ";
var indent4 = "\t|\t|\t|\t-- ";
var indent5 = "\t|\t|\t|\t|\t-- ";
var header = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
var divider = "\t========================================================================================================================================================"
if (plugins.length === 0) {
db.getCollection('PackageDescriptors').find({}, {"Name":1}
).forEach( function(myDoc) {
plugins.push(myDoc.Name);
}
);
}
plugins.forEach(function (pluginName) {
print(header)
print("Plugin : " + pluginName);
// PackageDescriptors
print("\r");
print(divider);
print("\tPackageDescriptors:")
print(`\t\tdb.PackageDescriptors.find({"_id": {$regex:'${pluginName}'}})`);
print(divider);
db.getCollection('PackageDescriptors').find(
{"_id": {$regex:pluginName}},
{
"Name":1,
"Version":1,
"PythonVersion":1
}
).forEach( function(myDoc) {
print( indent + "Version: " + myDoc.Version );
print( indent + "PythonVersion: " + myDoc.PythonVersion );
print("\r");
}
);
// AssetDescriptors
print(divider);
print("\tAssetDescriptors:")
print(`\t\tdb.AssetDescriptors.find({"PackageDescriptor.Name": {$regex:'${pluginName}'}})`);
print(divider);
db.getCollection('AssetDescriptors').find(
{"PackageDescriptor.Name": {$regex:pluginName}},
{
"Version":1,
"PackageDescriptor.Version":1,
"PackageDescriptor.PythonVersion":1
}
).forEach( function(myDoc) {
print( indent + "Version: " + myDoc.Version);
print( indent + "PackageDescriptor.");
print( indent2 + "Version: " + myDoc.PackageDescriptor.Version);
print( indent2 + "PythonVersion: " + myDoc.PackageDescriptor.PythonVersion);
print("\r");
}
);
// AvailableActionDescriptors
print(divider);
print("\tAvailableActionDescriptors:")
print(`\t\tdb.AvailableActionDescriptors.find({"PackageDescriptor.Name": {$regex:'${pluginName}'}})`);
print(divider);
db.getCollection('AvailableActionDescriptors').find(
{"PackageDescriptor.Name": {$regex:pluginName}},
{
"Name":1,
"Version":1,
"AssetDependencyVersion":1,
"PackageDescriptor.Version":1,
"PackageDescriptor.PythonVersion":1
}
).forEach( function(myDoc) {
availableActionDescriptors.push(myDoc._id);
print(indent + "Name: " + myDoc.Name);
print(indent + "_id: " + myDoc._id);
print(indent + "Version: " + myDoc.Version);
print(indent + "AssetDependencyVersion: " + myDoc.AssetDependencyVersion);
print(indent + "PackageDescriptor.");
print(indent2 + "Version: " + myDoc.PackageDescriptor.Version );
print(indent2 + "PythonVersion: " + myDoc.PackageDescriptor.PythonVersion );
print("\r");
}
);
// Assets
print(divider);
print("\tAssets:")
print(`\t\tdb.Assets.find({"Descriptor.PackageDescriptor.Name": {$regex:'${pluginName}'}})`);
print(divider);
db.getCollection('Assets').find(
{"Descriptor.PackageDescriptor.Name": {$regex:pluginName}},
{
"_id":1,
"Name":1,
"Descriptor.Name":1,
"Descriptor.Version":1,
"Descriptor.PackageDescriptor.Name":1,
"Descriptor.PackageDescriptor.Version":1,
"Descriptor.PackageDescriptor.PythonVersion":1
}
).forEach( function(myDoc) {
assets.push(myDoc._id);
print(indent + "_id: " + myDoc._id);
print(indent + "Name: " + myDoc.Name);
print(indent + "Descriptor.");
print(indent2 + "Name: " + myDoc.Descriptor.Name);
print(indent2 + "Version: " + myDoc.Descriptor.Version );
print(indent2 + "PackageDescriptor.");
print(indent3 + "Name: " + myDoc.Descriptor.PackageDescriptor.Name);
print(indent3 + "Version: " + myDoc.Descriptor.PackageDescriptor.Version);
print(indent3 + "PythonVersion: " + myDoc.Descriptor.PackageDescriptor.PythonVersion);
print("\r");
}
);
// fs.files
print(divider);
print("\tfs.files:")
print(`\t\tdb.fs.files.find({"filename": {$regex:'${pluginName}'}})`);
print(divider);
db.getCollection('fs.files').find(
{"filename": {$regex:pluginName} }
).forEach( function(myDoc) {
print(indent + "_id: " + myDoc._id);
print(indent + "filename: " + myDoc.filename);
}
);
// NON Forked Tasks
var taskCount = 1
print("\r");
print(divider);
print("\tNON Forked Tasks:");
print(`\t\tdb.Tasks.find({"Action._t": "PackagedAction", "Action.Descriptor.PackageDescriptor.Name": {$regex:'${pluginName}'}})`);
print(divider);
var tasks = db.getCollection('Tasks').find(
{
"Action._t": "PackagedAction",
"Action.Descriptor.PackageDescriptor.Name": {$regex:pluginName}
},
{ "_id":1,
"Name":1,
"Action.PackageDescriptorId":1,
"Action.AssetId":1,
"Action.Descriptor._id":1,
"Action.Descriptor.Name":1,
"Action.Descriptor.AssetDependencyVersion":1,
"Action.Descriptor.PackageDescriptor.Version":1,
"Action.Descriptor.PackageDescriptor.PythonVersion":1
});
tasks.forEach(function(task) {
print("\tTask #" + taskCount++ + ": " + task.Name + "\n");
print(indent + "_id: " + task._id);
print(indent + "Action. ");
if (availableActionDescriptors.includes(task.Action.PackageDescriptorId)) {
print(indent2 + "PackageDescriptorId: " + task.Action.PackageDescriptorId + " (match found)");
} else {
print(indent2 + "PackageDescriptorId: " + task.Action.PackageDescriptorId + " (match NOT found)");
}
if (assets.includes(task.Action.AssetId)) {
print(indent2 + "AssetId: " + task.Action.AssetId + " (match found)");
} else {
print(indent2 + "AssetId: " + task.Action.AssetId + " (match NOT found)");
}
print(indent3 + "Descriptor. ");
print(indent4 + "_id: " + task.Action.Descriptor._id);
print(indent4 + "Name: " + task.Action.Descriptor.Name);
print(indent4 + "AssetDependencyVersion: " + task.Action.Descriptor.AssetDependencyVersion);
print(indent4 + "PackageDescriptor. ");
print(indent5 + "Version: " + task.Action.Descriptor.PackageDescriptor.Version);
print(indent5 + "PythonVersion: " + task.Action.Descriptor.PackageDescriptor.PythonVersion);
print("\r");
});
// Forked Tasks
print(divider);
print("\tForked Tasks:");
print(`\t\tdb.Tasks.find({"Action.ForkedFromPackage": {$exists: true}, "Action.ForkedFromPackage": {$regex:'${pluginName}'}})`);
print(divider);
print("\r");
var taskCount = 1
var Tasks = db.getCollection('Tasks').find(
{
"Action.ForkedFromPackage": {$exists: true},
"Action.ForkedFromPackage": {$regex:pluginName}
},
{ "_id":1,
"Name":1,
"Action._t":1,
"Action.AssetId":1,
"Action.AssetDependencyVersion":1,
"Action.Descriptor.ActionType":1
});
Tasks.forEach(function(task) {
print("\tTask #" + taskCount++ + ": " + task.Name + "\n");
print(indent + "_id: " + task._id);
print(indent + "Action. ");
print(indent2 + "_t: " + task.Action._t);
if (assets.includes(task.Action.AssetId)) {
print(indent2 + "AssetId: " + task.Action.AssetId + " (match found)");
} else {
print(indent2 + "AssetId: " + task.Action.AssetId + " (match NOT found)");
}
print(indent2 + "AssetDependencyVersion: " + task.Action.AssetDependencyVersion);
print(indent2 + "Descriptor. ");
print(indent3 + "ActionType: " + task.Action.Descriptor.ActionType);
print("\r");
});
});