Sample scripts demonstrating usage of various Cisco CUCM Serviceability APIs using Python and the Zeep SOAP library.
https://developer.cisco.com/site/sxml/
risport70_selectCmDevice.py
- Demonstrates querying for all device registrations using Risport (<selectCmDevice>
)
perfmonPort_collect_counter_data.py
- Demonstrates retrieving and parsing performance counter data via the Perfmon <perfmonCollectCounterData>
request
services_getProductInformationList.py
- Use Control Center Services to retrieve a list of the installed Products and versions (<getProductInformationList>
)
perfmonPort_collectSession_data.py
- (Mac/Linux only) Uses Perfmonport to start a collection session, add example counters, then periodically retrieve/parse the results (<perfmonOpenSession>
, <perfmonAddCounter>
,<perfmonCollectCounterData>
)
logCollection_GetOneFile.py
- Performs a listing of log files available for a specific service (Cisco Audit Logs), retrieves the contents of the latest file, then parses/prints a few lines of the results (<selectLogFiles>
, <GetOneFile>
)
services_soapGetServiceStatus.py
- Performs a <soapGetServiceStatus>
request using the Zeep SOAP library.
services_doControlServices.py
- Performs a <soapDoControlServices>
request using the Zeep SOAP library,
periodically checks the status using <soapGetServiceStatus>
and parses/prints the results in a simple table output.
Tested using:
Install Python 3
(On Windows, choose the option to add to PATH environment variable)
Clone this repository:
git clone https://www.github.com/CiscoDevNet/serviceability-python-zeep-samples
cd serviceability-python-zeep-samples
(Optional) Create/activate a Python virtual environment named venv
:
python3 -m venv venv
source venv/bin/activate
Install needed dependency packages:
pip install -r requirements.txt
Open the project in Visual Studio Code:
code .
Rename the file .env.example
to .env
and edit to specify your CUCM address and Serviceability API user credentials
The Serviceability SOAP API WSDL files for CUCM v12.5 are included in this project. If you'd like to use a different version, replace the files in schema/
with the versions from your CUCM, which can be retrieved at:
CDRonDemand: https://{cucm}/CDRonDemandService2/services/CDRonDemandService?wsdl
Log Collection: https://{cucm}:8443/logcollectionservice2/services/LogCollectionPortTypeService?wsdl
PerfMon: https://{cucm}:8443/perfmonservice2/services/PerfmonService?wsdl
RisPort70: https://{cucm}:8443/realtimeservice2/services/RISService70?wsdl
Control Center Services: https://{cucm}:8443/controlcenterservice2/services/ControlCenterServices?wsdl
Control Center Services Extended: https://{cucm}:8443/controlcenterservice2/services/ControlCenterServicesEx?wsdl
You can get a 'dump' of an API WSDL to see how Zeep interprets it, for example by running (Mac/Linux):
python -mzeep schema/PerfmonService.wsdl > PerfmonServiceWsdl.txt
This can help with identifying the proper object structure to send to Zeep
Elements which contain a list, such as:
<members> <member> <subElement1/> <subElement2/> </member> <member> <subElement1/> <subElement2/> </member> </members>
are represented a little differently than expected by Zeep. Note that <member>
becomes an array, not <members>
:
{ 'members': { 'member': [ { 'subElement1': 'value', 'subElement2': 'value' }, { 'subElement1': 'value', 'subElement2': 'value' } ] } }
Owner
Contributors
Categories
CollaborationProducts
Cisco Unified Communications Manager (CUCM)Programming Languages
PythonLicense
Code Exchange Community
Get help, share code, and collaborate with other developers in the Code Exchange community.View Community