b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

sender命令的使用

电脑杂谈  发布时间:2020-03-14 20:01:06  来源:网络整理

使用zabbix_zabbix和nagios哪个好_zabbix如何使用

Zabbix_get命令:

zabbix_get是zabbix中的一个程序,用于zabbix-server到zabbix-agent获取数据。通常拿来检验agent的配置是否正确。

[[emailprotected]~]#zabbix_get-h

Zabbixgetv2.2.11(revision56693)(12November2015)

usage:zabbix_get[-hV]-s<hostnameorIP>[-p<port>][-I<IPaddress>]-k<key>

-s--host<hostnameorIP>SpecifyhostnameorIPaddressofahost

-p--port<portnumber>Specifyportnumberofagentrunningonthehost.Defaultis10050

-I--source-address<IPaddress>SpecifysourceIPaddress

-k--key<keyofmetric>Specifykeyofitemtoretrievevaluefor

-h--helpGivethishelp

-V--versionDisplayversionnumber

Example:zabbix_get-s127.0.0.1-p10050-k"system.cpu.load[all,avg1]"

参数说明:

-s --host: 指定客户端主机名或者IP

-p --port:客户端端口,默认10050

-I --source-address:指定源IP,写上zabbix server的ip地址即可,一般留空,服务器如果有多ip的之后,你指定一个。

-k --key:你想获得的key

至于使用长参数还是短的,自己选,我一直使用-s而不是--host,太长了。

获取CPU负载

[[emailprotected]~]#zabbix_get-s127.0.0.1-p10050-k"system.cpu.load[all,avg15]"

key可以加引号,也可以不加。

zabbix如何使用_使用zabbix_zabbix和nagios哪个好

获取主机名

[[emailprotected]~]#zabbix_get-s127.0.0.1-p10050-ksystem.hostname

localhost.localdomain

Zabbix_sender命令:

zabbix_sender是什么?有什么作用?

zabbix获取key值有超时时间,如果自定义的key脚本通常必须执行更长时间,这根本无法去做监控,那如何办呢?使用zabbix监控类型zabbix trapper,需要配合zabbix_sender给它传递数据。关于trapper的用法,我们来弄个例子。

执行超长时间脚本,如:脚本去几十台服务器拉去数据,每个日志都上G,然后日志整合在一起,统计出返回值。这种脚本除了超时,所以我们需要改成使客户端提交数据的方法。

zabbix_sender命令用法:

[[emailprotected]~]#zabbix_sender-h

ZabbixSenderv2.2.11(revision56693)(12November2015)

usage:zabbix_sender[-Vhv]{[-zpsI]-ko|[-zpI]-T-i<file>-r}[-c<file>]

-c--config<file>Absolutepathtotheconfigurationfile

-z--zabbix-server<server>HostnameorIPaddressofZabbixserver

-p--port<serverport>Specifyportnumberofservertrapperrunningontheserver.Defaultis10051

-s--host<hostname>Specifyhostname.HostIPaddressandDNSnamewillnotwork

-I--source-address<IPaddress>SpecifysourceIPaddress

-k--key<key>

Specifyitemkey

-o--value<keyvalue>Specifyvalue

-i--input-file<inputfile>Loadvaluesfrominputfile.Specify-forstandardinput

Eachlineoffilecontainswhitespacedelimited:<hostname><key><value>

zabbix和nagios哪个好_使用zabbix_zabbix如何使用

Specify-in<hostname>tousehostnamefromconfigurationfileor--hostargument

-T--with-timestampsEachlineoffilecontainswhitespacedelimited:<hostname><key><timestamp><value>

Thiscanbeusedwith--input-fileoption

TimestampshouldbespecifiedinUnixtimestampformat

-r--real-timeSendmetricsonebyoneassoonastheyarereceived

Thiscanbeusedwhenreadingfromstandardinput

Otheroptions:

-h--helpGivethishelp

-V--versionDisplayversionnumber

使用参数:

-c--config<file>配置文件绝对路径

-z--zabbix-server<server>zabbixserver的IP地址

-p--port<serverport>zabbixserver端口.默认10051

-s--host<hostname>主机名,zabbix里面配置的主机名(不是服务器的hostname),不能使用ip地址

-I--source-address<IPaddress>源IP

-k--key<key>监控项的key

-o--value<keyvalue>key值

-i--input-file<inputfile>从文件上面写入hostname、key、value一行为一条数据,使用括号作为分隔符,如果主机名带括号,那么请使用双引号包起来

-T--with-timestamps一行一条数据,空格作为分隔符:<hostname><key><timestamp><value>,配合--input-fileoption,timestamp为unix时间戳

-r--real-time将数据即时提交给服务器

-v--verbose详细模式,-vv更详细

使用zabbix_zabbix和nagios哪个好_zabbix如何使用

Zabbix_sender使用示例:

先在主机zabbix server 上创建一个key。

wKiom1ddbjGJY1AAL7PrjIOmo830.png

传递一个数据至item中,注意-s后面为zabbix_agent.conf文件中配置的hostname,不是IP地址,也不是服务器的主机名。

[[emailprotected]alertscripts]#zabbix_sender-s"ZabbixServer"-z127.0.0.1-k"key.test.trapper"-o1-r

infofromserver:"processed:1;failed:0;total:1;secondsspent:0.000034"

sent:1;skipped:0;total:1

failed为0zabbix如何使用,表示传送失败的为0个。

zabbix_sender还可以批量上传数据,即将服务器的hostname(zabbix_agent.conf文件中配置的主机名)、key、value三个值保存至文件中,然后将该文件中的数据上传至各个item中。

zabbix_sender批量传递key值

"Zabbixserver"ttlsa.trapper10

"Zabbixserver"ttlsa.trapper20

"Zabbixserver"ttlsa.trapper30

"Zabbixserver"ttlsa.trapper40

"Zabbixserver"ttlsa.trapper1

#./zabbix_sender-z127.0.0.1-if.txt

infofromserver:"processed:5;failed:0;total:5;secondsspent:0.000085"

sent:5;skipped:0;total:5

每行对应一个key值,一般是相似的主机名、不同的key、不同的key值。这边方便测试,所以都用了同一个key

这种方法也有zabbix trapper监控模式的模型。

Zabbix Trapper监控案例演示:

zabbix如何使用_使用zabbix_zabbix和nagios哪个好

创建两个监控项,monitor[TotalMemory]和monitor[FreeMemory],分别用来监控总存储和剩余内存。

监控脚本如下:

#!/bin/bash

zabbix_server_ip=172.16.206.130

TotalMemory()

TotalMemory=`cat/proc/meminfo|awk'/^MemTotal:/{print$2}'`

echo"$hostnamemonitor[TotalMemory]$TotalMemory"

FreeMemory()

FreeMemory=`cat/proc/meminfo|awk'/^MemFree:/{print$2}'`

echo"$hostnamemonitor[FreeMemory]$FreeMemory"

TotalMemory>>/tmp/test.txt

FreeMemory>>/tmp/test.txt

zabbix_sender-z$zabbix_server_ip-i/tmp/test.txt&>/dev/null

注意:脚本最后一行是当数据上传完成后删除保存数据的文件,这样以后执行脚本时确保不会有相似的key对应多个value。

zabbix web上创建对应的item

wKiom1ddFJqRkypVAAI1aay1KHM304.png

注意:上面我们创建了itemzabbix如何使用,也构建了获得item值的脚本。但是这个脚本不会自动执行,将数据传送至zabbix server上。所以我们还必须再建立一个监控项,这个监控项会定时执行我们构建的脚本。

创建自定义监控的conf文件

[[emailprotected]zabbix_agentd.d]#vimuserparameter_memory.conf

UserParameter=send.date[*],/etc/zabbix/scripts/memory.monitor.sh$1

zabbix server上创建监控项:


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/ruanjian/article-144160-1.html

    相关阅读
      发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

      • 陈燕平
        陈燕平

        肯定质量杠杠的

        • 薛幸峰
          薛幸峰

          那些炮弹难道真是在电视上让那些鼓吹的军事家的咸蛋与茶叶蛋吗

      • 张尧
        张尧

        相当装逼

      热点图片
      拼命载入中...