Hi -
As far back as a year ago [1], we talked about building a
web-accessible PMAPI. I started prototyping something along the lines
we talked about, and am now getting back to it more seriously.
The code is being developed in the pcpfans.git repo I mentioned the
other day, in the fche/pmwebapi branch. To build it, you first need
to install libmicrohttpd [2], a LGPL2'd library for web service. (I
could not find a better alternative, in the sense of license
compatibility, availability on major distros, portability.) Then:
% git clone git://sourceware.org/git/pcpfans.git # or git remote add ...
% git checkout fche/pmwebapi
% ls src/pmwebapi
% configure; make all install
% # update LD_LIBRARY_PATH for new libpcp.so if needed
% ./src/pmwebapi/pmwebapi -v
And sic a web browser at
http://localhost:44323/pmapi/context?hostname=localhost
(A few other connection-initiation formats are also available.)
It should result in a JSON response of the form:
{ "context": 916793616 }
This context number will then be used as a cookie-of-sorts in
subsequent http queries to refer to a particular PMAPI pmContext
maintained for that client by pmwebapi. pmwebapi automagically times
out these contexts if they're not used for some amount of time. That
is basically all the tool does right now: actual PMAPI calls other
than context setup/teardown are missing. That's because I focused on
this part as the key that bridges the concepts from connectionless
HTTP to long-lasting PMAPI. I hope to add code soon to do basic
metric enumeration & fetching, along the RESTful lines we discussed in
[1].
pmwebapi lacks authentication, until we get that into the core pcp
widget separately. pmwebapi (via libmicrohttpd) can include SSL/TLS
via gnutls (not the certifiable Mozilla NSS, sigh). Alternatively,
one might deploy pmwebapi behind a standard http server that
authenticates/secures and proxies connections.
The prototype pmwebapi has another little feature I imagine would be
useful to serve tiny pcp webapps: an optional very basic fileserver
associated with the "-r resdir" option. The idea is to make it
possible to serve pmapi webapps, without having to set up a full web
server.
Please let me know any concerns or suggestions.
[1] http://oss.sgi.com/pipermail/pcp/2011-March/001661.html
[2] http://www.gnu.org/software/libmicrohttpd/
|