Page 1 of 1

Get availability information

Posted: Mon Nov 26, 2012 7:34 am
by morabanc
Hello,

I'm trying to get availability information using report 'availability.php'
I'm proceeding into two steps, first one to login, and the second one for obtaining the information.
The answer it returns to me is "Your session has timed out'
What is wrong with the code?

$url = 'https://172.16.40.1/nagiosxi/login.php';

$outputfile = "bp_login.txt";
$cmd = "/usr/bin/wget --quiet=on --cookies=on --post-data 'username=xxxxxx&password=yyyyyyy&nsp=32c0390753bdbe9344d9bbb64646bc3e&action=/nagiosxi/login.php' \"$url\" -O $outputfile --save-cookies=./my-cookies.txt --keep-session-cookies=on --no-check-certificate";
exec($cmd);

$url = 'https://172.16.40.1/nagiosxi/reports/av ... vicegroup=';

$outputfile = "bp_disponibilitat.txt";
$cmd = "/usr/bin/wget --post-data='nsp_str=0d2273b2c10738606a4c92d5f9f4e0cb' --quiet=on --load-cookies=./my-cookies.txt --keep-session-cookies=on --save-cookies=./my-cookies.txt \"$url\" -O $outputfile --no-check-certificate";
exec($cmd);

Thanks for your help :)

Re: Get availability information

Posted: Mon Nov 26, 2012 1:32 pm
by scottwilkerson
My guess is you aren't giving a full path to the cookies file or the $outputfile, cookies=./my-cookies.txt won't exist....

I would go about this a bit differently.

If you go to Admin-> Manage Components -> Backend API

you can get the username & ticket for the user you are trying to login ad and it will auto log them in. then setup something like this replacing the username/ticket values

Code: Select all

$url = 'https://172.16.40.1/nagiosxi/reports/availability.php?host=Processos_negoci&service=&reportperiod=custom&startdate=2012-11-19&enddate=2012-11-20&reporttimesubmitbutton=Go&hostgroup=&servicegroup=&username=nagiosadmin&ticket=q6jjimi4';

$outputfile = "/tmp/bp_disponibilitat.txt";
$cmd = "/usr/bin/wget --quiet=on "$url" -O $outputfile --no-check-certificate";
exec($cmd);

Re: Get availability information

Posted: Wed Nov 28, 2012 3:26 am
by morabanc
Thanks scottwilkerson

I install the component but doesn't appear in my list (admin -> manage components) :?
It's possible that appear in other name ?? I find for "backend" and "api" but I don't find.

The last question, where I should go to see this parameters (usernamen and ticket) after install ??

Thanks

Re: Get availability information

Posted: Wed Nov 28, 2012 9:48 am
by scottwilkerson
It should be listed under
"Backend API URL"

Re: Get availability information

Posted: Fri Nov 30, 2012 9:32 am
by morabanc
I find it !!!!

The problem was that I had to give permissions to directory backend API by the shell
If i have a problem I'll tell you


Thanks scottwilkerson

Re: Get availability information

Posted: Fri Nov 30, 2012 10:31 am
by mguthrie
If you're using 2012 Enterprise Edition you can also just schedule the report to be emailed on a regular basis from the web interface.