简单的任务,令人敬畏
total的Python项目详细描述
在我写最后一篇文章的时候,我写了一些语法(伪语法),不适用于一个不存在的命令……不过,我认为应该这样做。
语法是通过vmstat命令获取过去3秒的平均CPU空闲时间。
``sh
vmstat 13 total'$id:average'
```
这使我停止编写post,开始处理新命令,然后再处理这个post。
[![构建状态](https://travis-ci.org/daniellawrence/total.png?branch=master)(https://travis ci.org/daniellawrence/total)
total
----
这个命令被称为*total*并且非常受awk的启发。
total命令是awk的一种交换,使用简单的语法,可以解决常见问题。
example time
----
求出命令生成的一组数字的平均值:在本例中,它是*vmstat*
``sh
$vmstat 13
procs----------内存----------交换----io----系统----cpu--
r b swpd free buff cache si so bi bo in cs us sy id wa
0 6207264 85564 949404 0 0 294 107 178 2 1 98 0
0 0 6201800 85564 955036 0 0 0 403 396 0 0 100 0
0 0 6201552 85572 955244 0 0 0 80 591 677 2 1 98 0
`````
'100'和'98'
``sh
$vmstat 1 3 awk'开始{id_total=0;count=0}
{id_total+=15;count+=1}
结束{print id_total/count}
```
这不是一个数字。
15列被称为“id”。
这意味着你可以做以下事情,得到总id。
```sh
$vmstat 1 3 total'$id'
297
`````
>你可以将数据引用为列的名称(:total是默认值)
``sh
```sh
```vmstat1 3/total/total.py'$cache$cache:total$6$6:total'
>total'
8262988个8262988 8262988 8262988
````
然而,空闲CPU时间的总量并不是一个很好的标记。
真正需要的是平均ID…。
``sh
$vmstat 1 3 total'$id:avg'
>99
``` ` ` ` `
` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `电子邮件或警告。
``sh
$vmstat 1 3 total'平均空闲cpu为$id:avg,最大值为$id:max'
平均空闲cpu为97,最大值为98
``````
>或者像平均缓存减去平均缓存减去平均缓存这类疯狂的事情
``sh
``vmstat1 2 total'$cache:avg-$buff:avg'avg'avg'bc
1932560
1932560
1932560
1932560
>```
到获取可以在*$*(美元)符号中使用的所有*键*的列表,您只需使用--list
``sh
$vmstat 1 2 totat--list'
就可以使用以下cols for::total,:avg,:min,:max
bo,buff,cache,cs,free,id,in,r,si,so,swpd,sy,us,wa
```
不仅是vmstat……
```sh
netstat-i total--list''
您可以使用以下列:total、:avg、:min、:max
flg、iface、met、mtu、rx drp、rx err、rx ok、rx drp、tx err、tx ok、tx ovr
```
如何安装!
——
install from pip
``sh
$sudo pip install total
vg'
```
install from source
``sh
$git clone git://github.com/daniellawrence/total
$cd total
$sudo./setup.py install
\test
$vmstat 13 total'$id:avg'
```
语法是通过vmstat命令获取过去3秒的平均CPU空闲时间。
``sh
vmstat 13 total'$id:average'
```
这使我停止编写post,开始处理新命令,然后再处理这个post。
[![构建状态](https://travis-ci.org/daniellawrence/total.png?branch=master)(https://travis ci.org/daniellawrence/total)
total
----
这个命令被称为*total*并且非常受awk的启发。
total命令是awk的一种交换,使用简单的语法,可以解决常见问题。
example time
----
求出命令生成的一组数字的平均值:在本例中,它是*vmstat*
``sh
$vmstat 13
procs----------内存----------交换----io----系统----cpu--
r b swpd free buff cache si so bi bo in cs us sy id wa
0 6207264 85564 949404 0 0 294 107 178 2 1 98 0
0 0 6201800 85564 955036 0 0 0 403 396 0 0 100 0
0 0 6201552 85572 955244 0 0 0 80 591 677 2 1 98 0
`````
'100'和'98'
``sh
$vmstat 1 3 awk'开始{id_total=0;count=0}
{id_total+=15;count+=1}
结束{print id_total/count}
```
这不是一个数字。
15列被称为“id”。
这意味着你可以做以下事情,得到总id。
```sh
$vmstat 1 3 total'$id'
297
`````
>你可以将数据引用为列的名称(:total是默认值)
``sh
```sh
```vmstat1 3/total/total.py'$cache$cache:total$6$6:total'
>total'
8262988个8262988 8262988 8262988
````
然而,空闲CPU时间的总量并不是一个很好的标记。
真正需要的是平均ID…。
``sh
$vmstat 1 3 total'$id:avg'
>99
``` ` ` ` `
` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `电子邮件或警告。
``sh
$vmstat 1 3 total'平均空闲cpu为$id:avg,最大值为$id:max'
平均空闲cpu为97,最大值为98
``````
>或者像平均缓存减去平均缓存减去平均缓存这类疯狂的事情
``sh
``vmstat1 2 total'$cache:avg-$buff:avg'avg'avg'bc
1932560
1932560
1932560
1932560
>```
到获取可以在*$*(美元)符号中使用的所有*键*的列表,您只需使用--list
``sh
$vmstat 1 2 totat--list'
就可以使用以下cols for::total,:avg,:min,:max
bo,buff,cache,cs,free,id,in,r,si,so,swpd,sy,us,wa
```
不仅是vmstat……
```sh
netstat-i total--list''
您可以使用以下列:total、:avg、:min、:max
flg、iface、met、mtu、rx drp、rx err、rx ok、rx drp、tx err、tx ok、tx ovr
```
如何安装!
——
install from pip
``sh
$sudo pip install total
vg'
```
install from source
``sh
$git clone git://github.com/daniellawrence/total
$cd total
$sudo./setup.py install
\test
$vmstat 13 total'$id:avg'
```