Solved

Commvault PowerShell Module Dead Slow

  • 29 January 2021
  • 12 replies
  • 371 views

Userlevel 2
Badge +4

Hi Everyone

 

I have been trying to get my head around Commvault’s PowerShell module and it runs so slow, not sure why. Has anyone else has faced the same issue? Below script returned 3676 objects and it took more than two hours:

 

Get-Date
$clients = Get-CVClient
$subClientObjs = @()
foreach ($client in $clients){
$subClients = Get-CVSubclient -ClientName $client.clientName -AllProperties
foreach ($subClient in $subClients){
$subClientObj = [PSCustomObject]@{
'clientName' = $subClient.subClientProperties.subClientEntity.clientName
'subClientName'= $subClient.subClientProperties.subClientEntity.subclientName
'backupSetName' = $subClient.subClientProperties.subClientEntity.backupsetName
'clientType' = $subClient.subClientProperties.subClientEntity.appName
'clientInstanceName' = $subClient.subClientProperties.subClientEntity.instanceName
'vmContents' = $subClient.subClientProperties.vmContent.children.displayName -join "`n"
'vmFilters' = $subClient.subClientProperties.vmFilter.children.displayName -join "`n"
'vmDiskFilters' = $subClient.subClientProperties.vmDiskFilter.filters.filter -join "`n"
'proxyClient' = $subClient.subClientProperties.proxyClient.clientName
'backupPlan' = $subClient.subClientProperties.planEntity.planName
'vmTotalCount' = $subClient.subClientProperties.vmBackupinfo.vmTotalCount
'vmProtectedCount' = $subClient.subClientProperties.vmBackupinfo.vmProtectedCount
'vmPendingCount' = $subClient.subClientProperties.vmBackupinfo.vmPendingCount
'vmNeverBackedUpCount' = $subClient.subClientProperties.vmBackupinfo.vmNeverBackedUpCount
'vmBackedUpWithErrorCount' = $subClient.subClientProperties.vmBackupinfo.vmBackedUpWithErrorCount
'vmExcludedFromSLA' = $subClient.subClientProperties.vmSLAInfo.vmExcludedCount
'vmMetSLACount' = $subClient.subClientProperties.vmSLAInfo.vmMetSLACount
'vmMissedSLACount' = $subClient.subClientProperties.vmSLAInfo.vmMissedSLACount
'lastBackupJonbId' = $subClient.subClientProperties.commonproperties.lastBackupJobInfo.JobId
'lastBackupEndTime' = (Get-Date 01.01.1970)+([System.TimeSpan]::FromSeconds($subClient.subClientProperties.commonproperties.lastBackupJobInfo.endtime.time))
'fsContent' = $subClient.subClientProperties.content.path -join "`n"
}
$subClientObjs += $subClientObj
}
}
Get-Date

 

icon

Best answer by Yash 2 March 2021, 15:46

View original

12 replies

Userlevel 5
Badge +10

Perhaps worth having a check how your CommServe has been provisioned and if MSSQL is running hot.

Other than that, perhaps one way you could improve the code efficiency by chunking up the workload into powerhsell jobs (look into Start-Job, Wait-Job, Release-Job, Remove-Job) or there are some third party modules that can help like https://github.com/nightroman/SplitPipeline.

Userlevel 3
Badge +4

Get-CVSubclient seems to be calling Get all Clients again just to fetch the Client Id for the Client Name passed which is the main cause of slowness. We’d fix this and get back once new changes are pushed to Github.

Userlevel 6
Badge +12

Get-CVSubclient seems to be calling Get all Clients again just to fetch the Client Id for the Client Name passed which is the main cause of slowness. We’d fix this and get back once new changes are pushed to Github.

 

@Yash   Same thing happens with “cvjob -clientname”   It will throw an “info” that the parameter doesnt exist, but then continues to return everything.  If you provide a specific parameter and its not found, it should bail, or at least throw error so it can be trapped. 

 

 

 

Userlevel 3
Badge +4

@MFasulo Yes, Understood. We’d fix this too.

Userlevel 3
Badge +4

Get-CVSubclient seems to be calling Get all Clients again just to fetch the Client Id for the Client Name passed which is the main cause of slowness. We’d fix this and get back once new changes are pushed to Github.

@Abdul Wajid We fixed this and pushed it to GitHub. Please try your script again after fetching the new changes and see if there’s any improvement. Thanks.

Userlevel 3
Badge +4

Get-CVSubclient seems to be calling Get all Clients again just to fetch the Client Id for the Client Name passed which is the main cause of slowness. We’d fix this and get back once new changes are pushed to Github.

 

@Yash   Same thing happens with “cvjob -clientname”   It will throw an “info” that the parameter doesnt exist, but then continues to return everything.  If you provide a specific parameter and its not found, it should bail, or at least throw error so it can be trapped. 

 

 

 

@MFasulo We fixed this too. You may fetch the new changes from GitHub.

Userlevel 2
Badge +4

@Yash  I did download the new module and installed. But this module also seems to use the same amount of time. 

 

Get-Date
$clients = Get-CVClient
$subClientObjs = @()
foreach ($client in $clients){
$subClients = Get-CVSubclient -ClientName $client.clientName -AllProperties
foreach ($subClient in $subClients){
$subClientObj = [PSCustomObject]@{
'clientName' = $subClient.subClientProperties.subClientEntity.clientName
'subClientName'= $subClient.subClientProperties.subClientEntity.subclientName
'description' = $subClient.subClientProperties.commonProperties.description
'storagePolicy' = $subClient.subClientProperties.commonProperties.storageDevice.dataBackupStoragePolicy.storagePolicyName
'isSnapBackupEnabled' = $subClient.subClientProperties.commonProperties.snapCopyInfo.isSnapBackupEnabled
'backupSetName' = $subClient.subClientProperties.subClientEntity.backupsetName
'clientType' = $subClient.subClientProperties.subClientEntity.appName
'clientInstanceName' = $subClient.subClientProperties.subClientEntity.instanceName
'vmContents' = $subClient.subClientProperties.vmContent.children.displayName -join "`n"
'vmFilters' = $subClient.subClientProperties.vmFilter.children.displayName -join "`n"
'vmDiskFilters' = $subClient.subClientProperties.vmDiskFilter.filters.filter -join "`n"
'proxyClient' = $subClient.subClientProperties.proxyClient.clientName
'backupPlan' = $subClient.subClientProperties.planEntity.planName
'vmTotalCount' = $subClient.subClientProperties.vmBackupinfo.vmTotalCount
'vmProtectedCount' = $subClient.subClientProperties.vmBackupinfo.vmProtectedCount
'vmPendingCount' = $subClient.subClientProperties.vmBackupinfo.vmPendingCount
'vmNeverBackedUpCount' = $subClient.subClientProperties.vmBackupinfo.vmNeverBackedUpCount
'vmBackedUpWithErrorCount' = $subClient.subClientProperties.vmBackupinfo.vmBackedUpWithErrorCount
'vmExcludedFromSLA' = $subClient.subClientProperties.vmSLAInfo.vmExcludedCount
'vmMetSLACount' = $subClient.subClientProperties.vmSLAInfo.vmMetSLACount
'vmMissedSLACount' = $subClient.subClientProperties.vmSLAInfo.vmMissedSLACount
'lastBackupJonbId' = $subClient.subClientProperties.commonproperties.lastBackupJobInfo.JobId
'lastBackupEndTime' = (Get-Date 01.01.1970)+([System.TimeSpan]::FromSeconds($subClient.subClientProperties.commonproperties.lastBackupJobInfo.endtime.time))
'fsContent' = $subClient.subClientProperties.content.path -join "`n"
}
$subClientObjs += $subClientObj
}
}
Get-Date

 

Userlevel 3
Badge +4

@Abdul Wajid  Could you enable $DebugPreference = “Continue” and see if its calling Get-CVId to fetch the client Id when you call Get-CVSubclient -ClientName $client.clientName -AllProperties ? Just wanted to confirm if the new changes are reflected in your run.

Userlevel 2
Badge +4

@Abdul Wajid  Could you enable $DebugPreference = “Continue” and see if its calling Get-CVId to fetch the client Id when you call Get-CVSubclient -ClientName $client.clientName -AllProperties ? Just wanted to confirm if the new changes are reflected in your run.

Tuesday, March 2, 2021 3:31:01 PM
DEBUG: Get-CVClient: begin
DEBUG: Get-CVSessionDetail: begin
DEBUG: Get-CVSessionDetail: process
DEBUG: Get-CVSessionDetail: end
DEBUG: Get-CVClient: process
DEBUG: Get-CVRESTHeader: begin
DEBUG: Get-CVRESTHeader: process
DEBUG: Get-CVRESTHeader: end
DEBUG: Submit-CVRESTRequest: begin
DEBUG: Submit-CVRESTRequest: process
DEBUG: Submit-CVRESTRequest: header: Accept: application/json
DEBUG: Submit-CVRESTRequest: header: Authtoken: QSDK...
DEBUG: Submit-CVRESTRequest: body: 
DEBUG: Submit-CVRESTRequest: baseUrl: http://xxxxxx:81/SearchSvc/CVWebService.svc/
DEBUG: Submit-CVRESTRequest: endpoint: Client
DEBUG: Submit-CVRESTRequest: method: Get
DEBUG: Submit-CVRESTRequest: end
DEBUG: Get-CVClient: end
DEBUG: Get-CVSubclient: begin
DEBUG: Get-CVSessionDetail: begin
DEBUG: Get-CVSessionDetail: process
DEBUG: Get-CVSessionDetail: end
DEBUG: Get-CVSubclient: process
DEBUG: Get-CVId: begin
DEBUG: Get-CVSessionDetail: begin
DEBUG: Get-CVSessionDetail: process
DEBUG: Get-CVSessionDetail: end
DEBUG: Get-CVId: process
DEBUG: GetId?clientName=TEST_IndexServer

Userlevel 3
Badge +4

Thanks @Abdul Wajid . I see its calling the GetId instead of fetching all clients to get the clientId which is definitely a faster call. But if you’re still seeing the same time, then we need to look at another solution as to what you’re trying to achieve. Looking at the script, I understand you’re trying to get each and every subclient properties. But, may I ask what are you trying to achieve at the end?

Userlevel 2
Badge +4

Thanks @Abdul Wajid . I see its calling the GetId instead of fetching all clients to get the clientId which is definitely a faster call. But if you’re still seeing the same time, then we need to look at another solution as to what you’re trying to achieve. Looking at the script, I understand you’re trying to get each and every subclient properties. But, may I ask what are you trying to achieve at the end?

I was trying stuff around. I am new to Commvault and I have been using PowerShell for a while. I was trying to export the list of Subclients as an html using PSWriteHTML. This makes the search very fast as compared to looking for objects using Webconsole or Java Console. Answer to your question would be I am trying to get stuff done using PowerShell, it also helps me have better understanding what goes on behind the scene. Have been using PowerShell with other products and never seen that much of a lag so initiated this discussion. 

Userlevel 3
Badge +4

Understood. Thanks @Abdul Wajid . The lag usually depends on how many rest api calls you’re making. In this case, you’re making a large number of rest api calls, hence the delay. If there’s any rest api which is taking longer to response, then we could look into it further which is not the case here. To search for any specific entity like client or subclient, you could still call individual cmdlets. I’d also recommend you to take a look into our various reports which would generate html reports which are much faster and returns many other details than what you’re fetching through your script.

https://documentation.commvault.com/commvault/v11/article?p=130996.htm

Reply