4 years ago
Cisco Call Manager Backup Status
Powershell script to pull Call Manager appliance's backup status. Would love some feedback and recommendations on improvements. Would also love it in Groovy (so its not dependent on windows collectors) but haven't had the time to figure out, if anyone is feeling generous, I can offer nerd points. The web request output is pasted below for reference. Something else I want to figure out is how to represent the date of last successful backup (once, not for every file), found in the $xmlResult, in a widget. If anyone has thoughts on that, again, I'd appreciate hearing it.
# Requests backup status from Cisco Call Manager Cluster devices # $serverURL = 'https://##system.hostname##/platform-services/services/MaintenanceService?wsdl' $ciscoUser = '##cucm.user##' $ciscoPwd = '##cucm.pass##' $match = 'Success' $soapRequest = [xml]@" <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ser="http://services.api.platform.vos.cisco.com"> <soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"> <wsa:Action>urn:getBackupProgress</wsa:Action> <wsa:ReplyTo> <wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address> </wsa:ReplyTo> <wsa:MessageID>uuid:dc75e529-34fb-4009-b594-d801ec86f39e</wsa:MessageID> </soap:Header> <soap:Body> <ser:getBackupProgress/> </soap:Body> </soap:Envelope> "@ $header = @{"Authorization" = "Basic "+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($ciscoUser+":"+$ciscoPwd))} # Making the web request try { $result = Invoke-WebRequest -Uri $serverURL -Headers $header -Method:Post -Body $soapRequest -ContentType "application/soap+xml" -usebasicparsing } catch { # exit code of non 0 will means the web request returned an error # throw $Error[0].Exception exit 1 } if ($result.StatusCode -eq "200") { [xml]$SOAP = $result.Content # returns detailed config backup status for individual services including date and file path $xmlResult = $SOAP.Envelope.Body.getBackupProgressResponse.return.backupProgressResult.componentList # returns summary result indicating success or failure $backupOverallStatus = $SOAP.Envelope.Body.getBackupProgressResponse.return.backupProgressResult.status # True if matches string "Success" # if ($backupOverallStatus -match $match) { $Status = 1 } else { $Status = 2 } Write-Host "Status = $Status" exit 0 } else { exit 1 } # want to do something with detailed output later # # Write-Host "$xmlResult" #
# web request results
# $xmlResult
PLM host ELM-AGENT SUCCESS Sun Jul 04 21:45:02 EDT 2021 activelog/platform/drf/log/2021-07-04-21-45-02_b_host_plm_elm-agent.log
PLM host ELM-SERVER SUCCESS Sun Jul 04 21:45:03 EDT 2021 activelog/platform/drf/log/2021-07-04-21-45-02_b_host_plm_elm-server.log
PLM host ELM-AGENT SUCCESS Sun Jul 04 21:45:04 EDT 2021 activelog/platform/drf/log/2021-07-04-21-45-02_b_host_plm_elm-agent.log
PLM host ELM-SERVER SUCCESS Sun Jul 04 21:45:05 EDT 2021 activelog/platform/drf/log/2021-07-04-21-45-02_b_host_plm_elm-server.log
...
# $backupOverallStatus
Status: SUCCESS :Backup Completed...