在执行Chef配方时,我想确定是否有足够的可用磁盘空间来执行操作。
如何做到最好?
答案 0 :(得分:11)
Ohai都会检测节点的某些属性。这些属性被捕获为automatic attributes,可作为节点属性使用。
属性node ['filesystem']包含有关系统中每个设备的信息。为了获得特定设备的kb空间:
node['filesystem']['/dev/xvda1']['kb_available']
以下是来自Ohai的文件系统属性JSON的示例:
"filesystem": {
"/dev/xvda1": {
"kb_size": "521882300",
"kb_used": "119914572",
"kb_available": "375474240",
"percent_used": "25%",
"mount": "/",
"fs_type": "ext4",
"mount_options": [
"rw"
],
"uuid": "248b8180-f75f-48fc-a8be-e3ff3506c4d6"
},
"tmpfs": {
"kb_size": "1987292",
"kb_used": "0",
"kb_available": "1987292",
"percent_used": "0%",
"mount": "/dev/shm",
"fs_type": "tmpfs",
"mount_options": [
"rw",
"rootcontext=\"system_u:object_r:tmpfs_t:s0\""
]
}
}
答案 1 :(得分:-1)
cron 'cron for checking disk space' do
minute '00'
hour '12'
command 'disk_space_check.sh'
user 'smj'
end