Is there any way available to check the status of a apache tomcat server from another machine in python?
For example, A restful API is running in a machine with apache tomcat server in 8086
port.
Now, what I want is to check the status of the apache tomcat service of the specified machine from my pc programmatically in python.
Yes,I could check the machine is running or not through pinging by using os.system
in python.
import os
hostname = "xxx.xxx.xxx.xxx" #example
response = os.system("ping -c 1 " + hostname)
#and then check the response...
if response == 0:
print hostname, 'is up!'
else:
print hostname, 'is down!'
But, what I am interested in is that, is it possible to check the status of the service (real_ip:8086/BotAPI) in stead of the liveness of the machine, programmatically in python ?
Update: using paramiko I got the following traceback
channel.exec_command('ps -ef| grep tomcat')
Traceback (most recent call last):
File "<pyshell#67>", line 1, in <module>
channel.exec_command('ps -ef| grep tomcat')
File "E:\python\lib\site-packages\paramiko\channel.py", line 63, in _check
return func(self, *args, **kwds)
File "E:\python\lib\site-packages\paramiko\channel.py", line 241, in exec_command
self._wait_for_event()
File "E:\python\lib\site-packages\paramiko\channel.py", line 1197, in _wait_for_event
raise e
paramiko.ssh_exception.SSHException: Channel closed.