linux -- determine what service was running on a down port
<p>I need to write a bash script that:</p>

<p>-- takes ip address and list of ports as standard input,</p>

<p>-- check to see if port up or down, </p>

<p>-- if port is down, then restart the service via ssh</p>

<p>Got the first two working, however I am stuck on the last part, determining what service was running on the down port, as I may not know what services the machine is supposed to be running. lsof, netstat are not useful because the service is down. </p>

<p>The assumption is that this script will run on the users machine to check server status and restart any downed services automagically. It is known that some services may use ports listed in /etc/services for other services (for example, cpanel customer portal uses 2083, which /etc/services lists as radsec). </p>

<p>Any help is most appreciated, thank you!!</p>