- 论坛徽章:
- 5
|
下面这个将zabbix与cloudwatch集成的插件中
https://github.com/omni-lchen/zabbix-cloudwatch
有一个python脚本,如下所示:
[root@redhat cloudwatch]# python zabbixCloudWatch.py --help
Usage: zabbixCloudWatch.py [options]
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-z ZABBIX, --zabbix=ZABBIX
zabbix server name
-x HOST, --host=HOST zabbix host name
-a ACCOUNT, --account=ACCOUNT
account name
-r REGION, --region=REGION
aws region
-s SERVICE, --service=SERVICE
aws service (ELB, SQS, DynamoDB, etc...)
-d DIMENSIONS, --dimensions=DIMENSIONS
Dimensions split with comma (LoadBalancerName=,
etc...)
-p PERIOD, --period=PERIOD
Period
-f STARTTIME, --starttime=STARTTIME
Start Time
-t ENDTIME, --endtime=ENDTIME
End Time
当我运行这个脚本带这些参数时,会将AWS上EC2的cloudwatch的监控信息传到zabbix-server,如下所示:
[root@redhat cloudwatch]# /usr/bin/python zabbixCloudWatch.py -x "54.213.216.110" -z "superman-zabbix.superman-webplatform.com" -a "CloudWatch-test" -r "cn-north-1" -s "EC2" -d "InstanceId=i-0d3138e5be40eef22" -p "300" -f "2017-12-22 02:50:00" -t "2017-12-22 02:55:00"
在shell中可以使用这两个变量表示,当前时间和5分钟前的时间
ENDTIME=$(date -u "+%F %H:%M:00")
STARTTIME=$(date -u "+%F %H:%M:00" -d "5 minutes ago")
如果我想在shell中使用一个变量来表示当前时间和5分钟之前的时间 ,即将starttime和endtime用变量表示:
[root@redhat cloudwatch]# /usr/bin/python zabbixCloudWatch.py -x "54.213.216.110" -z "superman-zabbix.superman-webplatform.com" -a "CloudWatch-test" -r "cn-north-1" -s "EC2" -d "InstanceId=i-0d3138e5be40eef22" -p "300" -f "$(date -u "+%F %H:%M:00" -d "5 minutes ago")" -t "$(date -u "+%F %H:%M:00")"
那么在python中如果后面跟参数的话,ENDTIME和starttime应该用什么变量或者表达式来表示:
|
|