fix misuse of snprintf, fix tags, use strtok_r

this was previously relying on undefined behavior- according to c99 spec, snprintf has undefined behavior when reading and writing to the same place. on ubuntu 12.04, this resulted in invalid datagrams being generated for any metric that this code attempted to convert to tags.

i haven't written c in 10 years and i was never any good at it, so i'm not claiming this is good, i'm just claiming it works.