RE : [Nagios-devel] Nagios CGI Customizing - service_name?
Posted: Tue Aug 02, 2005 12:39 am
--Boundary-00=_yEz7CJDF5a9ddoI
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Hi,
I use http referer to get host_name and service_name.
I add a link "Go to Wiki" with ssi inclusion, and i call
a perl cgi wich redirect to the good page.
See my tiny perl script. (Install notes are in header)
Regards
>Hello,
>
>I'm trying to implement a wiki into nagios, yet I'm having difficulties
>filtering out the "service_name" itself. If I use the "service_desc"
>parameter in the cgi, it gives me "%host&service=%servcie", yet i'dd
>like to have the "%service" alone.
>Has anyone done this before?
>
>Regards
>
>Karim
--Boundary-00=_yEz7CJDF5a9ddoI
Content-Type: application/x-perl;
name="doc.cgi"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="doc.cgi"
#!/usr/bin/perl -T -w
# Copyright (C) 2004-2005 Eric Bollengier
#
# This program and documentation is free software; you can redistribute
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
# $Id$
# Nagios is a registered trademark of Ethan Galstad.
################################################################
##
# README :
# This cgi display documentation about host and services
# INSTALL :
# copy this file in $prefix/cgi (where prefix is nagios install dir)
# do a chmod +x $prefix/cgi/doc.cgi
# add something like
# [root@plume ssi]# cat /usr/share/nagios/ssi/extinfo-header.ssi
# Informations
################################################################
# user configuration
our $doc_url = '/phpwiki' ;
################################################################
use strict ;
use CGI qw/:standard/;
use CGI::Util qw/unescape/ ;
param() or die "Error with param() $!" ;
my $host = param('host') || '' ;
my $serv = param('service') || '' ;
my $hostgrp = param('hostgroup') || '' ;
my $last_url = referer() || '' ;
if ($last_url =~ /host=([^&]+)&?/) {
$host = unescape($1) ;
}
if ($last_url =~ /service=([^&]+)&?/) {
$serv = unescape($1) ;
}
if ($last_url =~ /hostgroup=([^&]+)&?/) {
$hostgrp = unescape($1) ;
}
my $query = new CGI() ;
# verfication
if ($hostgrp) {
$hostgrp =~ /^[0-9a-zA-Z_ \.-]+$/ or die "Error in $hostgrp format" ;
print $query->redirect("$doc_url/$hostgrp") ;
exit 0 ;
}
$host =~ /^[0-9a-zA-Z_ \.-]+$/ or die "Error in $host format" ;
if ($serv) {
$serv =~ /^[0-9a-zA-Z_\.-]+$/ or die "Error in $serv format" ;
}
print $query->redirect("$doc_url/$host#$serv") ;
exit 0 ;
--Boundary-00=_yEz7CJDF5a9ddoI--
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Hi,
I use http referer to get host_name and service_name.
I add a link "Go to Wiki" with ssi inclusion, and i call
a perl cgi wich redirect to the good page.
See my tiny perl script. (Install notes are in header)
Regards
>Hello,
>
>I'm trying to implement a wiki into nagios, yet I'm having difficulties
>filtering out the "service_name" itself. If I use the "service_desc"
>parameter in the cgi, it gives me "%host&service=%servcie", yet i'dd
>like to have the "%service" alone.
>Has anyone done this before?
>
>Regards
>
>Karim
--Boundary-00=_yEz7CJDF5a9ddoI
Content-Type: application/x-perl;
name="doc.cgi"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="doc.cgi"
#!/usr/bin/perl -T -w
# Copyright (C) 2004-2005 Eric Bollengier
#
# This program and documentation is free software; you can redistribute
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
# $Id$
# Nagios is a registered trademark of Ethan Galstad.
################################################################
##
# README :
# This cgi display documentation about host and services
# INSTALL :
# copy this file in $prefix/cgi (where prefix is nagios install dir)
# do a chmod +x $prefix/cgi/doc.cgi
# add something like
# [root@plume ssi]# cat /usr/share/nagios/ssi/extinfo-header.ssi
# Informations
################################################################
# user configuration
our $doc_url = '/phpwiki' ;
################################################################
use strict ;
use CGI qw/:standard/;
use CGI::Util qw/unescape/ ;
param() or die "Error with param() $!" ;
my $host = param('host') || '' ;
my $serv = param('service') || '' ;
my $hostgrp = param('hostgroup') || '' ;
my $last_url = referer() || '' ;
if ($last_url =~ /host=([^&]+)&?/) {
$host = unescape($1) ;
}
if ($last_url =~ /service=([^&]+)&?/) {
$serv = unescape($1) ;
}
if ($last_url =~ /hostgroup=([^&]+)&?/) {
$hostgrp = unescape($1) ;
}
my $query = new CGI() ;
# verfication
if ($hostgrp) {
$hostgrp =~ /^[0-9a-zA-Z_ \.-]+$/ or die "Error in $hostgrp format" ;
print $query->redirect("$doc_url/$hostgrp") ;
exit 0 ;
}
$host =~ /^[0-9a-zA-Z_ \.-]+$/ or die "Error in $host format" ;
if ($serv) {
$serv =~ /^[0-9a-zA-Z_\.-]+$/ or die "Error in $serv format" ;
}
print $query->redirect("$doc_url/$host#$serv") ;
exit 0 ;
--Boundary-00=_yEz7CJDF5a9ddoI--
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]