#!/bin/bash

time_val=`curl -w "\n%{time_total}\n" -o /dev/null --location --request GET  "http://api.cbill.kvdc.net/api/SyncData/GetSyncData?lastSyncDate=&offset=0&count=10&versionCode=31&lastCustId=&lastRcptId=&lastBillId=&lastpaymenthistoryId=" -H "$(cat /usr/lib64/nagios/plugins/time_headers.txt)"`

if [ "$(echo $time_val | cut -d. -f1)" -gt "6" ]; then
	echo "Time to retrieve data is" $time_val | mail -s "KCCL time taken" divya@cliffsupport.com rooshi@cliffsupport.com saravana@cliffsupport.com veena@syntrio.in nishita@syntrio.in
	echo "Time taken to retrieve data is" $time_val;
	exit 2;
else
	echo "Time taken to retrieve data is normal";
	exit 0;
fi
