Friday, February 17, 2012

Auto Login in Cacti

After finishing a second Cacti project, I need to place a link for the second cacti from the main Cacti System. It was just easy to make it using the 'superlinks' plugin in cacti, but the problem is, I have to do another login using my credentials for the second cacti system. And not only that, the header of the second cacti also appears below the header of the main Cacti.

I want my other users to view the "read-only" Devices (plugin), with only the device name and device status (up  or down. I modified the "Devices" plugin to suit my requirements and remove the headers from the script leaving only hosts status and filter options.

First, is to create an autologin.php in your cacti folder using the code below:

<?php

$_REQUEST["action"]="login";
$_POST["login_username"]='username';
$_POST["login_password"]='password';
$_SERVER["HTTP_REFERER"]='/plugins/devices/devices.php';

include "index.php";

?>

Call the script from your browser, and it will direct you to your http://your-server-ip/cacti/plugins/devices.php. The problem here is when you click again the 'superlinks tab', you will get an 'Access Denied'. To fix this, insert a code on your devices.php to call the autologin.php when opening the devices.php.

include_once("./autologin.php");

Then load the "http://your-server-ip/cacti/plugins/devices/devices.php" on the main Cacti's 'superlinks', you can now re-click the superlinks without getting an "Access Denied" error.


No comments:

Post a Comment