From 55783753ae8f2d857a7225b7a93c1d47039e5a90 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Mon, 16 Apr 2018 10:30:15 +0200 Subject: OpenShift monitoring --- scripts/ping.pl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 scripts/ping.pl (limited to 'scripts/ping.pl') diff --git a/scripts/ping.pl b/scripts/ping.pl new file mode 100755 index 0000000..0f24483 --- /dev/null +++ b/scripts/ping.pl @@ -0,0 +1,19 @@ +#!/usr/bin/perl -w +use Net::Ping; +use Switch; + +if (@ARGV >1) { $host=$ARGV[0]; $timeout=$ARGV[1]; } +elsif (@ARGV>0) { $host=$ARGV[0]; $timeout=2; } +else { print "Usage is: $0 host \n"; exit; } + +if ($host =~ /^(.*):(\d+)$/) { + $host = $1; + $port = $2; +} else { + $port = 22; +} + +$p=Net::Ping->new('tcp'); +$p->port_number($port); +if ($p->ping($host, $timeout)) {print 1;} else {print 0;} +$p->close(); -- cgit v1.2.3