diff doc/connect_with_mon/bottledash.alert @ 24:7d431b779512

working connection with MON
author sean
date Thu, 13 Aug 2015 16:34:46 +0200
parents 7a573ec679a6
children 140c9023df7a
line wrap: on
line diff
--- a/doc/connect_with_mon/bottledash.alert	Thu Aug 13 13:14:00 2015 +0200
+++ b/doc/connect_with_mon/bottledash.alert	Thu Aug 13 16:34:46 2015 +0200
@@ -21,34 +21,19 @@
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #
 
-#STD
+#!/usr/bin/perl
+use LWP::UserAgent;
 use Getopt::Std;
 
-#get LWP functionallity
-use LWP::UserAgent;
-
-#alert-status propbably? every Mon-alert uses that
-getopts ("s:g:h:t:l:u");
+getopts ("S:s:g:h:t:l:f:u");
 
-#Creates a new LWP-use-agent
-my $ua = LWP::UserAgent->new;
-
-#defines the server-Endpoint. Usually the bottledash-server
-my $server_endpoint = "http://<IP_des_Bottledash_servers>:8080/updown";
-
-#determinates if the altert is an upalert or a "down"-alert
 $ALERT = $opt_u ? "UPALERT" : "ALERT";
-
-# set custom HTTP request header fields
-my $req = HTTP::Request->new(POST => $server_endpoint);
-$req->header('content-type' => 'application/json');
-$req->header('x-auth-token' => 'kfksj48sdfj4jd9d');
+$SERVICE = $opt_g;
 
-# add POST data to HTTP request body
-my $post_data = '{ "server": $ALERT, "status": $opt_u }';
-$req->content($post_data);  
-
-#every-alert uses that. Dont know what that is
-while (<STDIN>) {
-    print;
-}
\ No newline at end of file
+my $server_endpoint = "http://localhost:8000/updown";
+my $ua = LWP::UserAgent->new;
+my $req = HTTP::Request->new(POST => $server_endpoint);
+$req->header('content-type' => 'x-www-form-urlencoded');
+my $post_data = "service=$SERVICE&status=$ALERT";
+$req->content($post_data);
+my $resp = $ua->request($req);
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)