Hi All,
I’m looking for extract information like Load, memory usage, uptime,swap space from all linux servers in csv farmat. could please anyone suggest playbook for the same.
Regards,
Shivu
Hi All,
I’m looking for extract information like Load, memory usage, uptime,swap space from all linux servers in csv farmat. could please anyone suggest playbook for the same.
Regards,
Shivu
The Ansible setup module will give you facts about target systems including memory usage, uptime,swap space, it would be fairly simple to extend this with a custom fact to also grab the contents of /proc/loadavg
See https://docs.ansible.com/ansible/latest/collections/ansible/builtin/setup_module.html or run ‘$ ansible-doc setup’
Reading between the lines though, it sounds like you have been tasked to use ansible as an ersatz monitoring solution? Scheduling ansible runs against a number of hosts to grab runtime stats might not be the most efficient use case, you may want to investigate dedicated tooling like Sensu, Nagios, Zabbix or similar.
try ansible-cmdb
I’ve tried ansible-cmdb but it doesn’t work as well as I would like and it’s not been updates for a long time. I did try and contact the author as i had some ideas to make it better but got no reply.
I created this to solve the same problem but I store the results in a mongoDB. I created an ansible-galaxy module for it here: https://galaxy.ansible.com/apidb/ansibledb_opensource
You can extend standard facts by adding the custom_extensions role which integrates with ansibleDB and gives you the ability to write your own facts and add them in so the setup module adds them int to the output: https://github.com/apidb-io/custom_extensions
There are lots of examples to pull out the data using JQ and add in comma delimiter output for excel.