How to use regexp in command_line


#1

Hello,

I want to include graphs (from nagios grapher) link from service checks into the notification e-mails.
For this I want to use the following:

define command{
command_name service-notifications
command_line /usr/bin/printf “%b” " …BLABLA… Graph URL: NAG/nagios/cgi-bin/graphs.cgi?ho … $&service=$SERVICEDESC$ \n" | /bin/mail -s “SUBJECT” $CONTACTEMAIL$
}

The problem is that some of the service names have spaces EX: "check disk C"
Because of this the link generated for the graph is : NAG/nagios/cgi-bin/graphs.cgi?host=WIN&service=check disk C which is not useful to me because of the spaces.
An useful link would be NAG/nagios/cgi-bin/graphs.cgi?host=WIN&service=check%20disk%20C

For this I will need to use a regexp to change the spaces from $SERVICEDESC$ into "%20"
Does someone know how can I do this inside the command_line ?

Regards Ovidiu.