The script will gather the topology JSON data for each topology
Gather all the boltId and capacity values
Then check if each capacity is over the limit, which in this case is 0.75
Any and all that fall into this criteria will trigger an email.



# the max capacity you want to allow
CAPACITY_LIMIT='0.75'

# the email address you would like to inform of the issue.
TRIGGER_EMAIL="[email protected]"

# get all the topology id's
TOPOLOGY_IDS=`curl -s
http://ADDYOURHOSTNAMEHERE:8080/api/v1/topology/summary | json_pp | grep
'"id"' | sed 's/.* : "\(.*\)".*/\1/'`

for id in ${TOPOLOGY_IDS} ; do
TOPOLOGY=`curl -s
http://ADDYOURHOSTNAMEHERE:8080/api/v1/topology/${id}?sys=false`

# collet all the capacities in the topology
CAPACITIES=`echo ${TOPOLOGY} | json_pp | grep '"capacity"' | sed 's/.* :
"\(.*\)".*/\1/'`
CAPACITIES_ARRAY=()
for capactiy in ${CAPACITIES} ; do
CAPACITIES_ARRAY+=("${capactiy}")
done

# collect all of the bolt ids in the topology
BOLT_IDS=`echo ${TOPOLOGY} | json_pp | grep '"boltId"' | sed 's/.* :
"\(.*\)".*/\1/'`
BOLT_IDS_ARRAY=()
for boltId in ${BOLT_IDS} ; do
BOLT_IDS_ARRAY+=("${boltId}")
done

# check and collect bad capacites
BAD_CAPACITIES_ARRAY=()
BAD_BOLT_ID_ARRAY=()
for(( x=0; x<${#BOLT_IDS_ARRAY[@]}; x++ ));  do
result=`echo ${CAPACITIES_ARRAY[$x]} '>' ${CAPACITY_LIMIT} | bc -l`
if [ "${result}" -eq "1" ] ; then
BAD_CAPACITIES_ARRAY+=("${CAPACITIES_ARRAY[$x]}")
BAD_BOLT_ID_ARRAY+=("${BOLT_IDS_ARRAY[$x]}")
fi
    done

    # send a trigger if needed
    # capacity and bolt id arrays will always be the same size
for(( x=0; x<${#BAD_CAPACITIES_ARRAY[@]}; x++ ));  do
mail -s "${id} is nearing capacity!" "${TRIGGER_EMAIL}" <<EOF
"${BAD_BOLT_ID_ARRAY[${x}]}" has a capacity of
"${BAD_CAPACITIES_ARRAY[$x]}".
This is an early warning limit suggesting that you look into allocating
more resources to the given topology.
This email is set to trigger when a bolt capacity is more than
"${CAPACITY_LIMIT}".
EOF
done

done




On Mon, May 30, 2016 at 2:53 PM, anshu shukla <[email protected]>
wrote:

> hello ,
>
> Can you please share the bash script that you are talking about . I am
> also interested in trying that .
>
> Thanks,
> Anshu  Shukla
> IISC,Bangalore
>
>
> On Mon, May 30, 2016 at 6:17 PM, Matthew Lowe <[email protected]>
> wrote:
>
>> Hello all.
>>
>> What kind of monitoring solutions do you use with storm?
>>
>> For example I have a bash script that reads the Json data from the REST
>> UI and alerts if there are any bolts with high capacities.
>>
>> It's only small and hacky, but I am genuinely interested to how you all
>> monitor your topologies.
>>
>> Best Regards
>> Matthew Lowe
>
>
>
>
> --
> Thanks & Regards,
> Anshu Shukla
>

Reply via email to