The event handler needs to be defined rather like this:
define command {
command_name myeventhandler01
command_line /myfolder01/myscript01.sh $HOSTNAME$
}
The file /myfolder01/myscript01.sh may be a python file. Ensure that the script is executable when run with a proper argument.