changeset 24:7d431b779512

working connection with MON
author sean
date Thu, 13 Aug 2015 16:34:46 +0200
parents f63737665ac5
children 05e5441c5160
files dash.py doc/connect_with_mon/bottledash.alert views/bottledash_view.tpl
diffstat 3 files changed, 13 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/dash.py	Thu Aug 13 13:14:00 2015 +0200
+++ b/dash.py	Thu Aug 13 16:34:46 2015 +0200
@@ -179,7 +179,7 @@
     logger.info('------- new alert --------')
     logger.info('Service : ' + str(service))
     logger.info('Status : ' + str(status))
-    log_tile_status()
+    # log_tile_status()
 
     return "thanks for informing bottledash! :: " + str(service) + " is " + str(status) + " !"
 
--- 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);
--- a/views/bottledash_view.tpl	Thu Aug 13 13:14:00 2015 +0200
+++ b/views/bottledash_view.tpl	Thu Aug 13 16:34:46 2015 +0200
@@ -140,7 +140,7 @@
       function check_server_state_loop() {
         for (var i = 0; i < mon_tile_ips.length; i++) {
           var state = check_server_state(mon_tile_ips[i])
-          if (state == "up") {
+          if (state == "UPALERT" || state == "UP") {
             set_mon_tile_status(mon_tile_ips[i], "active")
           } else {
             set_mon_tile_status(mon_tile_ips[i], "dead")
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)