sean@11: #!/usr/bin/perl sean@11: # sean@11: # sean@11: # Sean Engelhardt, sean.engelhardt@intevation.de sean@11: # sean@11: # sean@11: # Copyright (C) 2015, Intevation sean@11: # sean@11: # This program is free software; you can redistribute it and/or modify sean@11: # it under the terms of the GNU General Public License as published by sean@11: # the Free Software Foundation; either version 2 of the License, or sean@11: # (at your option) any later version. sean@11: # sean@11: # This program is distributed in the hope that it will be useful, sean@11: # but WITHOUT ANY WARRANTY; without even the implied warranty of sean@11: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the sean@11: # GNU General Public License for more details. sean@11: # sean@11: # You should have received a copy of the GNU General Public License sean@11: # along with this program; if not, write to the Free Software sean@11: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA sean@11: # sean@11: sean@11: #STD sean@11: use Getopt::Std; sean@11: sean@11: #get LWP functionallity sean@11: use LWP::UserAgent; sean@11: sean@11: #alert-status propbably? every Mon-alert uses that sean@11: getopts ("s:g:h:t:l:u"); sean@11: sean@11: #Creates a new LWP-use-agent sean@11: my $ua = LWP::UserAgent->new; sean@11: sean@11: #defines the server-Endpoint. Usually the bottledash-server sean@11: my $server_endpoint = "http://:8080/updown"; sean@11: sean@11: #determinates if the altert is an upalert or a "down"-alert sean@11: $ALERT = $opt_u ? "UPALERT" : "ALERT"; sean@11: sean@11: # set custom HTTP request header fields sean@11: my $req = HTTP::Request->new(POST => $server_endpoint); sean@11: $req->header('content-type' => 'application/json'); sean@11: $req->header('x-auth-token' => 'kfksj48sdfj4jd9d'); sean@11: sean@11: # add POST data to HTTP request body sean@11: my $post_data = '{ "server": $ALERT, "status": $opt_u }'; sean@11: $req->content($post_data); sean@11: sean@11: #every-alert uses that. Dont know what that is sean@11: while () { sean@11: print; sean@11: }