Failure precursors in rocks and concrete