update: add RSS MiB to server root page

main
_ 2020-12-20 19:46:30 +00:00
parent e5103d48bd
commit 4cb0911b77
5 changed files with 25 additions and 4 deletions

View File

@ -58,6 +58,7 @@ async fn handle_all (req: Request <Body>, state: Arc <State>)
let ptth_resp = file_server::serve_all ( let ptth_resp = file_server::serve_all (
&state.handlebars, &state.handlebars,
&state.metrics_startup, &state.metrics_startup,
&**state.metrics_gauge.load (),
file_server_root, file_server_root,
ptth_req.method, ptth_req.method,
&ptth_req.uri, &ptth_req.uri,

View File

@ -47,10 +47,22 @@ struct DirEntry {
pub async fn serve_root ( pub async fn serve_root (
handlebars: &Handlebars <'static>, handlebars: &Handlebars <'static>,
instance_metrics: &metrics::Startup metrics_startup: &metrics::Startup,
metrics_gauges: &Option <metrics::Gauges>,
) -> Result <Response, FileServerError> ) -> Result <Response, FileServerError>
{ {
let s = handlebars.render ("file_server_root", &instance_metrics)?; #[derive (Serialize)]
struct RootHtml <'a> {
metrics_startup: &'a metrics::Startup,
metrics_gauges: &'a Option <metrics::Gauges>,
}
let params = RootHtml {
metrics_startup,
metrics_gauges,
};
let s = handlebars.render ("file_server_root", &params)?;
Ok (serve_html (s)) Ok (serve_html (s))
} }

View File

@ -219,6 +219,7 @@ async fn serve_file (
pub async fn serve_all ( pub async fn serve_all (
handlebars: &Handlebars <'static>, handlebars: &Handlebars <'static>,
metrics_startup: &metrics::Startup, metrics_startup: &metrics::Startup,
metrics_gauges: &Option <metrics::Gauges>,
root: &Path, root: &Path,
method: Method, method: Method,
uri: &str, uri: &str,
@ -264,7 +265,7 @@ pub async fn serve_all (
}, },
InvalidQuery => serve_error (StatusCode::BadRequest, "Query is invalid for this object\n"), InvalidQuery => serve_error (StatusCode::BadRequest, "Query is invalid for this object\n"),
Root => html::serve_root (handlebars, metrics_startup).await?, Root => html::serve_root (handlebars, metrics_startup, metrics_gauges).await?,
ServeDir (internal::ServeDirParams { ServeDir (internal::ServeDirParams {
path, path,
dir, dir,

View File

@ -76,6 +76,7 @@ async fn handle_one_req (
let response = file_server::serve_all ( let response = file_server::serve_all (
&state.file_server.handlebars, &state.file_server.handlebars,
&state.file_server.metrics_startup, &state.file_server.metrics_startup,
&**state.file_server.metrics_gauge.load (),
file_server_root, file_server_root,
parts.method, parts.method,
&parts.uri, &parts.uri,

View File

@ -16,10 +16,16 @@
background-color: #ddd; background-color: #ddd;
} }
</style> </style>
<title>{{server_name}}</title> <title>{{metrics_startup.server_name}}</title>
</head> </head>
<body> <body>
<h1>{{metrics_startup.server_name}}</h1>
<h2>Gauges</h2>
<p>RSS MiB: {{metrics_gauges.rss_mib}}</p>
<div class="entry_list"> <div class="entry_list">
<div> <div>