hostapd: execute a command when there is new connection established

As @beemaster said run this:

hostapd_cli -a '/onHostapdChange.sh'

With the script: onHostapdChange.sh

#!/bin/bash
if [[ $2 == "AP-STA-CONNECTED" ]]
then
  echo "someone has connected with mac id $3 on $1"
fi

if [[ $2 == "AP-STA-DISCONNECTED" ]]
then
  echo "someone has disconnected with mac id $3 on $1"
fi

For now I've found the following solution:

hostapd_cli -a 'some_script'

Where script receives network interface name and event type as an arguments. This must be started after hostapd daemon. Also it needs ctrl_interface to be set in hostapd.conf.