---
- name: Statistics CPU Memory Disk Utilization
hosts: eisc
become: no
remote_user: root
gather_facts: no
tasks:
- name: "Statistics CPU Memory Disk Utilization..."
shell: |
hostname
ps -u root
free -g | grep "Mem" |awk '{printf " %sGB\n", $2}'
df -h| grep -vE '^文件系统|Filesystem|tmpfs|cdrom' | awk '{ print $1 " " $3" "$2" "$5}'|tr '\n' '|'
register: out
- debug:
msg: "DBLOAD hostres {{out.stdout_lines}} ENDLOAD"
---
- name: Statistics CPU Memory Disk Utilization
hosts: ST_REPORT
become: no
remote_user: sysomc
gather_facts: no
tasks:
- name: send shell package to hosts
copy:
src: ./hard_info/shell
dest: /home/sysomc/shell
force: yes
mode: 0755
- name: "Statistics CPU Memory Disk Utilization..."
shell: |
hostname
ifconfig | grep inet | grep -vE 'inet6|127.0.0.1' | awk '{print $2}'
uname -r
sh /home/sysomc/shell/getostype.sh
cat /sys/class/dmi/id/product_name
cat /proc/cpuinfo | grep name | sort | uniq|awk -F ":" '{printf $NF "\n"}'
cat /proc/cpuinfo | grep "physical id"|wc -l|awk '{printf $NF "\n"}'
top -bn1 | grep Cpu | awk '{printf $(3)+$(2) "\n"}'
free -g | grep "Mem" |awk '{printf " %sGB\n", $2}'
sh /home/sysomc/shell/querymemrate.sh
df -h| grep -vE '^文件系统|Filesystem|tmpfs|cdrom' | awk '{ print $1 " " $3" "$2" "$5}'|tr '\n' '|'
register: out
- debug:
msg: "DBLOAD hostres {{out.stdout_lines}} ENDLOAD"
---
- name: 注销RadHssGiDict.xml配置文件包含Huawei-AliasAPN的内容
hosts: ST_ALL_SEE
gather_facts: false
remote_user: sysomc
become: yes
become_user: see
vars:
path: /home/see/nginrun/config/Radius/RadHssGiDict.xml
result: "\t\t<!--<avpEntry name=\"Huawei-AliasAPN\" code=\"168\" vendorId=\"2011\" fragmentFlag=\"false\" encrypt=\"No\" datatype=\"Unsigned32\" minlength=\"0\" maxlength=\"247\" appAvpname=\"1021\"/> -->"
tasks:
- name: 查询“Huawei-AliasAPN”字段所在行,确认此文件有且只有一行。
shell:
cat -n {{path}} |grep Huawei-AliasAPN|awk -F' ' '{print $1}'
register: num
- name: 对该行进行sed替换操作
shell:
sed -i '{{num.stdout}} s/</<\!--</g' {{path}};sed -i '{{num.stdout}} s/>/> -->/g' {{path}}
- name: 查看修改后的结果
shell:
cat {{path}} |grep Huawei-AliasAPN
register: out
- name: 修改结果一致就执行重启RadiusAdapter 186进程
shell:
source /home/see/.cshrc;kc 186;p|grep RadiusAdapter|grep -v grep
register: sd
args: #使用csh解释器来解释.cshrc环境变量
executable: /bin/csh
when: out.stdout == '{{result}}'
- name: 打印结果
debug:
msg: "{{sd.stdout_lines}}"
---
- name: Statistics CPU Memory Disk Utilization
hosts: eisc
become: no
remote_user: root
gather_facts: no
tasks:
- name: "send shell package to hosts"
# 发送 包
copy:
src: /root/jianc.sh
dest: /root
force: yes
# 强制覆盖之前的文件
mode: 0755
# 权限
- name: "Statistics CPU Memory Disk Utilization..."
shell: |
echo "主机名字:"
hostname
ifconfig | grep inet | grep -vE 'inet6|127.0.0.1' | awk '{print $2}'
sh /root/jianc.sh
register: out
# 记录执行结果
- debug:
var: out.stdout_lines
# 打印执行结果
# 服务器巡检 sh 脚本:https://eisc.cn/index.php?c=read&id=476&page=1&cache=refresh
register: out
- debug:
var: out.stdout_lines
register: out
- debug:
msg: "DBLOAD hostres {{out.stdout_lines}} ENDLOAD"
#
Powered by ddoss.cn 12.0
©2015 - 2025 ddoss
渝公网安备50011302222260号
渝ICP备2024035333号
【实验平台安全承诺书】
小绿叶技术社区,优化网络中,点击查看配置信息
主机监控系统: 安全防火墙已开启检查cc攻击-下载文件完成后等待10s 恢复访问,检查连接数低于峰值恢复访问
您的IP:10.1.102.55,2025-12-17 19:05:25,Processed in 0.01572 second(s).