blob: eb20e8c982ef590e5fdb40efc3a2513b2153fda3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#! /usr/bin/perl
# vim:ts=8:sw=8
use lib '/opt/gondul/include';
use utf8;
use nms;
use nms::web qw($dbh db_safe_quote get_input finalize_output);
use strict;
use warnings;
my %input = %{JSON::XS::decode_json(get_input())};
my ($q,$check);
my $metric = $dbh->prepare("INSERT INTO metrics (src,metadata,data) VALUES(?,?,?)");
$nms::web::cc{'max-age'} = '0';
$nms::web::cc{'stale-while-revalidate'} = '0';
$nms::web::json{'state'} = 'ok';
foreach my $entry (@{$input{'data'}}) {
$metric->execute($input{'src'},JSON::XS::encode_json($input{'metadata'}),JSON::XS::encode_json($entry));
}
finalize_output();
|