RESTful back end for querying arbitraty system "facts".
- Minimal set of requirements
- Python 2.4+ compatible
- Access and application logging
- host and environment REST endpoints
- Unit tested
- Python 2.4+
- python-simplejson if Python 2.4 or 2.5
- PyYAML if using the facter plugin
Via distutils:
sudo python ./setup.py install
Via rpm (requires development packages):
make rpm
sudo yum localinstall ./rpm-build/noarch/*.rpm
Now we'll start jsonstatsd in a terminal. It won't detach from the
controlling shell. This means we'll have to ctrl+c the process when
we're done.
/usr/bin/jsonstatsd
Loading plugin... <class 'JsonStats.FetchStats.Fetcher'>
Loading plugin... <class 'JsonStats.FetchStats.Plugins.RPM.RPM'>
Loading plugin... <class 'JsonStats.FetchStats.Plugins.Facter.Facter'>
Loading plugin... <class 'JsonStats.FetchStats.Plugins.DEB.DEB'>
Messages like ERROR: Failed to load plugin 'foo' aren't critical. They just mean a required command wasn't found on our system.
In another terminal you can run a curl command like this to test
that the server is running*****:
curl localhost:8008 | python -m json.tool
- The
python -m json.toolpart is optional and is just there to reformat the output
jsonstatsd can be configured at runtime with several other options:
$ jsonstatsd --help
Usage: jsonstatsd [options]
Options:
-h, --help show this help message and exit
-p PORT, --port=PORT Port to listen on. (Default: 8008)
-l LISTEN, --listen=LISTEN
Address to listen on. (Default: 0.0.0.0)
--logdir=LOGDIR Directory to log access requests to. (Default:
./logs/)
To enable jsonstatsd as a system service on hosts still using the
service and chkconfig commands:
sudo chkconfig jsonstatsd on
sudo service jsonstatsd start
To enable jsonstatsd as a system service on systemd managed hosts:
$ sudo systemctl enable jsonstatsd.service
ln -s '/usr/lib/systemd/system/jsonstatsd.service' '/etc/systemd/system/multi-user.target.wants/jsonstatsd.service'
If you are running jsonstatsd as a system service (ex: via
systemctl or service commands) then you may want to examine the
service configuration file in /etc/sysconfig/jsonstatsd
######################################################################
# Listen on all interfaces by default. You might also enjoy: 127.0.0.1
# to just listen locally
INTERFACE=0.0.0.0
######################################################################
# Port to listen on
PORT=8008
######################################################################
# Customize the logging directory
LOGDIR=/var/log/jsonstatsd
######################################################################
# Single line with all options for the SysV init script
OPTIONS="--listen $INTERFACE --port $PORT --logdir $LOGDIR"
There are two log file which are produced by a running instance.
- jsonstatsd_access.log: Access log similar to apache's access log.
- jsonstatsd.log: Application level logging which logs some logic results.
Run make tests to execute the test suite.
-
New fact plugins MUST subclass the
Fetcherparent class. Example:from JsonStats.FetchStats import Fetcher class MegaFrobber(Fetcher): -
Read the source for the
Fetcherbase class inJsonStats/FetchStats/__init__.pyto see the remaining methods you must implement in your plugin. -
Until we come up with a better way of dynamically loading all plugins, new fact plugin module names MUST be added to the
__all__list inJsonStats/FetchStats/Plugins/__init__.py
