【ansible 批量安装node-exporter 示例】

ansible 批量安装node-exporter 示例

1.登录主控制ansible

[root@hosts-vm27 ~]# cd /opt/
[root@hosts-vm27 opt]# ll
total 135516
drwxr-xr-x 8 root root       294 Oct 23 14:06 jdk1.8.0_361
-rw-r--r-- 1 root root 138762230 Oct 23 14:05 jdk-8u361-linux-x64.tar.gz
drwxr-xr-x 5 root root      4096 Oct 22 22:05 monitor
drwxr-xr-x 4 root root        47 Nov  4 15:59 rh
drwxr-xr-x 2 root root       106 Nov 14 15:16 tar
[root@hosts-vm27 opt]# ll monitor/
total 1613284
lrwxrwxrwx  1 root root         15 Oct 22 18:51 grafana -> grafana-9.5.10/
drwxr-xr-x 11 root root        227 Oct 22 19:00 grafana-9.5.10
-rwxr-xr-x  1 root root   92207343 Oct 22 18:49 grafana-enterprise-9.5.10.linux-amd64.tar.gz
-rwxr-xr-x  1 root root        582 Oct 22 18:50 install_grafana.sh
-rwxr-xr-x  1 root root        905 Oct 22 20:22 install_prome.sh
drwxr-xr-x  2 root root         89 Sep 29 20:13 node_exporter-1.3.1.linux-amd64
-rwxr-xr-x  1 root root    9034588 Oct 22 18:49 node_exporter-1.3.1.linux-amd64.tar.gz
lrwxrwxrwx  1 root root         29 Oct 22 18:52 prometheus -> prometheus-2.37.0.linux-amd64
drwxr-xr-x  5 root root        160 Oct 22 21:35 prometheus-2.37.0.linux-amd64
-rwxr-xr-x  1 root root   83782323 Oct 22 18:49 prometheus-2.37.0.linux-amd64.tar.gz
-rw-r--r--  1 root root 1466964485 Oct 22 19:45 prometheus26.tar.gz
[root@hosts-vm27 opt]#

2.配置ssh互信

[root@hosts-vm27 opt]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:dkkN5HoLFA3w3e0gjaCKJgr6sq8CF2kL76IWU9RJJwA root@hosts-vm27
The key's randomart image is:
+---[RSA 2048]----+
| E..+ooo++o      |
|   . ooo =.* .   |
|  ..  . o * = .  |
|. +o . . o o o   |
|o++o.   S +   .  |
|==+    . + .     |
|+oo       .      |
|+o.              |
|B*o              |
+----[SHA256]-----+
[root@hosts-vm27 opt]#
[root@hosts-vm27 opt]# ssh-copy-id 192.168.1.26
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.1.26's password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '192.168.1.26'"
and check to make sure that only the key(s) you wanted were added.

[root@hosts-vm27 opt]#
[root@hosts-vm27 opt]# ssh-copy-id 192.168.1.25
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.1.25's password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '192.168.1.25'"
and check to make sure that only the key(s) you wanted were added.

[root@hosts-vm27 opt]# ssh-copy-id 192.168.1.24
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.1.24's password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '192.168.1.24'"
and check to make sure that only the key(s) you wanted were added.

[root@hosts-vm27 opt]#
[root@hosts-vm27 opt]# ssh-copy-id 192.168.1.66
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.1.66's password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '192.168.1.66'"
and check to make sure that only the key(s) you wanted were added.

[root@hosts-vm27 opt]#
[root@hosts-vm27 opt]#
[root@hosts-vm27 opt]# ll /etc/ansible/hosts
-rw-r--r-- 1 root root 1162 Nov 13 15:51 /etc/ansible/hosts
[root@hosts-vm27 opt]#
[root@hosts-vm27 opt]# tail /etc/ansible/hosts

## db-[99:101]-node.example.com
[mysql-servers]
192.168.1.24
192.168.1.25
192.168.1.26
192.168.1.66
[root@hosts-vm27 opt]#

3.测试网络互通

[root@hosts-vm27 opt]# ansible mysql-servers -m ping
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
192.168.1.66 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "ping": "pong"
}
192.168.1.25 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "ping": "pong"
}
192.168.1.26 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "ping": "pong"
}
192.168.1.24 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "ping": "pong"
}

4.创建目录并拷贝node-exporter安装包和脚本

[root@hosts-vm27 opt]# ansible mysql-servers -m command -a "ls -lh /opt"
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
192.168.1.66 | CHANGED | rc=0 >>
total 0
drwxr-xr-x. 2 root root 99 Nov 13 15:59 tar
192.168.1.26 | CHANGED | rc=0 >>
total 0
drwxr-xr-x. 2 root root 99 Nov 13 16:03 tar
192.168.1.25 | CHANGED | rc=0 >>
total 0
drwxr-xr-x. 2 root root 99 Nov 13 16:03 tar
192.168.1.24 | CHANGED | rc=0 >>
total 0
drwxr-xr-x. 3 root root  27 Nov 14 16:50 rh
drwxr-xr-x. 2 root root 203 Nov 14 18:09 tar
[root@hosts-vm27 opt]#

[root@hosts-vm27 opt]# cd monitor/
[root@hosts-vm27 monitor]#
[root@hosts-vm27 monitor]# ansible mysql-servers -m command -a "mkdir -p /opt/monitor"
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
[WARNING]: Consider using the file module with state=directory rather than running 'mkdir'.  If you need to use command because file is insufficient you can add 'warn: false' to this command task or set 'command_warnings=False' in ansible.cfg to get rid of this message.
192.168.1.26 | CHANGED | rc=0 >>

192.168.1.25 | CHANGED | rc=0 >>

192.168.1.66 | CHANGED | rc=0 >>

192.168.1.24 | CHANGED | rc=0 >>

[root@hosts-vm27 monitor]#
[root@hosts-vm27 monitor]# ansible mysql-servers -m command -a "ls -lh /opt"
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
192.168.1.26 | CHANGED | rc=0 >>
total 0
drwxr-xr-x. 2 root root  6 Nov 17 14:34 monitor
drwxr-xr-x. 2 root root 99 Nov 13 16:03 tar
192.168.1.25 | CHANGED | rc=0 >>
total 0
drwxr-xr-x. 2 root root  6 Nov 17 14:34 monitor
drwxr-xr-x. 2 root root 99 Nov 13 16:03 tar
192.168.1.66 | CHANGED | rc=0 >>
total 0
drwxr-xr-x. 2 root root  6 Nov 17 14:30 monitor
drwxr-xr-x. 2 root root 99 Nov 13 15:59 tar
192.168.1.24 | CHANGED | rc=0 >>
total 0
drwxr-xr-x. 2 root root   6 Nov 17 14:34 monitor
drwxr-xr-x. 3 root root  27 Nov 14 16:50 rh
drwxr-xr-x. 2 root root 203 Nov 14 18:09 tar
[root@hosts-vm27 monitor]#
[root@hosts-vm27 monitor]# ansible mysql-servers -m copy -a "src=node_exporter-1.3.1.linux-amd64.tar.gz dest=/opt/monitor"
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
192.168.1.26 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": true,
    "checksum": "9f33bb92952a1f7e333d76860703afcb87ce0642",
    "dest": "/opt/monitor/node_exporter-1.3.1.linux-amd64.tar.gz",
    "gid": 0,
    "group": "root",
    "md5sum": "5d12549751142ffd0725fb4427f211ef",
    "mode": "0644",
    "owner": "root",
    "secontext": "system_u:object_r:usr_t:s0",
    "size": 9034588,
    "src": "/root/.ansible/tmp/ansible-tmp-1700202936.36-14272-49436219706589/source",
    "state": "file",
    "uid": 0
}
192.168.1.66 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": true,
    "checksum": "9f33bb92952a1f7e333d76860703afcb87ce0642",
    "dest": "/opt/monitor/node_exporter-1.3.1.linux-amd64.tar.gz",
    "gid": 0,
    "group": "root",
    "md5sum": "5d12549751142ffd0725fb4427f211ef",
    "mode": "0644",
    "owner": "root",
    "secontext": "system_u:object_r:usr_t:s0",
    "size": 9034588,
    "src": "/root/.ansible/tmp/ansible-tmp-1700202936.36-14274-87162137666346/source",
    "state": "file",
    "uid": 0
}
192.168.1.25 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": true,
    "checksum": "9f33bb92952a1f7e333d76860703afcb87ce0642",
    "dest": "/opt/monitor/node_exporter-1.3.1.linux-amd64.tar.gz",
    "gid": 0,
    "group": "root",
    "md5sum": "5d12549751142ffd0725fb4427f211ef",
    "mode": "0644",
    "owner": "root",
    "secontext": "system_u:object_r:usr_t:s0",
    "size": 9034588,
    "src": "/root/.ansible/tmp/ansible-tmp-1700202936.33-14270-35266519335829/source",
    "state": "file",
    "uid": 0
}
192.168.1.24 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": true,
    "checksum": "9f33bb92952a1f7e333d76860703afcb87ce0642",
    "dest": "/opt/monitor/node_exporter-1.3.1.linux-amd64.tar.gz",
    "gid": 0,
    "group": "root",
    "md5sum": "5d12549751142ffd0725fb4427f211ef",
    "mode": "0644",
    "owner": "root",
    "secontext": "system_u:object_r:usr_t:s0",
    "size": 9034588,
    "src": "/root/.ansible/tmp/ansible-tmp-1700202936.4-14268-98104309874668/source",
    "state": "file",
    "uid": 0
}
[root@hosts-vm27 monitor]#

[root@hosts-vm27 monitor]# ansible mysql-servers -m copy -a "src=install_node.sh dest=/opt/monitor"
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
192.168.1.26 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": true,
    "checksum": "45782e2114e1a86c0f1ce36c1a2236ca010f351b",
    "dest": "/opt/monitor/install_node.sh",
    "gid": 0,
    "group": "root",
    "md5sum": "dd633ca5428c246f731c830dc42020f9",
    "mode": "0644",
    "owner": "root",
    "secontext": "system_u:object_r:usr_t:s0",
    "size": 597,
    "src": "/root/.ansible/tmp/ansible-tmp-1700202974.75-14553-171348241204765/source",
    "state": "file",
    "uid": 0
}
192.168.1.25 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": true,
    "checksum": "45782e2114e1a86c0f1ce36c1a2236ca010f351b",
    "dest": "/opt/monitor/install_node.sh",
    "gid": 0,
    "group": "root",
    "md5sum": "dd633ca5428c246f731c830dc42020f9",
    "mode": "0644",
    "owner": "root",
    "secontext": "system_u:object_r:usr_t:s0",
    "size": 597,
    "src": "/root/.ansible/tmp/ansible-tmp-1700202974.76-14551-70452038567216/source",
    "state": "file",
    "uid": 0
}
192.168.1.66 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": true,
    "checksum": "45782e2114e1a86c0f1ce36c1a2236ca010f351b",
    "dest": "/opt/monitor/install_node.sh",
    "gid": 0,
    "group": "root",
    "md5sum": "dd633ca5428c246f731c830dc42020f9",
    "mode": "0644",
    "owner": "root",
    "secontext": "system_u:object_r:usr_t:s0",
    "size": 597,
    "src": "/root/.ansible/tmp/ansible-tmp-1700202974.77-14554-143893062474701/source",
    "state": "file",
    "uid": 0
}
192.168.1.24 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": true,
    "checksum": "45782e2114e1a86c0f1ce36c1a2236ca010f351b",
    "dest": "/opt/monitor/install_node.sh",
    "gid": 0,
    "group": "root",
    "md5sum": "dd633ca5428c246f731c830dc42020f9",
    "mode": "0644",
    "owner": "root",
    "secontext": "system_u:object_r:usr_t:s0",
    "size": 597,
    "src": "/root/.ansible/tmp/ansible-tmp-1700202974.75-14549-88295804853297/source",
    "state": "file",
    "uid": 0
}
[root@hosts-vm27 monitor]# ansible mysql-servers -m command -a "ls -lh /opt/monitor"
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
192.168.1.26 | CHANGED | rc=0 >>
total 8.7M
-rw-r--r--. 1 root root  597 Nov 17 14:36 install_node.sh
-rw-r--r--. 1 root root 8.7M Nov 17 14:35 node_exporter-1.3.1.linux-amd64.tar.gz
192.168.1.66 | CHANGED | rc=0 >>
total 8.7M
-rw-r--r--. 1 root root  597 Nov 17 14:32 install_node.sh
-rw-r--r--. 1 root root 8.7M Nov 17 14:31 node_exporter-1.3.1.linux-amd64.tar.gz
192.168.1.25 | CHANGED | rc=0 >>
total 8.7M
-rw-r--r--. 1 root root  597 Nov 17 14:36 install_node.sh
-rw-r--r--. 1 root root 8.7M Nov 17 14:35 node_exporter-1.3.1.linux-amd64.tar.gz
192.168.1.24 | CHANGED | rc=0 >>
total 8.7M
-rw-r--r--. 1 root root  597 Nov 17 14:36 install_node.sh
-rw-r--r--. 1 root root 8.7M Nov 17 14:35 node_exporter-1.3.1.linux-amd64.tar.gz
[root@hosts-vm27 monitor]#

5.解压node-exporter安装包、赋权脚本、创建软连接

[root@hosts-vm27 monitor]# ansible mysql-servers -m raw -a "cd /opt/monitor && chmod 755 *.sh && tar xf node_exporter-1.3.1.linux-amd64.tar.gz "
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
192.168.1.25 | CHANGED | rc=0 >>
Shared connection to 192.168.1.25 closed.

192.168.1.66 | CHANGED | rc=0 >>
Shared connection to 192.168.1.66 closed.

192.168.1.26 | CHANGED | rc=0 >>
Shared connection to 192.168.1.26 closed.

192.168.1.24 | CHANGED | rc=0 >>
Shared connection to 192.168.1.24 closed.

[root@hosts-vm27 monitor]# ansible mysql-servers -m command -a "ls -lh /opt/monitor"
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
192.168.1.26 | CHANGED | rc=0 >>
total 8.7M
-rwxr-xr-x. 1 root root  597 Nov 17 14:36 install_node.sh
drwxr-xr-x. 2 3434 3434   89 Jun 26 21:03 node_exporter-1.3.1.linux-amd64
-rw-r--r--. 1 root root 8.7M Nov 17 14:35 node_exporter-1.3.1.linux-amd64.tar.gz
192.168.1.66 | CHANGED | rc=0 >>
total 8.7M
-rwxr-xr-x. 1 root root  597 Nov 17 14:32 install_node.sh
drwxr-xr-x. 2 3434 3434   89 Jun 26 21:03 node_exporter-1.3.1.linux-amd64
-rw-r--r--. 1 root root 8.7M Nov 17 14:31 node_exporter-1.3.1.linux-amd64.tar.gz
192.168.1.25 | CHANGED | rc=0 >>
total 8.7M
-rwxr-xr-x. 1 root root  597 Nov 17 14:36 install_node.sh
drwxr-xr-x. 2 3434 3434   89 Jun 26 21:03 node_exporter-1.3.1.linux-amd64
-rw-r--r--. 1 root root 8.7M Nov 17 14:35 node_exporter-1.3.1.linux-amd64.tar.gz
192.168.1.24 | CHANGED | rc=0 >>
total 8.7M
-rwxr-xr-x. 1 root root  597 Nov 17 14:36 install_node.sh
drwxr-xr-x. 2 3434 3434   89 Jun 26 21:03 node_exporter-1.3.1.linux-amd64
-rw-r--r--. 1 root root 8.7M Nov 17 14:35 node_exporter-1.3.1.linux-amd64.tar.gz
[root@hosts-vm27 monitor]#
[root@hosts-vm27 monitor]# ansible mysql-servers -m raw -a "cd /opt/monitor && ln -s node_exporter-1.3.1.linux-amd64 node_exporter"
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
192.168.1.26 | CHANGED | rc=0 >>
Shared connection to 192.168.1.26 closed.

192.168.1.25 | CHANGED | rc=0 >>
Shared connection to 192.168.1.25 closed.

192.168.1.66 | CHANGED | rc=0 >>
Shared connection to 192.168.1.66 closed.

192.168.1.24 | CHANGED | rc=0 >>
Shared connection to 192.168.1.24 closed.

[root@hosts-vm27 monitor]#
[root@hosts-vm27 monitor]# ansible mysql-servers -m command -a "ls -lh /opt/monitor"
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
192.168.1.26 | CHANGED | rc=0 >>
total 8.7M
-rwxr-xr-x. 1 root root  597 Nov 17 14:36 install_node.sh
lrwxrwxrwx. 1 root root   31 Nov 17 14:42 node_exporter -> node_exporter-1.3.1.linux-amd64
drwxr-xr-x. 2 3434 3434   89 Jun 26 21:03 node_exporter-1.3.1.linux-amd64
-rw-r--r--. 1 root root 8.7M Nov 17 14:35 node_exporter-1.3.1.linux-amd64.tar.gz
192.168.1.25 | CHANGED | rc=0 >>
total 8.7M
-rwxr-xr-x. 1 root root  597 Nov 17 14:36 install_node.sh
lrwxrwxrwx. 1 root root   31 Nov 17 14:42 node_exporter -> node_exporter-1.3.1.linux-amd64
drwxr-xr-x. 2 3434 3434   89 Jun 26 21:03 node_exporter-1.3.1.linux-amd64
-rw-r--r--. 1 root root 8.7M Nov 17 14:35 node_exporter-1.3.1.linux-amd64.tar.gz
192.168.1.66 | CHANGED | rc=0 >>
total 8.7M
-rwxr-xr-x. 1 root root  597 Nov 17 14:32 install_node.sh
lrwxrwxrwx. 1 root root   31 Nov 17 14:38 node_exporter -> node_exporter-1.3.1.linux-amd64
drwxr-xr-x. 2 3434 3434  128 Nov 17 14:39 node_exporter-1.3.1.linux-amd64
-rw-r--r--. 1 root root 8.7M Nov 17 14:31 node_exporter-1.3.1.linux-amd64.tar.gz
192.168.1.24 | CHANGED | rc=0 >>
total 8.7M
-rwxr-xr-x. 1 root root  597 Nov 17 14:36 install_node.sh
lrwxrwxrwx. 1 root root   31 Nov 17 14:42 node_exporter -> node_exporter-1.3.1.linux-amd64
drwxr-xr-x. 2 3434 3434   89 Jun 26 21:03 node_exporter-1.3.1.linux-amd64
-rw-r--r--. 1 root root 8.7M Nov 17 14:35 node_exporter-1.3.1.linux-amd64.tar.gz
[root@hosts-vm27 monitor]#
[root@hosts-vm27 monitor]#

6.脚本安装node-exporter

[root@hosts-vm27 monitor]#
[root@hosts-vm27 monitor]# ansible mysql-servers -m raw -a "cd /opt/monitor && ./install_node.sh"
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
192.168.1.25 | CHANGED | rc=0 >>
Created symlink from /etc/systemd/system/multi-user.target.wants/node_exporter.service to /usr/lib/systemd/system/node_exporter.service.
● node_exporter.service - node_exporter
   Loaded: loaded (/usr/lib/systemd/system/node_exporter.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2023-11-17 14:43:46 CST; 98ms ago
 Main PID: 15505 (node_exporter)
   CGroup: /system.slice/node_exporter.service
           └─15505 /opt/monitor/node_exporter/node_exporter --web.listen-addr...

Nov 17 14:43:46 hosts-vm25 node_exporter[15505]: ts=2023-11-17T06:43:46.077Z cal...e
Nov 17 14:43:46 hosts-vm25 node_exporter[15505]: ts=2023-11-17T06:43:46.077Z cal...e
Nov 17 14:43:46 hosts-vm25 node_exporter[15505]: ts=2023-11-17T06:43:46.077Z cal...x
Nov 17 14:43:46 hosts-vm25 node_exporter[15505]: ts=2023-11-17T06:43:46.077Z cal...s
Nov 17 14:43:46 hosts-vm25 node_exporter[15505]: ts=2023-11-17T06:43:46.077Z cal...e
Nov 17 14:43:46 hosts-vm25 node_exporter[15505]: ts=2023-11-17T06:43:46.077Z cal...t
Nov 17 14:43:46 hosts-vm25 node_exporter[15505]: ts=2023-11-17T06:43:46.077Z cal...s
Nov 17 14:43:46 hosts-vm25 node_exporter[15505]: ts=2023-11-17T06:43:46.077Z cal...s
Nov 17 14:43:46 hosts-vm25 node_exporter[15505]: ts=2023-11-17T06:43:46.077Z cal...9
Nov 17 14:43:46 hosts-vm25 node_exporter[15505]: ts=2023-11-17T06:43:46.079Z cal...e
Hint: Some lines were ellipsized, use -l to show in full.
Shared connection to 192.168.1.25 closed.

192.168.1.66 | CHANGED | rc=0 >>
Created symlink from /etc/systemd/system/multi-user.target.wants/node_exporter.service to /usr/lib/systemd/system/node_exporter.service.
● node_exporter.service - node_exporter
   Loaded: loaded (/usr/lib/systemd/system/node_exporter.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2023-11-17 14:39:58 CST; 91ms ago
 Main PID: 29611 (node_exporter)
   CGroup: /system.slice/node_exporter.service
           └─29611 /opt/monitor/node_exporter/node_exporter --web.listen-addr...

Nov 17 14:39:58 host62 systemd[1]: Started node_exporter.
Shared connection to 192.168.1.66 closed.

192.168.1.26 | CHANGED | rc=0 >>
Created symlink from /etc/systemd/system/multi-user.target.wants/node_exporter.service to /usr/lib/systemd/system/node_exporter.service.
● node_exporter.service - node_exporter
   Loaded: loaded (/usr/lib/systemd/system/node_exporter.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2023-11-17 14:43:46 CST; 91ms ago
 Main PID: 27265 (node_exporter)
   CGroup: /system.slice/node_exporter.service
           └─27265 /opt/monitor/node_exporter/node_exporter --web.listen-addr...

Nov 17 14:43:46 hosts-vm26 node_exporter[27265]: ts=2023-11-17T06:43:46.651Z cal...e
Nov 17 14:43:46 hosts-vm26 node_exporter[27265]: ts=2023-11-17T06:43:46.651Z cal...e
Nov 17 14:43:46 hosts-vm26 node_exporter[27265]: ts=2023-11-17T06:43:46.651Z cal...x
Nov 17 14:43:46 hosts-vm26 node_exporter[27265]: ts=2023-11-17T06:43:46.651Z cal...s
Nov 17 14:43:46 hosts-vm26 node_exporter[27265]: ts=2023-11-17T06:43:46.651Z cal...e
Nov 17 14:43:46 hosts-vm26 node_exporter[27265]: ts=2023-11-17T06:43:46.651Z cal...t
Nov 17 14:43:46 hosts-vm26 node_exporter[27265]: ts=2023-11-17T06:43:46.651Z cal...s
Nov 17 14:43:46 hosts-vm26 node_exporter[27265]: ts=2023-11-17T06:43:46.651Z cal...s
Nov 17 14:43:46 hosts-vm26 node_exporter[27265]: ts=2023-11-17T06:43:46.652Z cal...9
Nov 17 14:43:46 hosts-vm26 node_exporter[27265]: ts=2023-11-17T06:43:46.653Z cal...e
Hint: Some lines were ellipsized, use -l to show in full.
Shared connection to 192.168.1.26 closed.

192.168.1.24 | CHANGED | rc=0 >>
Created symlink from /etc/systemd/system/multi-user.target.wants/node_exporter.service to /usr/lib/systemd/system/node_exporter.service.
● node_exporter.service - node_exporter
   Loaded: loaded (/usr/lib/systemd/system/node_exporter.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2023-11-17 14:43:47 CST; 243ms ago
 Main PID: 4206 (node_exporter)
   CGroup: /system.slice/node_exporter.service
           └─4206 /opt/monitor/node_exporter/node_exporter --web.listen-addre...

Nov 17 14:43:47 hosts-vm24 node_exporter[4206]: ts=2023-11-17T06:43:47.447Z call...e
Nov 17 14:43:47 hosts-vm24 node_exporter[4206]: ts=2023-11-17T06:43:47.447Z call...e
Nov 17 14:43:47 hosts-vm24 node_exporter[4206]: ts=2023-11-17T06:43:47.447Z call...x
Nov 17 14:43:47 hosts-vm24 node_exporter[4206]: ts=2023-11-17T06:43:47.447Z call...s
Nov 17 14:43:47 hosts-vm24 node_exporter[4206]: ts=2023-11-17T06:43:47.447Z call...e
Nov 17 14:43:47 hosts-vm24 node_exporter[4206]: ts=2023-11-17T06:43:47.447Z call...t
Nov 17 14:43:47 hosts-vm24 node_exporter[4206]: ts=2023-11-17T06:43:47.447Z call...s
Nov 17 14:43:47 hosts-vm24 node_exporter[4206]: ts=2023-11-17T06:43:47.447Z call...s
Nov 17 14:43:47 hosts-vm24 node_exporter[4206]: ts=2023-11-17T06:43:47.450Z call...9
Nov 17 14:43:47 hosts-vm24 node_exporter[4206]: ts=2023-11-17T06:43:47.452Z call...e
Hint: Some lines were ellipsized, use -l to show in full.
Shared connection to 192.168.1.24 closed.

[root@hosts-vm27 monitor]#

7.检查进程

[root@hosts-vm27 monitor]#
[root@hosts-vm27 monitor]# ansible mysql-servers -m raw -a "ps -ef|grep node"
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
192.168.1.25 | CHANGED | rc=0 >>
root     15505     1  0 14:43 ?        00:00:00 /opt/monitor/node_exporter/node_exporter --web.listen-address=:8089
root     15545 15374  0 14:44 pts/1    00:00:00 bash -c ps -ef|grep node
root     15557 15545  0 14:44 pts/1    00:00:00 grep node
Shared connection to 192.168.1.25 closed.

192.168.1.24 | CHANGED | rc=0 >>
root      4206     1  1 14:43 ?        00:00:00 /opt/monitor/node_exporter/node_exporter --web.listen-address=:8089
root      4249  4076  0 14:44 pts/1    00:00:00 bash -c ps -ef|grep node
root      4261  4249  0 14:44 pts/1    00:00:00 grep node
Shared connection to 192.168.1.24 closed.

192.168.1.66 | CHANGED | rc=0 >>
root     29611     1  1 14:39 ?        00:00:00 /opt/monitor/node_exporter/node_exporter --web.listen-address=:8089
root     29658 29481  0 14:40 pts/1    00:00:00 bash -c ps -ef|grep node
root     29670 29658  0 14:40 pts/1    00:00:00 grep node
Shared connection to 192.168.1.66 closed.

192.168.1.26 | CHANGED | rc=0 >>
root     27265     1  0 14:43 ?        00:00:00 /opt/monitor/node_exporter/node_exporter --web.listen-address=:8089
root     27306 27135  0 14:44 pts/1    00:00:00 bash -c ps -ef|grep node
root     27318 27306  0 14:44 pts/1    00:00:00 grep node
Shared connection to 192.168.1.26 closed.

[root@hosts-vm27 monitor]#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值