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
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 oyvind.bjorge at telenor.com 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
Xymon mailing list Xymon at xymon.com http://lists.xymon.com/mailman/listinfo/xymon
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, <oyvind.bjorge at telenor.com> 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
Xymon mailing list Xymon at xymon.com http://lists.xymon.com/mailman/listinfo/xymon
On 9 August 2012 23:17, <oyvind.bjorge at telenor.com> 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
On 10-08-2012 03:55, Jeremy Laidman wrote:
#!/bin/bash exec 3<>/dev/tcp/$1/1984 || exit 1 echo "status
uname -n.testing greendate$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
On Fri, Aug 10, 2012 at 2:47 AM, Henrik Størner <henrik at hswn.dk> 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 greendate$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
participants (5)
-
henrik@hswn.dk
-
jlaidman@rebel-it.com.au
-
Mark.Deiss@xerox.com
-
oyvind.bjorge@telenor.com
-
ralphmitchell@gmail.com