-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
References #195 This is the first dumb-ass implementation of the collector-api. It actually works fine for write AS IS, but has 0 safties. But I'm thinking the API itself is reasonably stable and ready for testing. I will need to extend it for dhcp-specific stuff, and the plan is to create a secondary table with metadata (hidden from the user) and a few other nice things. Also, indexes. We need indexes. Obviously.
- Loading branch information
1 parent
813ed7a
commit 0bd0445
Showing
2 changed files
with
132 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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(); |