1.

[root@kylin1 grains]# cd /srv/salt/_grains/

[root@kylin1 _grains]# ls

cpu.py

[root@kylin1 _grains]# cat /srv/salt/_grains/cpu.py

#!/usr/bin/python

#coding:utf-8

import os

def cpu():

grains = {}

command = "top -b -n 1 | grep Cpu | awk -F'[:,]' '{print $5}'"

with os.popen(command) as file:

grains["cpu_id"] = file.read()

return grains

2.

3.

saltstack_grains的更多相关文章

  1. 3.saltstack的grains和pillar学习笔记

    作者:刘耀 QQ:22102107 SaltStack_Grains Grains grains是minion第一次启动的时候采集的静态数据,可以用在salt的模块和其他组件中.其实grains在每次 ...

随机推荐

  1. 为什么使用 Bootstrap

    移动设备优先:自 Bootstrap 3 起,框架包含了贯穿于整个库的移动设备优先的样式 浏览器支持:所有的主流浏览器都支持 Bootstrap 容易上手:只要您具备 HTML 和 CSS 的基础知识 ...

  2. spark在yarn-cluster模式,错误查找方法

    yarn logs -applicationId application_xxxx_xxx 可选(">exception")

  3. LNK4098: 默认库“MSVCRT”与其他库的使用冲突

    LNK4098: 默认库"MSVCRT"与其他库的使用冲突 修改的方法:在项目属性中,在连接器-输入选项中,在忽略特定库中添加相应的库,具体添加那些苦请参照下面的表格. 下面的内容 ...

  4. Problem D

    Problem Description An entropy encoder is a data encoding method that achieves lossless data compres ...

  5. Problem I

    Problem Description Queues and Priority Queues are data structures which are known to most computer ...

  6. Hibernate的基础入门(一)

    一Java三层结构 1 web层:struts框架 2 service层:Spring框架 3  dao层 :hibernate框架 相当于MVC的思想 1 M:模型èhibernate框架 2 V: ...

  7. Android 开发笔记___滚动视图__scroll view

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

  8. Matrix 矩阵

    CSS3中的矩阵指的是一个方法,书写为matrix()和matrix3d(),前者是元素2D平面的移动变换(transform),后者则是3D变换.2D变换矩阵为3*3, 如上面矩阵示意图:3D变换则 ...

  9. Anaconda快捷搭建Python2和Python3环境

    我们在使用Pycharm编辑Python程序经常会因为不熟悉Python2和Python3的一些代码区别而导致错误,我们知道他们之间很多代码是必须运行在对应版本中的,否则是会报错的.因此,本文介绍一个 ...

  10. StackExchange.Redis学习笔记(三)

    这一章主要写一些StackExchange.Redis的配置及不太经常用到的函数 数据库连接 下面是我的连接字符串,里面指定了地址,密码,及默认的数据库 Redis启动后默认会分成0-15个数据库,不 ...