如何找到厨师食谱中可用的磁盘? [英] How can I find the disk available in a Chef recipe?
本文介绍了如何找到厨师食谱中可用的磁盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在执行Chef配方时,我想确定是否有足够的可用磁盘空间来执行操作。
While a Chef recipe is executing, I want to determine if there is sufficient free disk space available to perform an operation.
如何做到最好?
推荐答案
Ohai 每次运行时都会检测到aa节点的某些属性。这些属性被捕获为自动属性,并且可以作为节点属性使用。
Ohai detects certain properties of a a node each time it is run. These properties are captured as automatic attributes and are available to you as node attributes.
属性节点['filesystem']包含有关系统上每个设备的信息。要获取特定设备的可用空间(以kb为单位),
The attribute node['filesystem'] contains information about each of the devices on your system. To get the space available in kb, for a specific device:
node['filesystem']['/dev/xvda1']['kb_available']
以下是来自Ohai的文件系统属性JSON的示例:
The following is an example of the filesystem attribute JSON from Ohai:
"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\""
]
}
}
这篇关于如何找到厨师食谱中可用的磁盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文