[英]Ansible playbook to see memory usage of servers
I currently am trying to find out how to get the % of memory used on my server.我目前正在尝试找出如何获得我的服务器上使用的内存百分比。 Or at least some sort of information regarding the memory usage.
或者至少是关于内存使用情况的某种信息。
I know that by using the following我知道通过使用以下
---
- hosts: all
gather_facts: False
tasks:
- name: run uptime
shell: uptime
register: uptime
- name: show uptime
debug: var=uptime
I'm able to see the uptime, but not sure what I have to modify to see the memory?我能够看到正常运行时间,但不确定我必须修改什么才能看到内存? Even if I could see just the total memory of the server and the memory used it would be useful
即使我只能看到服务器的总内存和使用的内存,它也会很有用
You can try running something like this, you can get memory usage and other information,你可以尝试运行这样的东西,你可以获得内存使用情况和其他信息,
- name: Hardware info
vars:
msg: |
RAM: {{ ansible_memtotal_mb }}
SWAP: {{ ansible_memory_mb.swap.total }}
debug:
msg: "{{ msg.split('\n') }}"
Or you can also try running some shell command using grep/awk or something like cat /proc/meminfo
or vmstat
to get the memory usage on your servers and grab them in some file or something via output of ansible.或者,您也可以尝试使用 grep/awk 或
cat /proc/meminfo
或vmstat
类的东西运行一些 shell 命令,以获取服务器上的内存使用情况,并通过 ansible 的输出将它们抓取到某个文件或其他内容中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.