Perl client without xymon client. (OPEN)
list Oyvind Bjorge
Is there anyone that have made a perl module or subroutine for sending to a xymon-server without having to install the xymon client? On some node it is difficult to install a client. Some vendors are very afraid of having things installed on "their" equipment, and the os might be stripped down with no compilers and so on. For sending to xymon I guess all you need is a simple socket connections so I expect that this has been done many times already. Anyone who would like to share? / Øyvind
list Mark Deiss
You could investigate using Big Sister as a client. It's been a few years since I used it. It ~was Perl based and ~was compatible with Big Brother/port 1984 transmission/BB messaging format at the time. I think it is safe to mention it now; in the past, Mr. Croteau and Mr. MacGuire would throw thunderbolts from Mount BB.
▸
-----Original Message-----
From: xymon-bounces at xymon.com [mailto:xymon-bounces at xymon.com] On Behalf Of user-9b0f7b358aa3@xymon.invalid
Sent: Thursday, August 09, 2012 9:17 AM
To: xymon at xymon.com
Subject: [Xymon] Perl client without xymon client. (OPEN)
Is there anyone that have made a perl module or subroutine for sending to a xymon-server without having to install the xymon client?
On some node it is difficult to install a client. Some vendors are very afraid of having things installed on "their" equipment, and the os might be stripped down with no compilers and so on.
For sending to xymon I guess all you need is a simple socket connections so I expect that this has been done many times already.
Anyone who would like to share?
/ Øyvind
list Oyvind Bjorge
The syntax of the bb-protocol was described in bb-doc, so tested with the following perl subroutine and it worked.
- Øyvind
sub sendToXymon {
use IO::Socket;
my($server,$port,$host,$test,$color,$date,$subject,$string) = @_ ;
my $sock = new IO::Socket::INET (
PeerAddr => $server,
PeerPort => $port,
Proto => 'tcp',
);
die "Could not create socket: $!\n" unless $sock;
print $sock "status " . &xymonhost($host) . "." . $test . " " . $color . " " . $date . " " . $subject . "\n" . $string ;
close($sock);
}
sub xymonhost {
my($host) = @_ ;
$host =~ s/\./,/g ;
return $host ;
▸
}
Fra: Deiss, Mark [user-aa18037b3fdc@xymon.invalid]
Sendt: 9. august 2012 15:54
Til: Bjørge Øyvind (Operations); xymon at xymon.com
Emne: RE: Perl client without xymon client. (OPEN)
You could investigate using Big Sister as a client. It's been a few years since I used it. It ~was Perl based and ~was compatible with Big Brother/port 1984 transmission/BB messaging format at the time.
I think it is safe to mention it now; in the past, Mr. Croteau and Mr. MacGuire would throw thunderbolts from Mount BB.
-----Original Message-----
From: xymon-bounces at xymon.com [mailto:xymon-bounces at xymon.com] On Behalf Of user-9b0f7b358aa3@xymon.invalid
Sent: Thursday, August 09, 2012 9:17 AM
To: xymon at xymon.com
Subject: [Xymon] Perl client without xymon client. (OPEN)
Is there anyone that have made a perl module or subroutine for sending to a xymon-server without having to install the xymon client?
On some node it is difficult to install a client. Some vendors are very afraid of having things installed on "their" equipment, and the os might be stripped down with no compilers and so on.
For sending to xymon I guess all you need is a simple socket connections so I expect that this has been done many times already.
Anyone who would like to share?
/ Øyvind
list Ralph Mitchell
There used to be a perl script called bb.pl that was almost a drop-in replacement for the old 'bb' command, if I recall correctly. I've been having a reasonable degree of success using curl to post to the xymon server. It shouldn't be too hard to make that into a shell script to replace the compiled client for general use. Ralph Mitchell
▸
On Thu, Aug 9, 2012 at 9:17 AM, <user-9b0f7b358aa3@xymon.invalid> wrote:
Is there anyone that have made a perl module or subroutine for sending to a xymon-server without having to install the xymon client? On some node it is difficult to install a client. Some vendors are very afraid of having things installed on "their" equipment, and the os might be stripped down with no compilers and so on. For sending to xymon I guess all you need is a simple socket connections so I expect that this has been done many times already. Anyone who would like to share? / Øyvind
list Jeremy Laidman
▸
On 9 August 2012 23:17, <user-9b0f7b358aa3@xymon.invalid> wrote:
Is there anyone that have made a perl module or subroutine for sending to a xymon-server without having to install the xymon client?
You could use xymon-rclient (on xymonton.org), where you only need an ssh connection from the server to a shell running on the client; it automagically sends the client-side script, and injects the results on the server side. Also, this shell one-liner works on Solaris under ksh, bash and bourne shell (sh): #!/bin/sh ( echo "$2"; sleep 1 ) | telnet $1 1984 2>&1 >/dev/null | grep -v "closed by foreign host" Run it like this: ./xymon.sh $XYMSRV "status `uname -n`.testname green All OK" Alternatively, netcat (nc) can be used like so: echo "$2" | nc -w1 $1 1984 || echo "Connection failure" Neither of these are ideal, because there's no way to close the connection on the client side once the message has been sent, and so it simply waits 1 second (-w1 for nc) and assumes it has all been sent. This bash code doesn't have the same limitation. It works on Linux and should work on all UNIXes that run bash: #!/bin/bash exec 3<>/dev/tcp/$1/1984 || exit 1 echo "status `uname -n`.testing green `date` $2" >&3 Run it as above. This script uses the /dev/tcp bash-ism, so it's not portable to other shells. If you needed to send multiple messages in a single script, you should close the socket after each with "exec 3<>-". J
list Henrik Størner
▸
On 10-08-2012 03:55, Jeremy Laidman wrote:
#!/bin/bash exec 3<>/dev/tcp/$1/1984 || exit 1 echo "status `uname -n`.testing green `date` $2" >&3
Well, whaddayano - one learns something new every day! This was too good to just leave in the mailinglist archive, so I collected the Perl, Bash- and Korn-shell suggestions into the Xymon "Tips & Tricks" document. See http://www.xymon.com/xymon/help/xymon-tips.html#noinstall Thanks! Regards, Henrik
list Ralph Mitchell
▸
On Fri, Aug 10, 2012 at 2:47 AM, Henrik Størner <user-ce4a2c883f75@xymon.invalid> wrote:
On 10-08-2012 03:55, Jeremy Laidman wrote:#!/bin/bash exec 3<>/dev/tcp/$1/1984 || exit 1 echo "status `uname -n`.testing green `date` $2" >&3Well, whaddayano - one learns something new every day! This was too good to just leave in the mailinglist archive, so I collected the Perl, Bash- and Korn-shell suggestions into the Xymon "Tips & Tricks"
document. See http://www.xymon.com/xymon/**help/xymon-tips.html#noinstall<http://www.xymon.com/xymon/help/xymon-tips.html#noinstall>;
Another one for the list. This works well enough to be a drop-in
replacement for the xymon binary on some AIX systems here. it gets you
(optional) encrypted delivery.
#!/bin/sh
# Shell script replacement for the xymon binary
export XYMONURL="https://server.domain.com/xymon-cgi/xymoncgimsg.cgi";
# the curl option "--capath" designates a directory with CA
certificates
# to validate secure server connections. If your xymon server doesn't
# use https, that line can be removed.
if [ "$2" = "@" ]; then
# read message from stdin
$XYMONHOME/bin/curl -s -S -L -m 30 \
--capath /etc/pki/tls/certs \
-H "Content-Type: application/octet-stream" \
-H "MIME-version: 1.0" \
--data-binary "@-" \
$XYMONURL
else
# arg 2 *is* the message
$XYMONHOME/bin/curl -s -S -L -m 30 \
--capath /etc/pki/tls/certs \
-H "Content-Type: application/octet-stream" \
-H "MIME-version: 1.0" \
--data-binary "$2" \
$XYMONURL
fi
exit 0
Ralph Mitchell