按内存大小过滤小兵

时间:2016-10-12 10:38:46

标签: salt-stack

在Salt Stack中是否可以按内存大小过滤小部件,但是指示内存大小必须大于或小于的值,而不是等于?所以不要这样:

salt -C 'G@mem_total > 993' test.ping

我需要这样的事情:

    public EditObras(string id, string NomeObra, string idCliente, string DataPLevantamento, string DataRLevantamento, string Estado, string DataRMateriais, string DataInicioObra, string DataConclusao, string DataVestoria, string Obs, string Prompor, string Levantpor, string executpor)
        {
            InitializeComponent();
            label4.Text = (string)id;
            textBox1.Text = (string)NomeObra;
            textBox2.Text = (string)idCliente;
            dateTimePicker1.Value = DateTime.ParseExact(DataPLevantamento, "d' de 'MMMM' de 'yyyy", System.Globalization.CultureInfo.CurrentCulture, System.Globalization.DateTimeStyles.None);
            // textBox3.Text = (string)DataPLevantamento;
            textBox4.Text = (string)DataRLevantamento;
            comboBox1.Text = (string)Estado;
            textBox5.Text = (string)DataRMateriais;
            textBox6.Text = (string)DataInicioObra;
            textBox7.Text = (string)DataConclusao;
            textBox8.Text = (string)DataVestoria;
            textBox12.Text = (string)Obs;
            textBox9.Text = (string)Prompor;
            textBox10.Text = (string)Levantpor;
            textBox11.Text = (string)executpor;
}

1 个答案:

答案 0 :(得分:1)

我担心你实际上无法使用targeting feature

我想到的第一件事是撰写custom grain

如果您只在一个地方需要这个并且值不经常更改,这可能是一种解决方法:

未经测试的示例

#!/usr/bin/env python
from psutil import virtual_memory

def categorize_memory():
    grains = {}
    mem = virtual_memory()
    total_mem = mem.total
    if total_mem < 1024 * 999:
        grains['memory_category'] = 'low_mem_minion'
    else:
        grains['memory_category'] = 'high_mem_minion'
    return grains

然后像salt -C 'G@memory_category:high_mem_minion' test.ping

那样使用它

从python中解析内存的代码取自Get total physical memory in Python