首页 > 其他分享 >基于ansible playbook 自动化巡检生成xlsx报告

基于ansible playbook 自动化巡检生成xlsx报告

时间:2024-08-15 09:52:33浏览次数:8  
标签:control xlsx overview usedutilization 1.88 ansible playbook true

IAAS自动化巡检生成xlsx报告

项目结构:

├── README.md
├── filter_plugins 生成json数据
├── generate_xlsx.yml 生成xlsx文件
├── group_vars 全局变量 
├── library 数据处理及生成xlsx模块
├── report 最终xlsx报告保存
├── roles  巡检代码
├── save_data json数据保存
├── site.yml  巡检入口
└── xlsx_template  模板

注意事项:

部署节点的IP需要放在control主机组的第一位,比如部署节点IP是:1.88.88.1
example:
	[control]
	1.88.88.1
	1.88.88.2
	1.88.88.3

执行巡检并处理json数据

注意:执行节点要与目标节点免密

  • ansible-playbook -i /etc/ansible/hosts/00-nodes site.yml

数据处理后生成os和platform的json数据(生成xlsx报告使用)

{
      "os": {
            "1.88.88.1": {
                  "cpu_usedutilization": "5.17%", 
                  "default_ipv4": "1.88.88.1", 
                  "hostname": "control01", 
                  "mem_usedutilization": "27.46%", 
                  "os_pretty_name": "CentOS Linux 7 (Core)", 
                  "size_usedutilization": "64%", 
                  "uptime": "256"
            }, 
            "1.88.88.2": {
                  "cpu_usedutilization": "9.04%", 
                  "default_ipv4": "1.88.88.2", 
                  "hostname": "control02", 
                  "mem_usedutilization": "37.85%", 
                  "os_pretty_name": "CentOS Linux 7 (Core)", 
                  "size_usedutilization": "56%", 
                  "uptime": "256"
            }, 
            "1.88.88.3": {
                  "cpu_usedutilization": "5.39%", 
                  "default_ipv4": "1.88.88.3", 
                  "hostname": "control03", 
                  "mem_usedutilization": "24.08%", 
                  "os_pretty_name": "CentOS Linux 7 (Core)", 
                  "size_usedutilization": "44%", 
                  "uptime": "256"
            }, 
      }, 
      "platform": {
            "compute_overview": {
                  "cinder_volume": true, 
                  "nova_compute": true, 
                  "openvswitch_agent": true
            }, 
            "control_overview": {
                  "control_ceph_mon": true, 
                  "control_cinder": true, 
                  "control_glance": true, 
                  "control_haproxy": true, 
                  "control_heat": true, 
                  "control_horizon": true, 
                  "control_keepalived": true, 
                  "control_keystone": true, 
                  "control_memcached": true, 
                  "control_mysql": true, 
                  "control_network": true, 
                  "control_network_dhcp": true, 
                  "control_neutron": true, 
                  "control_nova": true, 
                  "control_rabbitmq": true
            }, 
            "platform_overview": {
                  "ceph_cluster_overview": {
                        "ceph_health_status": true, 
                        "ceph_osd_status": true, 
                        "ceph_storage_rate": "1.94%", 
                        "ceph_storage_total": "218TiB", 
                        "ceph_storage_used": "4.2TiB"
                  }, 
                  "cluser_node_count": "8", 
                  "engineer_name": "test", 
                  "iaas_memory_overview": {
                        "memory_total_gb": "306124GiB", 
                        "memory_total_mb": "3134712", 
                        "memory_used_mb": "245760", 
                        "mepm_used_rate": "7.84%"
                  }, 
                  "iaas_service_overview": {
                        "ops_cinder": false, 
                        "ops_heat": false, 
                        "ops_neutron": true, 
                        "ops_nova": false
                  }, 
                  "iaas_url": "https://1.88.88253:81", 
                  "iaas_vcpus_overview": {
                        "vcpus_core_rate": "24.11%", 
                        "vcpus_core_total": "448", 
                        "vcpus_core_used": "108"
                  }, 
                  "iaas_version": "train", 
                  "iaas_vm_sum": 11, 
                  "montior_url": "https://1.88.88.253:3000", 
                  "mysql_cluster_status": true, 
                  "now_day": "2021-03-02", 
                  "rabbitmq_cluster_status": true
            }
      }
}

生成xlsx巡检报告

注意:执行前当前节点需要预先安装openpyxl模块pip install openpyxl

  • ansible-playbook generate_xlsx.yml

xlxs报告模板

在这里插入图片描述

在这里插入图片描述

代码获取方式

因代码不便于文字编辑,需要按下面自取吧
请-微-信-搜索弓-种-号:企鹅侠
发送关键词:iaas巡检

标签:control,xlsx,overview,usedutilization,1.88,ansible,playbook,true
From: https://blog.csdn.net/unbuntu_luo/article/details/141116652

相关文章

  • ansible 设置环境变量
    这里有个小知识点在Linux系统中,用户环境变量文件是用来设置用户级别的环境变量和shell配置的文件。这些文件可以控制用户的环境,包括路径、命令别名、shell提示符、自定义函数等。不同的文件在不同的情况下会被加载,并对用户的shell会话产生影响。常见的用户环境变量文件及......
  • ansible handlers
    handlers01.yaml----hosts:ubuntuhandlers:-name:restartapacheservice:name=apache2state=restartedtasks:-name:确保APT包列表是最新的apt:update_cache=yes-name:部署apache2apt:name=apache2state=present-name:......
  • ansible include方法使用
    root@test:~#catRestartPHPProcess.yml----name:RestartPHPProcess#该Task名为RestartPHPProcessservice:name=sshstate=restarted#调用service模块,重启名为php-#fpm的服务root@test:~#cattest.yml----hosts:localhostremote_user:roott......
  • python-xlsxwriter的基本使用
    安装xlsxwriter:pipinstallXlsxWriter简单实例:#coding:utf-8importxlsxwriterworkbook=xlsxwriter.Workbook('demo1.xlsx')#创建一个Excel文件worksheet=workbook.add_worksheet()#创建一个工作表对象worksheet.set_column('A:A',20)#设定第一列(A)宽度为20像素bold=......
  • 【Ansible 学习之旅】Ansible核心工具介绍
    系列文章Ansible介绍和架构Ansible安装和入门配置控制机器和受控机器Inventory文件介绍目录系列文章利用ansible实现管理的主要方式ansible-docansibleansible-playbookansible-vaultansible-consoleansible-galaxy利用ansible实现管理的主要方式Ad-Hoc即......
  • 使用ansible安装mongodb分片集群
    【说明】使用ansible安装一个分片集群,三台服务器,三个mongos,三个config,三个分片节点,每三个分片有三个副本(每个节点运行三个端口的mongod)  [mongo_servers]10.x.x.21ansible_user=rootansible_ssh_pass=xxxxxxxxcluster_role=mongo1......
  • XLSX.utils.decode_range 使用,选定表格范围
    表格选定范围设置边框当需要设置特定范围(如A6到E19)的边框时,可以使用XLSX.utils.decode_range和XLSX.utils.encode_cell方法来处理。以下是如何使用decode_range解析范围并设置边框样式的示例:importXLSXfrom'xlsx-js-style';constworkbook=XLSX.utils.book_new(......
  • xlsx-js-style 如何配置表格样式
    xlsx-js-style是一个用于处理Excel文件的JavaScript库,基于xlsx库并添加了对样式的支持。通过xlsx-js-style,你可以设置单元格的字体、背景、边框等样式。下面是如何使用xlsx-js-style库配置表格样式的步骤。1.安装库首先,确保你已经安装了xlsx-js-style库:npminstal......
  • OAF export data from VO in xlsx format
    InthisarticlewearegoingtoseehowtoexportviewobjectinMicrosoftofficeexcelxlsxformatToexportwithxlsxformatfewbasicthingsneededareJarfiles(Listofjari'veusedisshowninbelowscreenshot)ForbetterunderstandingI’lli......
  • ansible-yaml
    ansible-playbook简介playbooks记录并执行Ansible的配置、部署和编排功能。使用yaml格式,文件以yaml或者yml结尾官方网站:https://docs.ansible.com/ansible/latest/user_guide/playbooks.html#working-with-playbooksyaml语言YAML(YetAnotherMarkupLanguage)不是标记语言,它......