Fix path to tcollector in init.d script.

Change-Id: Ia91e1f0b493b8df1b0177b7d27349a83636d9223
Allow specifying more than one TSD on the command line.

This adds a -L / --hosts-list flag that can be used to specify more than
one TSD, in which case tcollector will attempt to connect to any of them
and will keep cycling through the list until it manages to connect.

Patch with changes from Benoit Sigoure.
Signed-off-by: Benoit Sigoure <tsunanet@gmail.com>

Change-Id: Ic6887a2b459c63709e60fe8e47c92efd550ea6fc
Add a constant for the default port used by TSD.

Change-Id: I8c8a00bb481b789c98402b0e827cc04b5d24fcf2
Fix shutdown of collectors with children.

Make each collector subprocess a group leader.  Signal whole group.
This fixes #46.

Signed-off-by: Benoit Sigoure <tsunanet@gmail.com>
Put the name of the collector we're waiting on when shutting down.

Original idea of Jacek Masiulaniec.
Correctly handle empty object arrays.

This fixes #37.

Signed-off-by: Benoit Sigoure <tsunanet@gmail.com>
Oops, fix leftover from debugging.
Add UDP counters from /proc/net/snmp.

Refactor stats printing code so that it's more generic and can handle
multiple stats files.  New metrics:
  - net.stat.udp.datagrams
  - net.stat.udp.errors

Signed-off-by: Benoit Sigoure <tsunanet@gmail.com>
Handle --max-bytes being passed without --backup-count.

In this case we want to force --backup-count=1 so that
we can setup logging properly and rotate the log file.

This fixes #59.
grsec compatibility: drop privileges after opening /proc files.

Some /proc files are no longer visible once we drop privileges.
So try to open them first, and only drop privileges before entering
the main loop.
Drop privileges in dfstat: no need to stay root.
Drop privileges in procstats after opening /proc files.
Drop privileges in ifstats after opening /proc file.

Will have to find a way to remove all this code duplication later.
Drop privileges in iostats after opening /proc file.

More code duplication :(
Add collector for stats published by OpenTSDB over HTTP.

Signed-off-by: Benoit Sigoure <tsunanet@gmail.com>
opentsdb.sh: exit 13 if there is no TSD to connect to.
Add an NFS stats collector.

Signed-off-by: Benoit Sigoure <tsunanet@gmail.com>
Add a MongoDB collector.

Signed-off-by: Benoit Sigoure <tsunanet@gmail.com>
Properly shutdown when ALIVE is set to False.

If number of exceptions counted by the sender thread exceeds
MAX_UNCAUGHT_EXCEPTIONS, the main thread can respawn children
and continue running forever.

Signed-off-by: Benoit Sigoure <tsunanet@gmail.com>
Make sure we don't leave any collector behind upon exiting.