—This paper addresses optimal spectrum sensing in cognitive radio networks considering its system level cost that accounts for the local processing cost of sensing (sample collection and energy calculation at each secondary user) as well as the transmission cost (forwarding energy statistic from secondary users to fusion center). The optimization problem solves for the appropriate number of samples to be collected and amplifier gains at each secondary user to minimize the global error probability subject to a total cost constraint. In particular, closed-form expressions for optimal solutions are derived and a generalized water-filling algorithm is proposed when number of samples or amplifier gains are fixed and additional constraints are imposed. Furthermore, when jointly designing the number of samples and amplifier gains, optimal solution indicates that only one secondary user needs to be active, i.e., collecting samples for local energy calculation and transmitting energy sta...