Hi, I need to run the ping command, I want to check my own IP is up or not. Thanks.
Hi, I need to run the ping command, I want to check my own IP is up or not. Thanks.
It's on the way. Should be there with the next system image. Maybe use curl
while you are waiting.
Thanks you, Do you think curl can work with IPs?
curl can work with IPs. You will get Connection refused
if there is no server listening on port 80, and No route to host
if the IP is not there. Try curl --head <ip_nmber>
that should do the job.
unfortunately, did not work, i got that can not run more than one socket at the same time!
That sounds strange! Could you copy/paste the exact command you ran (replacing the IP address with XXX
if you don't want it to be public) and the full error message?
def ping_command(ip): try: print("<--", ip) os.system(f'curl --head {ip}') return True except: return False
also, I tried subprocess.run() both did not work, Any idea, or when the ping command will work?
What is the actual error message?
when i use subprocess.run() I got this:
2021-04-01 16:22:52 VACUUM: unix socket /var/sockets/www.alaa-an.website/socket removed. 2021-04-01 16:22:56 *** Starting uWSGI 2.0.17.1 (64bit) on [Thu Apr 1 16:22:54 2021] *** 2021-04-01 16:22:56 compiled with version: 5.4.0 20160609 on 07 May 2020 19:40:56 2021-04-01 16:22:56 os: Linux-5.4.0-1029-aws #30 SMP Tue Nov 10 18:03:06 UTC 2020 2021-04-01 16:22:56 nodename: green-liveweb19 2021-04-01 16:22:56 machine: x86_64 2021-04-01 16:22:56 clock source: unix 2021-04-01 16:22:56 pcre jit disabled 2021-04-01 16:22:56 detected number of CPU cores: 4 2021-04-01 16:22:56 current working directory: /home/seifa 2021-04-01 16:22:56 detected binary path: /usr/local/bin/uwsgi 2021-04-01 16:22:56 *** dumping internal routing table *** 2021-04-01 16:22:56 [rule: 0] subject: path_info regexp: .svgz$ action: addheader:Content-Encoding:gzip 2021-04-01 16:22:56 *** end of the internal routing table *** 2021-04-01 16:22:56 chdir() to /home/seifa/ 2021-04-01 16:22:56 your processes number limit is 1536 2021-04-01 16:22:56 your memory page size is 4096 bytes 2021-04-01 16:22:56 detected max file descriptor number: 123456 2021-04-01 16:22:56 building mime-types dictionary from file /etc/mime.types... 2021-04-01 16:22:56 552 entry found 2021-04-01 16:22:56 lock engine: pthread robust mutexes 2021-04-01 16:22:56 thunder lock: disabled (you can enable it with --thunder-lock) 2021-04-01 16:22:56 uwsgi socket 0 bound to UNIX address /var/sockets/www.alaa-an.website/socket fd 3 2021-04-01 16:22:56 Python version: 3.7.5 (default, Nov 14 2019, 22:26:37) [GCC 5.4.0 20160609] 2021-04-01 16:22:56 Set PythonHome to /home/seifa/.virtualenvs/bus 2021-04-01 16:22:56 *** Python threads support is disabled. You can enable it with --enable-threads *** 2021-04-01 16:22:56 Python main interpreter initialized at 0x1854030 2021-04-01 16:22:56 your server socket listen backlog is limited to 100 connections 2021-04-01 16:22:56 your mercy for graceful operations on workers is 60 seconds 2021-04-01 16:22:56 setting request body buffering size to 65536 bytes 2021-04-01 16:22:56 mapped 501384 bytes (489 KB) for 2 cores 2021-04-01 16:22:56 *** Operational MODE: preforking *** 2021-04-01 16:22:56 initialized 54 metrics 2021-04-01 16:22:56 WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x1854030 pid: 1 (default app) 2021-04-01 16:22:56 *** uWSGI is running in multiple interpreter mode *** 2021-04-01 16:22:56 gracefully (RE)spawned uWSGI master process (pid: 1) 2021-04-01 16:22:56 spawned uWSGI worker 1 (pid: 3, cores: 1) 2021-04-01 16:22:56 spawned 2 offload threads for uWSGI worker 1 2021-04-01 16:22:56 spawned uWSGI worker 2 (pid: 6, cores: 1) 2021-04-01 16:22:56 metrics collector thread started 2021-04-01 16:22:56 spawned 2 offload threads for uWSGI worker 2 2021-04-01 16:22:58 announcing my loyalty to the Emperor...
That's not an error message, that is just the server log for a normal looking web app startup. Look in your error log for logs of errors.
so, the line should do the command does not work! the server can not execute this line. any other option? or should wait when ping will work? Thanks
If you do not tell us what "does not work" means, then we have no way to help you. What is the error when you run "os.system(f'curl --head {ip}')"?
I figured this out, I tried os.system(f'curl --head www.google.com') and it works. but when I tried os.system(f'curl --head 8.8.8.8') did not work. I did not get any error it is still running with no output.(stuck), curl --head does not work with IP address.
Any update? Thanks.
Curl does work with IPs, but only if the IP address in question is running an HTTP/HTTPS server of some kind. 8.8.8.8 is Google's DNS server rather than its website, so it won't work with curl.
What is running on the actual IP address that you're trying to monitor?
I am managing internet services, so I need to monitor my IPs. any way to do that or how much time need to wait for the update that allows the ping command?
Maybe try pythonping ยท PyPI