Forum Discussion

pperreault's avatar
3 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...

 

2 Replies

  • I had a couple people on the forums here help me put this together so I can't take full credit for this!

    This is what I use to monitor Backup Status on the Publisher only.     I want to make it run a little better but I haven't had time to make it better.   You are more than welcomed to use it and see if it helps and tweak it to however you see fit...it's all XML, so copy and paste into notepad and save as "CUCM_Backup_Status-.xml" and then you can IMPORT it.

    Default threshold is for 24hours but can be adjusted per Publisher you monitor.      There are 3 properties you need set on the device.   for the system.categories property, you need "CUCMPublisher".    I use that to help me identify which server is the publisher in the cluster.....I don't want backup status on any subscribers cause a failed backup job could create multiple alarms for 1 job failure.     The other two are your ssh.user and .pass creds for CUCM CLI.    

    -EDIT- Oh yea!   I forgot to mention that it also checks to make sure a Backup Job is even setup!   We've had issues where customers didn't know backup jobs weren't configured, so we monitor for that as well!  ? -EDIT-

    Enjoy!!!  ?

  • Anonymous's avatar
    Anonymous

    @Jason Fant, this is great!  I suggest that you commit it to your repo and make it public. It'll get a code review from one of the monitoring engineers at LM and will then be available in the exchange. Simplifies the sharing process.