In this manual we will describe how to make a local copy of a built-in notification script. There are two ways:
Quick and dirty way
Copy the notification plugin to the local directory
OMD[at]:~$ cp ~/lib/python3/cmk/cee/notification_plugins/servicenow.py ~/local/share/check_mk/notifications/
make the script executable
OMD[at]:~/local/share/check_mk/notifications$ chmod +x ~/local/share/check_mk/notifications/servicenow.py
- Inside the script, you need to change:
The 3rd line to a name of your script. This name will be displayed in the Notification rules
3 # Notification script name 4 # Bulk: no
at the end of the notification script, we need to add:
print("outside: about to check for __main__ == %s" % __name__) if __name__ == "__main__": print("outside: about to call main()") sys.exit(main())
Common way for python developers
This way is more efficient and recommended for python developers
# Create a folder inside the local python structure OMD[at]:~$ cd ~/local/lib/python3/cmk OMD[at]:~/local/lib/python3/cmk$ mkdir notifications_custom # Copy the notification script from the python structure to the local python structure OMD[at]:~$ cp ~/lib/python3/cmk/cee/notification_plugins/servicenow.py ~/local/lib/python3/cmk/notifications_custom/ # Copy the notification script from the notification path to the local notification path OMD[at]:~$ cp ~/share/check_mk/notifications/servicenow ~/local/share/check_mk/notifications/ # Now lets change some values OMD[at]:~$ vi ~/local/share/check_mk/notifications/servicenow Change 3 # Servicenow (Enterprise only) to 3 # Servicenow Custom (Enterprise only) and the import directory to the local structure 13 from cmk.cee.notification_plugins import servicenow to 13 from cmk.cee.notifications_custom import servicenow
Per default all notifications scripts are inside ~/lib/python3/cmk/notification_plugins/.
As servicenow is only available with the enterprise edition, you will find the script here: ~/lib/python3/cmk/cee/notification_plugins/
Related articles