寻求帮助。尝试创建一个检查磁盘空间不足并列出服务器名称和文件中安装不足的安装的剧本。 在大多数情况下,这是可行的,当我选择它以确保失败时,它会正确找到60%或更高的坐骑。问题是不是 仅返回失败的安装,它将列出服务器上的所有安装是否失败。因为该列表上唯一应该是“此服务器的/ home上的硬盘空间服务器1低” 详细模式显示这是唯一具有失败状态的安装。而且帮助会很棒。
Declare @x table(Id int primary key, form_url varchar(256))
Insert @x values (1, 'Agents/Accounting/Agent.html')
Insert @x values (2,
'Modules/Vendors/Vendors/VendorInformation/Vendor.html')
Insert @x values (3,
'Modules/Customers/Customers/AccountInformation/Account.html?AccountNo')
Select
*
,FullPath = right(form_url,charindex('/',reverse(form_url)) - 1)
,OnlyHtml = left(right(form_url,charindex('/',reverse(form_url)) - 1) ,charindex('.html',right(form_url,charindex('/',reverse(form_url)) + 3)))
,AnotherOnlyHtml = right(substring(form_url,1,charindex('.html',form_url) + 4),charindex('/',reverse(substring(form_url,1,charindex('.html',form_url) + 4))) - 1)
from @x
这是我的输出:
---
- hosts: hostlist
remote_user: remoteuser
tasks:
- name: Ensuring that free space on all volumes are greater than 30%
assert:
that:
- not {{ item.mount and ( item.size_available < item.size_total - ( item.size_total|float * 0.6 ) ) }}
with_items: '{{ ansible_mounts }}'
ignore_errors: yes
register: disk_free
- name: get results
delegate_to: localhost
shell: "echo \"This server has low Hard Disk Space {{ ansible_hostname }} on {{ item.mount }} \" >> /app/temp/linux.hdd"
with_items: '{{ ansible_mounts }}'
when: disk_free|failed