2019-03-08 21:31:08 +01:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
|
|
|
|
|
|
|
using namespace ircd;
|
|
|
|
|
|
|
|
mapi::header
|
|
|
|
IRCD_MODULE
|
|
|
|
{
|
|
|
|
"Prometheus Metrics"
|
|
|
|
};
|
|
|
|
|
|
|
|
resource
|
2019-08-03 23:58:52 +02:00
|
|
|
stats_resource
|
2019-03-08 21:31:08 +01:00
|
|
|
{
|
2019-08-03 23:58:52 +02:00
|
|
|
"/stats",
|
2019-03-08 21:31:08 +01:00
|
|
|
{
|
|
|
|
"Prometheus Metrics"
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static resource::response
|
2019-08-03 23:58:52 +02:00
|
|
|
get__stats(client &,
|
|
|
|
const resource::request &);
|
2019-03-08 21:31:08 +01:00
|
|
|
|
|
|
|
resource::method
|
2019-08-03 23:58:52 +02:00
|
|
|
stats_get
|
2019-03-08 21:31:08 +01:00
|
|
|
{
|
2019-08-03 23:58:52 +02:00
|
|
|
stats_resource, "GET", get__stats
|
2019-03-08 21:31:08 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
resource::response
|
2019-08-03 23:58:52 +02:00
|
|
|
get__stats(client &client,
|
|
|
|
const resource::request &request)
|
2019-03-08 21:31:08 +01:00
|
|
|
{
|
|
|
|
static const size_t buf_max
|
|
|
|
{
|
|
|
|
4096
|
|
|
|
};
|
|
|
|
|
|
|
|
char buf[buf_max];
|
|
|
|
std::stringstream out;
|
|
|
|
pubsetbuf(out, buf);
|
|
|
|
|
|
|
|
const time_t ts
|
|
|
|
{
|
|
|
|
ircd::time<milliseconds>()
|
|
|
|
};
|
|
|
|
|
|
|
|
out << "aio_requests_total"
|
|
|
|
<< ' ' << fs::aio::stats.requests
|
|
|
|
<< ' ' << ts
|
|
|
|
<< '\n';
|
|
|
|
|
|
|
|
out << "aio_requests_bytes_total"
|
|
|
|
<< ' ' << fs::aio::stats.bytes_requests
|
|
|
|
<< ' ' << ts
|
|
|
|
<< '\n';
|
|
|
|
|
|
|
|
const string_view output
|
|
|
|
{
|
|
|
|
view(out, buf)
|
|
|
|
};
|
|
|
|
|
|
|
|
return resource::response
|
|
|
|
{
|
|
|
|
client, output, "text/plain", http::OK
|
|
|
|
};
|
|
|
|
}
|