comparison 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
comparison
equal deleted inserted replaced
23:f63737665ac5 24:7d431b779512
19 # You should have received a copy of the GNU General Public License 19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software 20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 # 22 #
23 23
24 #STD 24 #!/usr/bin/perl
25 use LWP::UserAgent;
25 use Getopt::Std; 26 use Getopt::Std;
26 27
27 #get LWP functionallity 28 getopts ("S:s:g:h:t:l:f:u");
28 use LWP::UserAgent;
29 29
30 #alert-status propbably? every Mon-alert uses that 30 $ALERT = $opt_u ? "UPALERT" : "ALERT";
31 getopts ("s:g:h:t:l:u"); 31 $SERVICE = $opt_g;
32 32
33 #Creates a new LWP-use-agent 33 my $server_endpoint = "http://localhost:8000/updown";
34 my $ua = LWP::UserAgent->new; 34 my $ua = LWP::UserAgent->new;
35
36 #defines the server-Endpoint. Usually the bottledash-server
37 my $server_endpoint = "http://<IP_des_Bottledash_servers>:8080/updown";
38
39 #determinates if the altert is an upalert or a "down"-alert
40 $ALERT = $opt_u ? "UPALERT" : "ALERT";
41
42 # set custom HTTP request header fields
43 my $req = HTTP::Request->new(POST => $server_endpoint); 35 my $req = HTTP::Request->new(POST => $server_endpoint);
44 $req->header('content-type' => 'application/json'); 36 $req->header('content-type' => 'x-www-form-urlencoded');
45 $req->header('x-auth-token' => 'kfksj48sdfj4jd9d'); 37 my $post_data = "service=$SERVICE&status=$ALERT";
46 38 $req->content($post_data);
47 # add POST data to HTTP request body 39 my $resp = $ua->request($req);
48 my $post_data = '{ "server": $ALERT, "status": $opt_u }';
49 $req->content($post_data);
50
51 #every-alert uses that. Dont know what that is
52 while (<STDIN>) {
53 print;
54 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)