Problems page and image links

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
jag7720
Posts: 14
Joined: Wed Sep 15, 2010 11:24 am

Problems page and image links

Post by jag7720 »

The "Problems" pages has images all over it. We want to email this page but the image links point to
<IMG SRC='/nagios/images/down.gif...

In the email, they appear as file:///nagios/images/down.gif

Is there a way that we can globally change this image path to the FQDN so they appear in the email?
tonyyarusso
Posts: 1128
Joined: Wed Mar 03, 2010 12:38 pm
Location: St. Paul, MN, USA
Contact:

Re: Problems page and image links

Post by tonyyarusso »

I'm sure you could, but it's a little odd. Wouldn't it make more sense to print the page to a PDF and e-mail that, to make sure you send a static copy?
Tony Yarusso
Technical Services
___
TIES
Web: http://ties.k12.mn.us/
mmestnik
Posts: 972
Joined: Mon Feb 15, 2010 2:23 pm

Re: Problems page and image links

Post by mmestnik »

wget and perhaps some other tools, like your browser's save function, have methods to correct this problem. I'd start with those and see what you can find
jag7720
Posts: 14
Joined: Wed Sep 15, 2010 11:24 am

Re: Problems page and image links

Post by jag7720 »

Yes, that would. But I am not a programmer and all I am doing is using someone's perl script to send out these reports.

http://exchange.nagios.org/directory/Ad ... er/details

this is what I added to the script

Code: Select all

###############################################################################
sub report_current {
        $repdateprev = Date_PrevWorkDay("today",1);
        debug(1,"repdateprev = $repdateprev");
                                #2006072116:48:37
$reporturl      =       "$webbase/cgi-bin/status.cgi?host=all&servicestatustypes=28";
        $mailsubject = "Nagios Current alerts for today";
}

###############################################################################
Might you know how to print out the page in PDF with perl?


thanks
mmestnik
Posts: 972
Joined: Mon Feb 15, 2010 2:23 pm

Re: Problems page and image links

Post by mmestnik »

In perl(AKA the Practice Extraction and Report Language), it's certifiably possible. The perl moto is there is more then one way to do every thing, as an exercise we try and discover just how many... or something like that.

Something like this should do it.

Code: Select all

$output ~= s%<IMG SRC='/nagios/image%<IMG SRC='http://(servername)/nagios/image%g
jag7720
Posts: 14
Joined: Wed Sep 15, 2010 11:24 am

Re: Problems page and image links

Post by jag7720 »

mmestnik wrote:... perhaps some other tools, like your browser's save function...
Other tools???

I'm trying to do this from a script so I can run it with cron.
mmestnik
Posts: 972
Joined: Mon Feb 15, 2010 2:23 pm

Re: Problems page and image links

Post by mmestnik »

Here is a document that explains how:
http://www.darkspell.com/references/lwpcook.html
tonyyarusso
Posts: 1128
Joined: Wed Mar 03, 2010 12:38 pm
Location: St. Paul, MN, USA
Contact:

Re: Problems page and image links

Post by tonyyarusso »

To do it with Perl, I'd look at http://search.cpan.org/dist/PDF-API2/

You could also accomplish this with html2ps and ps2pdf (or ghostscript), or htmldoc, all of which would be scriptable.
Tony Yarusso
Technical Services
___
TIES
Web: http://ties.k12.mn.us/
jag7720
Posts: 14
Joined: Wed Sep 15, 2010 11:24 am

Re: Problems page and image links

Post by jag7720 »

I don't have it scripted yet but here are the basics that I came up with

Do a wget

Code: Select all

wget -O status.html --user nagios --password nagios "http://nagiosserver1.company.com/nagios/cgi-bin/status.cgi?host=all&servicestatustypes=28
Then convert it to postscript

Code: Select all

html2ps status.html > status.ps
then convert that to .pdf

Code: Select all

ps2pdf status.ps > status.pdf
Then mail it out

Code: Select all

email -s "Attachment" -a coolpic.jpg [email protected]

You can also redirect text:

email -s "Attachement" -a coolpic.jpg [email protected] < somefile

You can send an empty email with just the attachment:

email -s "Attachment" -a coolpic.jpg -b [email protected]

jag7720
Posts: 14
Joined: Wed Sep 15, 2010 11:24 am

Re: Problems page and image links

Post by jag7720 »

And now that I think about it, this is probably easier

wget -k -O status.html --user nagios --password nagios "http://nagiosdc1.dfckc.com/nagios/cgi-b ... ustypes=28"

the "-k" converts the links in the document to make them suitable for local viewing
then email the html file
Locked