Solved Zabbix script adaptation

fred974

Daemon

Reaction score: 37
Messages: 1,598

Hi,

I am trying to monitor a couple of instances that I have running on Amazon AWS and to do that, I am trying to use the Zabbix-Cloudwatch.
The script was obviously not written for FreeBSD so I have adapted a bit of the code. The bit I am stuck in is below:
/usr/local/etc/zabbix34/cloudwatch/cron.d/cron.RDS.sh
Code:
#!/usr/local/bin/bash

# Date:   08/08/2015
# Author: Long Chen
# Description: A script to bulk send RDS cloudwatch data to zabbix server

PATH=$PATH:/usr/local/etc/zabbix34/cloudwatch
export PATH

# DB instance indentifier
DB_INSTANCE=$1
# Zabbix Host
ZABBIX_HOST=$2
# Zabbix Server
ZABBIX_SERVER=$3
# AWS Account
ACCOUNT=$4
# AWS Region
REGION=$5
# Collecting 5-minute data from cloudwatch
PERIOD="300"
# Set start time and end time for collecting cloudwatch data
# Adding lag, as CloudWatch doesn't send all data if requested too early.
ENDTIME=$(date -u "+%F %H:%M:00" -d "5 minutes ago")
STARTTIME=$(date -u "+%F %H:%M:00" -d "10 minutes ago")

# Send cloudwatch data of a table to Zabbix Server
zabbixCloudWatch.py -z "$ZABBIX_SERVER" -x "$ZABBIX_HOST" -a "$ACCOUNT" -r "$REGION" -s "RDS" -d "DBInstanceIdentifier=$DB_INSTANCE" -p "$PERIOD" -f "$STARTTIME" -t "$ENDTIME"

./cron.RDS.sh

Code:
date: illegal time format
usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
            [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format]
date: illegal time format
usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
            [-f fmt date | [[[[[cc]yy]mm]dd]HH]MM[.ss]] [+format]
env: python: No such file or directory
Could anyone please help me sorting the date issue?

Also, I will welcome any alternative script people or willing to share :)
 

leebrown66

Well-Known Member

Reaction score: 137
Messages: 411

date: illegal time format
Try:
Code:
date -u +"%F %H:%M:00" -d "5 minutes ago"
instead of
Code:
date -u "+%F %H:%M:00" -d "5 minutes ago"
env: python: No such file or directory
1. Is python installed?
2. Is zabbixCloudWatch.py shebanged correctly for python?

I avoid python so I'm useless at providing further insight to this last one.
 
OP
OP
fred974

fred974

Daemon

Reaction score: 37
Messages: 1,598

Hi,

Thank you for your help.
I tried your suggestion but I am still getting the same error message.
 

leebrown66

Well-Known Member

Reaction score: 137
Messages: 411

My bad, got myself mixed up ( linux != FreeBSD )

Code:
date -u -v-5M +"%F %H:%M:00"
That's UTC, 5 minutes ago, for FreeBSD platform. It produces the same output the the linux version you gave.
 
Top