Added support for "sum" function for thresholds

The existing code assumes the user wants an average value for their
thresholds.

This code adds a "-f" option (function) where the user can choose
between "average" and "sum".