From 8f967a9aea976d1eedea2ed5a335e5e3654fca19 Mon Sep 17 00:00:00 2001 From: Sergey Ivanov <seriv@cs.umd.edu> Date: Thu, 2 Apr 2020 15:17:16 -0400 Subject: [PATCH] move to responce as unlisted entry --- lib/Resmon/Status.pm | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/lib/Resmon/Status.pm b/lib/Resmon/Status.pm index 5a3e8a2..8ed82a6 100644 --- a/lib/Resmon/Status.pm +++ b/lib/Resmon/Status.pm @@ -182,14 +182,6 @@ sub dump_generic_module { my $info = $services->{$service}; $rv .= $dumper->($module,$service,$info); } - if ($module eq "Core::Resmon") { - my $info = { - name => 'now', - type => 'i', - value => time(), - }; - $rv .= $dumper->($module,"now",$info); - } return $rv; } sub dump_xml { @@ -374,7 +366,18 @@ sub service { $client->print($response . "\r\n"); return; } elsif($req =~ /^\/([^\/]+)\/(.+)\?plain$/) { - if(exists($self->{store}->{$1}) && + if($1 eq "System::Time" && $2 eq "now") { + my $info = { + name => 'now', + type => 'i', + value => time(), + }; + my $response = plain_info($1,$2,$info); + $client->print(http_header(200, length($response), 'text/plain', $snip)); + $client->print( $response . "\r\n"); + return; + } + elsif(exists($self->{store}->{$1}) && exists($self->{store}->{$1}->{$2})) { my $info = $self->{store}->{$1}->{$2}; my $response = plain_info($1,$2,$info); @@ -383,7 +386,22 @@ sub service { return; } } elsif($req =~ /^\/([^\/]+)\/(.+)$/) { - if(exists($self->{store}->{$1}) && + if($1 eq "System::Time" && $2 eq "now") { + my $info = { + name => 'now', + type => 'i', + value => time(), + }; + my $response = qq^<?xml version="1.0" encoding="UTF-8"?>\n^; + $response .= qq^<?xml-stylesheet type="text/xsl" href="/resmon.xsl"?>^; + $response .= "<ResmonResults>\n". + xml_info($1,$2,$info). + "</ResmonResults>\n"; + $client->print(http_header(200, length($response), 'text/xml', $snip)); + $client->print( $response . "\r\n"); + return; + } + elsif(exists($self->{store}->{$1}) && exists($self->{store}->{$1}->{$2})) { my $info = $self->{store}->{$1}->{$2}; my $response = qq^<?xml version="1.0" encoding="UTF-8"?>\n^; -- GitLab