You can also check the communication of DB and cache with curl

What is this

Speaking of network communication check to DB, dedicated commands such as mysql-client for MySQL and redis-cli for Redis are common, but if you just want to check network communication, you can just use curl. I will.

Command image

$ curl -v telnet://hogehoge.com:3306

Speaking of general commands to check communication

Common usage of curl (confirmation of communication with http and https)

$ curl -v https://hogehoge.com

Connect using the http or https protocol as in.

What happens if you don't attach a protocol? When I did $ man curl on ubuntu, I found the following description.

If you specify URL without protocol:// prefix, curl will attempt to guess what protocol you  might
       want. It will then default to HTTP but try other protocols based on often-used host name prefixes.
       For example, for host names starting with "ftp." curl will assume you want to speak FTP.

Without the protocol, it seems that commonly used schemas are tried appropriately.

For example, if you hit localhost without specifying the protocol for the server standing locally, it will be interpreted as http and executed.

$ curl -I localhost
HTTP/1.1 404 Not Found
Server: nginx
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/7.2.0RC6
Cache-Control: no-cache, private
date: Tue, 30 Jun 2020 09:27:28 GMT

Check connection to DB and cache

The case where you want to check the connection from a certain server (ubuntu) to a certain DB server is as follows. Specify the port using the telnet protocol. I thought telnet was the command name, but it seemed that there was actually a telnet protocol. Reference: https://ja.wikipedia.org/wiki/Telnet

$ curl -v telnet://hogehoge.com:3306
* Rebuilt URL to: telnet://hogehoge.com:3306/
*   Trying xx.xx.xx.xx...
* TCP_NODELAY set
* Connected to hogehoge.com (xx.xx.xx.xx) port 3306 (#0)
Warning: Binary output can mess up your terminal. Use "--output -" to tell
Warning: curl to output it to your terminal anyway, or consider "--output
Warning: <FILE>" to save to a file.
* Failed writing body (0 != 29)
* Closing connection 0

The above output is a bit confusing, but it looks like the connection itself was successful (at Connected to hogehoge.com) and the output was failing to be written. I didn't use it because it was a little hard to see, but it may be good to specify --output / dev / null etc. using the output option as output.

Recommended Posts

You can also check the communication of DB and cache with curl
You can use assert and Enum (or) decorators to check compliance with type annotation constraints without the help of mypy.
Check the existence of the file with python
Check the type of the variable you are using
Check the date of the flag duty with Python
Dump the contents of redis db with lua
Until you can install blender and run it with python for the time being
You can read the analog meter with the example MNIST.
Visualize the range of interpolation and extrapolation with python
You can read the analog meter with the example MNIST.
What you can and cannot do with Tensorflow 2.x
Check the type and version of your Linux distribution
Follow the communication flow of Docker's bridge connection with nftables
Check the memory status of the server with the Linux free command
See the power of speeding up with NumPy and SciPy
What you can do with the Python standard library statistics
Check the scope of local variables with the Python locals function.
Check the operating status of the server with the Linux top command
Try and learn iptables, until you can browse the web
Commands and files to check the version of CentOS Linux
Play with the password mechanism of GitHub Webhook and Python
Check the code with flake8
Can you delete the file?
[Machine learning] Check the performance of the classifier with handwritten character data
Check the HTTP status code response with the curl command (#Linux #Shell)
If you give a list with the default argument of the function ...
Grant an access token with the curl command and POST the API
The story of making a standard driver for db with python.
Consider what you can do with Python from the Qiita article
You can also use virtualenv from the IntelliJ IDEA Python plugin
Check the memory protection of linux kerne with the code for ARM
[Required subject DI] Implement and understand the mechanism of DI with Go
To improve the reusability and maintainability of workflows created with Luigi
I want to check the position of my face with OpenCV!
Until you build the environment with ABCI and run MaskTrack RCNN