Page 1 of 2

Problems page and image links

Posted: Wed Sep 15, 2010 11:30 am
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?

Re: Problems page and image links

Posted: Wed Sep 15, 2010 11:55 am
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?

Re: Problems page and image links

Posted: Wed Sep 15, 2010 2:00 pm
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

Re: Problems page and image links

Posted: Wed Sep 15, 2010 2:03 pm
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

Re: Problems page and image links

Posted: Wed Sep 15, 2010 2:48 pm
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

Re: Problems page and image links

Posted: Wed Sep 15, 2010 3:12 pm
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.

Re: Problems page and image links

Posted: Wed Sep 15, 2010 3:16 pm
by mmestnik
Here is a document that explains how:
http://www.darkspell.com/references/lwpcook.html

Re: Problems page and image links

Posted: Wed Sep 15, 2010 4:21 pm
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.

Re: Problems page and image links

Posted: Wed Sep 15, 2010 5:39 pm
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]


Re: Problems page and image links

Posted: Thu Sep 16, 2010 9:40 am
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