annotate doc/connect_with_mon/bottledash.alert @ 17:09e3c38a7802

removing the old template cause of an ambiguous name
author sean
date Wed, 05 Aug 2015 13:36:26 +0200
parents 7a573ec679a6
children 7d431b779512
rev   line source
11
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
1 #!/usr/bin/perl
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
2 #
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
3 #
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
4 # Sean Engelhardt, sean.engelhardt@intevation.de
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
5 #
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
6 #
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
7 # Copyright (C) 2015, Intevation
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
8 #
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
9 # This program is free software; you can redistribute it and/or modify
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
10 # it under the terms of the GNU General Public License as published by
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
11 # the Free Software Foundation; either version 2 of the License, or
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
12 # (at your option) any later version.
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
13 #
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
14 # This program is distributed in the hope that it will be useful,
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
17 # GNU General Public License for more details.
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
18 #
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
19 # You should have received a copy of the GNU General Public License
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
20 # along with this program; if not, write to the Free Software
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
21 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
22 #
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
23
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
24 #STD
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
25 use Getopt::Std;
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
26
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
27 #get LWP functionallity
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
28 use LWP::UserAgent;
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
29
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
30 #alert-status propbably? every Mon-alert uses that
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
31 getopts ("s:g:h:t:l:u");
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
32
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
33 #Creates a new LWP-use-agent
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
34 my $ua = LWP::UserAgent->new;
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
35
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
36 #defines the server-Endpoint. Usually the bottledash-server
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
37 my $server_endpoint = "http://<IP_des_Bottledash_servers>:8080/updown";
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
38
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
39 #determinates if the altert is an upalert or a "down"-alert
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
40 $ALERT = $opt_u ? "UPALERT" : "ALERT";
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
41
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
42 # set custom HTTP request header fields
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
43 my $req = HTTP::Request->new(POST => $server_endpoint);
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
44 $req->header('content-type' => 'application/json');
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
45 $req->header('x-auth-token' => 'kfksj48sdfj4jd9d');
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
46
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
47 # add POST data to HTTP request body
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
48 my $post_data = '{ "server": $ALERT, "status": $opt_u }';
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
49 $req->content($post_data);
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
50
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
51 #every-alert uses that. Dont know what that is
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
52 while (<STDIN>) {
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
53 print;
7a573ec679a6 added more files, can now display charts a bit
sean
parents:
diff changeset
54 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)