From e5ac2c184451abec2b8b612a8be8ee5085ce25b0 Mon Sep 17 00:00:00 2001 From: jweiss Date: Mon, 4 Feb 2008 23:45:41 +0000 Subject: [PATCH] handle deep URLs and virtual hosts --- gen/nagios-wsh.gen | 74 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 3 deletions(-) diff --git a/gen/nagios-wsh.gen b/gen/nagios-wsh.gen index 3700360d..ab61299e 100755 --- a/gen/nagios-wsh.gen +++ b/gen/nagios-wsh.gen @@ -113,9 +113,77 @@ define service{ } END - } else { - printf STDERR "Machine %s has unknown service %s; ignoring\n", $name, $service; - } + } else { # Hopefully this is a URL of some sort + my $protocol; + my $server; + my $path; + if ($service =~ /^([a-z]*):\/\/([^\/]*)(.*)$/ ) { + $protocol = $1; + $server = $2; + $path = $3; + $protocol =~ tr/a-z/A-Z/; + $server =~ tr/A-Z/a-z/; + } + if ($protocol =~ /^HTTP(|S)$/) { + $path = "/" if ($path eq ""); + if ($server eq $name && $path eq "/") { # this is a simple service + push @tags,$protocol; + } + # prep a bunch of variables for the text we'll spit out + my $description = "$protocol-$server-$path"; + $description =~ s/-\//-/g; + $description =~ s/\/-/-/g; + $description =~ s/\//-/g; + $description =~ s/-$//g; + $description =~ tr/A-Z/a-z/; + my $ucdescription = $description; + $ucdescription =~ tr/a-z/A-Z/; + my $SSL = ""; + if ($protocol eq "HTTPS") { + $SSL = "--SSL -k /var/nagios/etc/cert.pem"; + } + print OUT <