I want to collect some information of the Remote Host, I try to use Ansible to execute some shell commands, but when executed on some machines, I found that its efficiency is a bit slow and consumes a lot of resources.
Here are some shell commands I wrote to collect the information I want.
# Startup status of some services
chkconfig --list ip6tables| awk '{$1=""; print $0}' | sed 's/\s\s*/ /g'
# Some kernel parameters, such as vm.swappiness
sysctl vm.swappiness|awk '{print $3}'
# Other parameters that need to read the file
cat /etc/logrotate.conf |grep -i '^rotate'|awk '{print $2}'
# some database information
lsnrctl status | grep -v 'Connecting'|grep -Po '(?<=HOST=)[^)]+|(?<=PORT=)\d+'|sed 'N;s/\n/:/'
I use the shell
module of Ansible to execute, but on some machines, it executes slowly, about 55 similar commands, and the execution takes more than 100 seconds.
Is there any other way to increase speed and reduce resource consumption?