I think there are a couple of ways:
SHOW STATUS WHERE `variable_name` = 'Threads_connected'
or you can do a SHOW PROCESSLIST
and find out unique values in the Id
column. In old PHP API mysql
, there is mysql_list_processes
function that does the same as SHOW PROCESSLIST
, too.
But first one should work for you. And perhaps you might like to check on other STATUS variables