This will undercount some visitors and overcount others, but it should be good enough for most purposes.
Seems reasonable for most cases, but if you're a website that's used a lot by schools or businesses, they might have every computer using the same user agent and IP.