0

I'm trying to wget a specific cacti graph image in order to make a daily report. We have htpasswd for the cacti website, and I've added a user for that. I'm usign wget's --http-user/password to pass it. That's working because without it, I get 403 Authorization Required back. However when I try to wget the image, I get redirected to index.php. What is it doing?

I've tried to change the user agent to the same as my Firefox in wget, no change. I've set the referer in wget to be the cacti page, no change. What is it doing? Is there something special with http auth and wget?

Amandasaurus
  • 31,471
  • 65
  • 192
  • 253

4 Answers4

3

You can pass cookie info with your wget command:

wget --help | grep cookie
   --cookies=off         don't use cookies.
   --load-cookies=FILE   load cookies from FILE before session.
   --save-cookies=FILE   save cookies to FILE after session.
Mark L
  • 568
  • 2
  • 9
  • 19
1

From what you've described it sounds like you've applied BasicAuth over the top of Cacti's builtin authorization mechanism. So by providing --http-user you are being allowed access to the web resource, but Cacti still doesn't know who you are, so it is redirecting you to a login page.

You probably have two options:

  • Provide wget a cookie so that it remains logged in.
  • Switch to "Web Basic Authentication" under settings.
Dan Carley
  • 25,617
  • 5
  • 53
  • 70
1

You can set cacti to pre-generate graphs on a regular basis and then stick them somewhere you can get at them. This avoids the identifying-yourself-to-cacti problem.

Go: console -> Configuration -> Settings -> Graph Export

You probably want to export to local file system, then put the graphs in some location where you can wget them from. Note that this seems to generate ALL graphs all at once which might be a significant impact on your system (depending on your system and complexity of cacti install) and make available more information than you really want to.

(This is true for cacti 0.8.7b, and, I presume, better versions.)

David Mackintosh
  • 14,293
  • 7
  • 49
  • 78
  • Yes I looked at the graph export, but it has a few flaws. Ideally I want a twice daily export. But you can'd do that in cacti. It's either every hour or everyday. Also it is a significant performance hog, so much so that nagios started going mad when I tried to export it. Also I don't *need* all the graphs. – Amandasaurus Aug 04 '09 at 23:21
0

I would start by checking the server logs (Apache perhaps) to see if there is any more information. Can you show us the command with different username and pass?

Oh, didn't read carefully enough, sorry. Are you sure the images are not generated dynamically as you request them? If they are not already there, the link will be invalid, the apache log might show you that.

Kyle Brandt
  • 83,619
  • 74
  • 305
  • 448