I am planning to create an html page that will count number of connected ports, challenge for me is how to put it in a page. Thanks!
you can use Perl and CGI for this.
in a perl CGI script, run your command / program / function to get the count of connected ports, and show the count in a web page using CGI module. this module might be present in your system already (along with default installation of perl)