Fix for procnettcp.py if IPv6 is disabled

If /proc/net/tcp6 doesn't exist, we die with:
procnettcp.py:     procfile.seek(0)
AttributeError: 'NoneType' object has no attribute 'seek'

Change-Id: I9127be78df8cf497cc8cbc25a857d5552bc03012
Reviewed-on: https://review.stumble.net/1952
Tested-by: Benoit Sigoure <tsuna@stumbleupon.com>
Reviewed-by: Benoit Sigoure <tsuna@stumbleupon.com>
Don't format strings unnecessarily in the fast-path.

Change-Id: I18297b7fef310239368cc656e304c9b5b38dea1e
tcollector: collect avail entropy with procstat.py

Change-Id: Id3213f24aa2d4c3ab2bd2e0c187d7916f84dee59
Reviewed-on: https://review.stumble.net/1696
Reviewed-by: Benoit Sigoure <tsuna@stumbleupon.com>
Tested-by: Berk D. Demir <bdd@stumbleupon.com>
Reviewed-by: Berk D. Demir <bdd@stumbleupon.com>
procstats: Add basic NUMA stats.

This adds 4 new metrics to keep track of the high-level stats on how
memory is allocated in NUMA systems:
  - sys.numa.zoneallocs: Number of pages allocated from the preferred
    node (type=hit) or not (type=miss).
  - sys.numa.foreign_allocs: Number of pages this node allocated
    because the preferred node didn't have a free page to accommodate
    the request.
  - sys.numa.allocation: Number of pages allocated locally (type=local)
    or remotely (type=remote) for processes executing on this node.
  - sys.numa.interleave: Number of pages allocated successfully by the
    interleave strategy.

Change-Id: I4174d7b929df8e1133ca7c4f95303c49ba38988c
Fix restart in case pidfile is stale

If the pidfile is stale, tcollector won't get restarted
if the pid got reused.

Don't do simplistic checks of the pid running but just
always use the pgrep check.

Removes blindly using the pidfile in stop() too.

Should just get rid of using the pidfile, but currently
it's required as part of tcollector.py.  The remaining
use case is the forcerestart logic, but we could get
the same functionality from looking at start time from
/proc/PID

Change-Id: I24b3fa0eb10332cac51e4d28a06ae030147b2c28
Reviewed-on: https://review.stumble.net/2236
Reviewed-by: Benoit Sigoure <tsuna@stumbleupon.com>
Tested-by: Benoit Sigoure <tsuna@stumbleupon.com>
Simplify a call to pgrep.

Change-Id: I949bf012e9864c0ded44d7fa06e8f4e22d6c892e
Reviewed-on: https://review.stumble.net/2242
Reviewed-by: Dave Barr <barr@stumbleupon.com>
Tested-by: Benoit Sigoure <tsuna@stumbleupon.com>
Evict old keys from the de-dup cache.

For every combination of (metric, tags), collectors remember what was
the last value they saw so that they can remove duplicate values (or,
in the future, perform RLE encoding).  If there are loads of different
combinations of (metric, tags) changing over time, this can lead to
excessive memory consumption because old values are never evicted from
this "de-dup cache".

This change adds a flag, --evict-interval (set to 6000 seconds = 1h40m
by default), to put an upper bound on how long a collector will remember
the last value seen for a specific combination of (metric, tags).

This change is based on a contribution of Kai Ren <kair at cs.cmu.edu>.

Change-Id: I5b5b0b64e05b2f1f81b213e14117e029bfd25ba7
Allow `/' in metric names, tag keys and values.

Change-Id: Icc995a58c3e1275fb8985c67936c607f2c13247c
Signed-off-by: Benoit Sigoure <tsunanet@gmail.com>
Use '/' in tag values for mount points.

Implements OpenTSDB feature request #14.

Change-Id: I566e45f7af3f38364c313b71d65447b74012e1bc
Signed-off-by: Benoit Sigoure <tsunanet@gmail.com>
Fix issue #2 using ALIVE flag for graceful termination of threads.

Change-Id: I12e589820daa6809b122322c87534c2f1d7d5212
Signed-off-by: Benoit Sigoure <tsunanet@gmail.com>
Add the ability to pass additional tags with `startstop'.

It may be necessary to pass additional tags when running tcollector.
In our case we are monitoring host level OpenStack systems, and
want to roll up into availability zones and hypervisor type.

./startstop start -t az=paloalto0 hv=kvm

Change-Id: Id48e4442dd984cd670d4677bbd5f393368501621
Signed-off-by: Benoit Sigoure <tsunanet@gmail.com>
Add a collector for MySQL.

The collector includes about 300 metrics about MySQL (when InnoDB
is used).  Most metrics are collected through `SHOW GLOBAL STATUS'.

The collector has a configuration file, `mysqlconf.py', in which
the user / password to use to connect to MySQL must be specified.

The collector has limited support for MySQL 5.0, because in that
version of MySQL running the command `SHOW GLOBAL STATUS' has a
big impact on the performance of the database.  Hopefully almost
everyone uses at least MySQL 5.1 these days.

Change-Id: If6042427f1701da3f5954c166a087c7996a86a1f
Add a basic collector for ElasticSearch.

The collector comes with 38 metrics about ElasticSearch server instances
as well as 8 additional cluster-wide metrics collected from the master
node.  Most metrics are system-level metrics, because right now ES
doesn't have many serving statistics.  We don't collect per-index
metrics at this time, because many indices are named dynamically and
we would need a way of canonicalizing index names.

Change-Id: I7619b29fc7cb83450e478c3601760762dbd83ba5
Tested-by: Benoit Sigoure <tsuna@stumbleupon.com>
Reviewed-by: Tony Landells <tony@stumbleupon.com>
Make sure there are no spaces in the `state' tag.

Change-Id: I35a38605ccb5b5ac708a85f421d4c6a87a1d10f3
Handle the output of "SHOW PROCESSLIST" from MySQL 5.5.

New columns have been added in 5.5, just ignore them.

Change-Id: Ia71339f7fd7b212c771736dee00e4dd676107889
Fix the metric name used for InnoDB mutex locks.

The metric name ought to be `mysql.innodb.locks'.

Change-Id: I7297ab0822fc945d60fde5b8be849155b74557cd
Detect when the InnoDB engine is used.

Change-Id: Id43513cef6af2d4a6e3b53ba6c48dc6894bd44fe
Refresh the timestamp more frequently.

This is in case a command takes a significant amount of time.

Change-Id: I4758b220d7883f5815e0618dbcf474ba8c299c9b
Collect more internal metrics from InnoDB.

Run `SHOW ENGINE INNODB STATUS' and parse the output to extract some
of the metrics.  Some InnoDB metrics are exposed in SHOW GLOBAL STATUS,
but many are not.

This adds 14 new metrics for InnoDB.  We can add more in the future.

Change-Id: Ib1458bfa939f2314bcb5c9c88fd2e4ac0fb10b5c
Reviewed-by: Tony Landells <tony@stumbleupon.com>
Tested-by: Benoit Sigoure <tsuna@stumbleupon.com>
Reviewed-by: Benoit Sigoure <tsuna@stumbleupon.com>
IPv6 support: Use `getaddrinfo' to resolve the TSD's host.

This way it works with IPv6 hosts and can work with DNS entries that
have multiple A or AAAA records.

Change-Id: I7f64ad730d98d732f8bef2f75576499e917a02bd
Signed-off-by: Benoit Sigoure <tsunanet@gmail.com>