Package: echeck
ECHECKWhat can ECHECK do?Echeck is a scripting tool developed based on the Python language. It mainly includes four core commands: eping, escan, ecurl, and eshell.ecurlis the same as curl instructions, it can try to access multiple addresses at the same time and output resultsepingcan ping multiple service addresses at the same time and output resultsescanis a port sniffing tool, and ultimately returns the result of port sniffingeshellinstructions can be executed remotelyUse of ECHECKInstallationECHECK is based on Python 3.7. You need to install python3 before installing the tool.1. Install Python3The development of the tool is based on Python version 3.7. It has not been tested for compatibility. Try to install version 3.7 when using it.Python3 downloadPython download addressSelect the corresponding version to install$ curl -Ok  https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
$ tar -xzvf Python-3.7.3.tgz
$ cd Python-3.7.3
$ ./configure
$ make && make install2. Install pipDownload the installation script$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.pyExecute the installation instructions$ python get-pip.py3. Install virtualenvIt is recommended to use virtualenv to simplify the impact of the external environment on the tool installation. If it is linux or mac, you can use the following command to install it.$ pip install virtualenvExecutable help to view the virtualenv use instructions4. Create a virtual environment$ virtualenv -p 'specify python installation path' venv5. Activate the virtual environment$ source venv/bin/activate6. Install ECHECKBefore installing ECHECK, you need to install pycurl>=7.43.0.2Install pycurlMake sure that openssl is installed before installing pycurl. For how to install openssl, it will be explained in the "Frequently Asked Questions" section.$ export PYCURL_SSL_LIBRARY=openssl
$ pip install pycurlSource code installationDownload source code$ git clone https://github.com/rockyCheung/easy_echeck.gitExecute the installation instructions$ cd easy_echeck
$ python setup.py installInstalled with pip$ pip install echeckHow to use1. Profile conf.ymlConf.yml is the core configuration file, below is a simple example#yaml config
#服务器的基础配置
server:
    log:
        log_file: echeck.log
        logger_name: main
        logger_level: DEBUG
#http协议检查
ecurl:
    url:
        - https://www.baidu.com
        - https://cn.bing.com
        - https://www.google.com
        - http://www.pathcurve.cn
        - http://www.easy.com

    index_file: echeck.htm
#网络联通性检查
eping:
    ip:
        - 127.0.0.1
        - 172.20.78.115
        - 172.20.79.255
        - google.cn
        - test.com
escan:
    - host:
        label: host_name1
        ip: 127.0.0.1
        port:
            - 80
            - 8080
    - host:
        label: host_name2
        ip: 172.20.78.115
        port:
            - 80
            - 80802. ecurl* ProfileEcurl is used to check the connectivity of the http/https address of the server. If the address to be checked at the same time ishttps://www.baidu.com,https://cn.bing.com,http://www.pathcurve.cn, The following configuration is required in the configuration file:ecurl:
    url:
        - https://www.baidu.com
        - https://cn.bing.com
        - http://www.pathcurve.cnThe url can be configured with multiple addresses, each of which starts with a "-" and is identified as a list structure.Carried out$ ecurl [profile]The configuration file after the command is an optional parameter. If there is no parameter, the default is the conf.yml file in the current path. Other commands are the same as ～3. epingProfileEping is suitable for checking network connectivity. If the addresses to be checked at the same time are 127.0.0.1, 172.20.78.115, 172.20.179.255, google.cn, test.com, you need to add the following configuration in conf.yaml:eping:
    count: 4
    timeout: 5
    ip:
        - 127.0.0.1
        - 172.20.78.115
        - 172.20.79.255
        - google.cn
        - test.comCount identifies the number of pings per address, and timeout is the length of time that ping waits for response, in seconds.Carried out$ eping  [profile]4. escanProfileThe escan is applicable to scanning a specified port. The port can be multiple. The configuration examples are as follows:escan:
    - host:
        label: host_name1
        ip: 127.0.0.1
        port:
            - 80
            - 8080
    - host:
        label: host_name2
        ip: 172.20.78.115
        port:
            - 80
            - 8080Carried out$ escan  [profile]5. eshellProfileThe eshell is suitable for remote execution of a script. The remote configuration is performed as an example. The specific configuration examples are as follows:eshell:
    - shell_cell:
        label: host_name1
        ip: 24.110.255.11
        port: 22
        user_name: root
        password: 123456
        exec_command:
             - docker rmi 9b0c10cae863
             - docker imagesThe exec_command configuration item consists of two instructions:Docker rmi 9b0c10cae863 Delete ID: Image of 9b0c10cae863Docker images Query all images of this machineEshell supports any remote server command. If you want to check the server hard disk usage and system resource limit, the general procedure is to log in to the server remotely, and then execute the following two commands:df -hulimit -aBut if you need to view 10 servers at the same time, it will be slightly annoying. If it is 50 or 100? In this way, I was so stunned by myself, squatting in front of the computer and seriously knocking on the instructions for three days. On the fourth day, I found that the resources of the 90 units in the front were forgotten. Now that I have an eshell, everything is simple, and the next one is in multiple units. The server executes the df -h, ulimit -a, and ls /opt commands as an example:For example, df, ulimit, and ls are examples:eshell:
    - shell_cell:
        label: host_name1
        ip: 24.110.255.11
        port: 22
        user_name: root
        password: 123456
        exec_command:
             - df -h
             - ulimit -a
             - ls /opt
    - shell_cell:
        label: host_name2
        ip: 24.110.255.12
        port: 22
        user_name: root
        password: 123456
        exec_command:
             - df -h
             - ulimit -a
             - ls /optCarried out$ eshell  [profile]There may be a warning message CryptographyDeprecationWarning during execution. This is because some methods referenced in paramiko may be discarded in cryptography>=2.6.1 or later, which does not affect the use. If you feel uncomfortable, you can adjust the cryptography version to 2.4.2.After the execution is complete, the echeck.log print log is as follows:/~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /*************************************************
  cmd:df -h	
 result: 
   *Filesystem      Size  Used Avail Use% Mounted on	
   */dev/vda1        99G   13G   81G  14% /	
   *devtmpfs        488M     0  488M   0% /dev	
   *tmpfs           497M     0  497M   0% /dev/shm	
   *tmpfs           497M  472K  496M   1% /run	
   *tmpfs           497M     0  497M   0% /sys/fs/cgroup	
   *tmpfs           100M     0  100M   0% /run/user/0
   *overlay          99G   13G   81G  14% /var/lib/docker/overlay/d41066b7d1041eb3a74f6974cdda2991f19f67c4414879dc00785cfde4b88762/merged	
   *shm              64M     0   64M   0% /var/lib/docker/containers/b72136e5913470347b2956450cbebd0fa6c91bb1e2bf1e019fb282ec37548e26/shm
 cmd:ulimit -a	
 result: 
   *core file size          (blocks, -c) 0	
   *data seg size           (kbytes, -d) unlimited	
   *scheduling priority             (-e) 0	
   *file size               (blocks, -f) unlimited	
   *pending signals                 (-i) 3901	
   *max locked memory       (kbytes, -l) 64	
   *max memory size         (kbytes, -m) unlimited	
   *open files                      (-n) 65535	
   *pipe size            (512 bytes, -p) 8	
   *POSIX message queues     (bytes, -q) 819200	
   *real-time priority              (-r) 0	
   *stack size              (kbytes, -s) 8192	
   *cpu time               (seconds, -t) unlimited	
   *max user processes              (-u) 3901	
   *virtual memory          (kbytes, -v) unlimited	
   *file locks                      (-x) unlimited	
 cmd:ls /opt	
 result: 
   *docker	
 *************************************************/
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/

  /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /*************************************************
  cmd:df -h	
 result: 
   *Filesystem      Size  Used Avail Use% Mounted on	
   */dev/vda1        99G   13G   181G  23% /	
   *devtmpfs        488M     0  488M   0% /dev	
   *tmpfs           497M     0  497M   0% /dev/shm	
   *tmpfs           497M  472K  496M   1% /run	
   *tmpfs           497M     0  497M   0% /sys/fs/cgroup	
   *tmpfs           100M     0  100M   0% /run/user/0
   *overlay          99G   13G   81G  14% /var/lib/docker/overlay/d41066b7d1041eb3a74f6974cdda2991f19f67c4414879dc00785cfde4b88762/merged	
   *shm              64M     0   64M   0% /var/lib/docker/containers/b72136e5913470347b2956450cbebd0fa6c91bb1e2bf1e019fb282ec37548e26/shm
 cmd:ulimit -a	
 result: 
   *core file size          (blocks, -c) 0	
   *data seg size           (kbytes, -d) unlimited	
   *scheduling priority             (-e) 0	
   *file size               (blocks, -f) unlimited	
   *pending signals                 (-i) 3901	
   *max locked memory       (kbytes, -l) 64	
   *max memory size         (kbytes, -m) unlimited	
   *open files                      (-n) 65535	
   *pipe size            (512 bytes, -p) 8	
   *POSIX message queues     (bytes, -q) 819200	
   *real-time priority              (-r) 0	
   *stack size              (kbytes, -s) 8192	
   *cpu time               (seconds, -t) unlimited	
   *max user processes              (-u) 3901	
   *virtual memory          (kbytes, -v) unlimited	
   *file locks                      (-x) unlimited	
 cmd:ls /opt	
 result: 
   *docker	
 *************************************************/
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/Common problemRuntime warningSome of the methods referenced in paramiko may be deprecated in cryptography>=2.6.1 or later, so there may be the following warning message during the run:CryptographyDeprecationWarning: encode_point has been deprecated on EllipticCurvePublicNumbers and will be removed in a future version. Please use EllipticCurvePublicKey.public_bytes to obtain both compressed and uncompressed point encoding.CryptographyDeprecationWarning: Support for unsafe construction of public numbers from encoded data will be removed in a future version. Please use EllipticCurvePublicKey.from_encoded_point
self.curve, Q_S_bytesCryptographyDeprecationWarning: encode_point has been deprecated on EllipticCurvePublicNumbers and will be removed in a future version. Please use EllipticCurvePublicKey.public_bytes to obtain both compressed and uncompressed point encoding.
hm.add_string(self.Q_C.public_numbers().encode_point())It is recommended to adjust the cryptography version to 2.4.2.The installation process gives an errorInstall echeck errorFailed building wheel for pycurlSolution Perform before installing:$ export PYCURL_SSL_LIBRARY=openssl
$ pip install pycurlCannot find openssl/ssl.h error when installing pycurlsrc/pycurl.h:164:13: fatal error: 'openssl/ssl.h' file not found
    #   include <openssl/ssl.h>
                ^~~~~~~~~~~~~~~
    1 error generated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------Solution install opensslExecute the following command under mac$ brew install opensslBecause considering that users may use TLS, brew will not be set as the default preferred module when installing openssl, so in order to find openssl when using or compiling, you need to make the following settings:$ echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
$ source ~/.bash_profile
$ export LDFLAGS="-L/usr/local/opt/openssl/lib"
$ export CPPFLAGS="-I/usr/local/opt/openssl/include"
$ export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"Then execute the pycurl installation instructions$ export PYCURL_SSL_LIBRARY=openssl
$ pip install pycurlInstall opensslOpenssl installation on windows is more complicated, it is best to find the latest version of openssl exe installation package online before installation.Release notesVersion 2.0.2In order to facilitate the identification of the device and enhance the identification of the device, the label setting is added to the eshell and escan commands, and the user can identify the device by the user according to the actual needs.In this version, the instructions for use and the handling of common errors are added.Github-flavored Markdownpathcurve