1. 1
Web-Based
Monitoring System
for Caching Solutions
Project submitted for Internship of
Bachelor of Technology
In
Computer Science & Engineering
Submitted by:
Subhayu Chakravorty
4th Year (2012 - 2016)
Institute of Engineering & Management, Kolkata
2. 2
TOPIC:
WEB-BASED MONITORING SYSTEM FOR CACHING SOLUTIONS
STUDENT NAME:
SUBHAYU CHAKRAVORTY
INSTITUTE NAME:
INSTITUTE OF ENGINEERING & MANAGEMENT, KOLKATA
STREAM:
COMPUTER SCIENCE AND ENGINEERING
YEAR:
4TH YEAR (2012 - 2016)
TRAINING PERIOD:
Start Date: 10-JULY-2015
End Date: 15-NOV-2015
PLACEMENT OF INTERNSHIP: Kolkata
3. 3
CERTIFICATE OF ORIGINALITY
This is to certify that the project entitled “WEB-BASED MONITORING
SYSTEM FOR CACHING SOLUTIONS” is a bonafide record of the work
done in partial fulfillment of the requirements for the award of Bachelor of
Technology (Computer Science) to:
Name: SUBHAYU CHAKRAVORTY
Roll: 10400112153
Registration: 121040110113
Session: 2012-2016
This is an authentic work carried out under my supervision. To the best of
my knowledge, the content of this project does not form a basis for the award of
any previous degree to anyone else.
_____________________
Mr. Sudipta Pal
DSCCIN.in Kolkata
________________________ _________________________
Mr. Sujoy Das Mr. Kallol Bhattacharya
DSCCIN.in Kolkata DSCCIN.in Kolkata
4. 4
ACKNOWLEDGEMENT
I take this opportunity to express my profound gratitude and deepest
regards to all those who sincerely helped me with their advice and guidance for the
completion of this project.
I am extremely grateful to my mentor Mr. Sudipta Pal for the confidence
bestowed in me and entrusting my project entitled “Web-Based Monitoring
System for Caching Solutions” for Data Systems Control & Communication Pvt.
Ltd.
I also take this opportunity to honor and express my sincere thanks to Mr.
Kallol Bhattacharya and Mr. Sujoy Das for giving me this opportunity to work as
an intern at the Data Consultancy Corp and providing valuable insights leading to
the successful completion of my project.
Lastly, I thank my parents, family and friends for their support and
encouragement without which this assignment would not have been possible.
_____________________________
SUBHAYU CHAKRAVORTY
5. 5
CONTENTS
A. INTRODUCTION
1. ABOUT THE COMPANY
B. SOFTWARE & HARDWARE
1. SOFTWARE USED
2. HARDWARE USED
C. PROJECT
1. INTRODUCTION
1.1 PURPOSE OF TASK
1.2 OPTIONS AVAILABLE FOR TASK
1.3 OPTION CHOSEN AND REASONS
1.4 FEATURE LIST
2. PROJECT MANAGEMENT
2.1 IMPLEMENTATION LANGUAGE AND
TECHNOLOGY
2.2 DESIGN PROCESSES
2.3 TESTING
3. PROGRAM DESCRIPTION AND IMPLEMENTATION
3.1 DESIGN DESCRIPTION AND WORKING
3.2 INTERFACE AND SCREENSHOTS
3.3 DATABASE AND SERVER
4. PROJECT SOURCE CODES
5. CONCLUSION
5.1 WHAT HAS BEEN DONE
5.2 CONTRIBUTION AND ROLE IN THE PROJECT
5.3 WHAT I HAVE LEARNT
5.4 WHAT I WOULD DIFFERENTLY IN FUTURE
D. BIBLIOGRAPHY
6. 6
INTRODUCTION
1. ABOUT THE COMPANY:
Data System Control & Communication Pvt. Ltd. or simply DSCC, is a unit of DCC. DCC
was founded in 1987 in New York City famous for their ability to provide companies with
LAN and WAN solutions. A large client base was developed and continues to grow. Today,
DCC is headquartered in Aurora, IL with Clients worldwide. DCC is fast becoming a leader
in services for clients in IP communication and networking technologies.
DCC provides innovated service solutions in the core areas of routing and switching as
well as advanced technologies such as IP Telephony, Network Security, Wireless LAN,
and backup and storage solutions.
DCC works closely with our technology partners such as Cisco Systems, HP, Microsoft,
Nortel, SAP (DCC is an IP communications certified premier partner with Cisco Systems,
a Microsoft gold partner, an HP Partner and a SAP service specialist group), to provide
an evolutionary hardware and software infrastructure that will deliver differentiated
value to clients through unique product and service offerings.
The DCC name has become synonymous with IP Solutions that allow companies to
increase productivity, improve customer satisfaction and strengthen competitive
advantage.
DSCC provides a number of solutions. They have three broad categories, namely, Service
Providing, Networking, and Security. Among the services that they provide are, Content
Caching, Content Filtering, IP Blacklist Removal, Outdoor Wireless, Reverse Caching,
IPv6 Migration and Billing Solution. In networking, they provide Wireless Solution,
Routing & Switching, Network Auditing and WAN Acceleration. In security they provide
Firewall and Audit solutions.
7. 7
SOFTWARE AND HARDWARE
1. SOFTWARE USED:
● Brackets [Development / Editor]
● WinSCP [File Transfer and Remote Login]
● Putty [Remote Login]
● MySQL [Database]
● Cacti [SNMP]
2. HARDWARE USED:
● OS: CentOS, Linux based servers.
● Server 1: iNetManage contains the Cacti software.
● Server 2: iNetMonitor contains the database.
● Some Linux based client machines for testing.
● Google Chrome for testing Client Side on all other platforms.
8. 8
PROJECT
ABSTRACT
GUI configuration for the inet-cache server which includes reporting graphs for interface
traffics and memory usage of servers and this service will be provided to various ISP’s to
monitor their servers.
1. INTRODUCTION
The idea is that the cacti server would poll the monitored devices and generate graphs.
The web UI server would fetch the graphs and embed the same into a consolidated UI.
The Web UI would also bear the capability to run specific commands on the monitored
targets and display the 'formatted result' from the command output. The UI would also
display the 'run status' of couple of important services in the monitored hosts.
The UI would also have some command buttons to execute some tasks on the monitored
hosts. It may also display some formatted and filtered output of few log files in the
monitored hosts.
An admin panel would be used to register the users using the service offered. It will also
control and monitor the usage of the customers. It will also keep a track of the payments
made by the customer and the expiration of their licenses.
1.1 Purpose of Task:
User access to the inet-cache server for reporting, troubleshooting and some basis
configuration portion.
Admin panel to control user access and monitor usage.
1.2 Options available to complete Task:
1. MRTG link for reporting graphs.
2. Webmin for troubleshooting and some basis configuration.
3. Cacti software for reporting graphs of all the inet-cache servers in a single server.
4. GUI using PHP platform, which will include some customized tabs for troubleshooting
and basis configuration portion. One server will include GUI for all the inet-cache servers.
9. 9
1.3 Option chosen and reasons:
1. Cacti Software is selected as more graph patterns are available then MRTG, also a
single server will be used for all the cache servers reporting graphs.
2. GUI using PHP platform is selected, as it is completely customizable and will be
patent to the inet-cache servers.
1.4 Feature List:
The features of the the user interface, as completed by the report deadline, are as follows.
The Login Page verifies the entered details with the database created on iNetMonitor. The
database consists of the Host Table, the User Table, the Graph table, the Host_Grpah
table and the Payment Table. Each user has one host and many graphs assigned to it. Each
host has unique username and password which they use to login. The hosts also have
some specific services subscribed by them and a bill cycle attached to them. The payment
each host makes is stored in the database with a downgrace, if any, which is decided by
the admin. The admin will be redirected to Admin Page, while others will be redirected to
user page. Sessions are being maintained for each user, so only each user can login to the
system from one account at a time on a device.
The admin will be adding new host and user details to the database of iNetMonitor and
at the same time to the database of cacti. The admin also sets the services subscriped to
by the users. Admin also sets the bill cycle according to the customer requirement. The
database of cacti has been used and PHP has been used to generate graph. SSH connection
has been maintained to execute commands in iNetManage to explicitly rebuild cache and
run poller. These methods helped us to add and generate graph of each template for each
user. The admin can also keep a track of the payment history of each customer and set the
downgrace, if any.
The customer side has a dashboard which gives details on the services subscribed to, the
payment history, the license expiration date and the graphs being maintained to track
their usage of the services. The explicit graph page has the details of all the graphs being
maintained. All the pages have been developed in PHP along with the necessary
formatting done by HTML, CSS and JavaScript.
The link to the website is http://208.50.229.71.
2. PROJECT MANAGEMENT
2.1 Implementation Language and Technology
The servers provided to my team had CentOS installed. They have been setup as per
requirements. The latest versions of Cacti, PHP, MySQL and Apache have been installed
and setup. One server, iNetManage has been configured with Cacti and polling other host
10. 10
machines. The other server, iNetMonitor consists of the user interface, displaying all the
graphs and admin panel.
All of the project has been developed in PHP with HTML, CSS and JavaScript elements
used for formatting. Inbuilt functions of Cacti has been used for creating and generating
graphs. MySQL database has been used for storing customer data. Linux commands and
scripts have been used to execute small scripts on the remote servers. RRD files have
modified to generate graphs with 1 minute polling average.
2.2 Design Processes
The website has been designed and coded in PHP with HTML, CSS and JavaScript
elements used for formatting and responsiveness. Bootstrap template has been used for
responsiveness in all devices.
Graphs have been created and generated on Cacti.
2.3 Testing
The website has been extensively tested using various host machines provided by “Data
Consultancy Corps”. It has also been tested using “live” customers. All of the tests have
yielded satisfactory results.
3. PROGRAM DESCRIPTION AND IMPLEMENTATION
3.1 Design Description & Working
My team members and I were provided with two servers - 208.50.229.71 and
208.50.229.72. The .71 server or the iNetMonitor is supposed to run the web UI
application. Whereas .72 server or the iNetManage is supposed to run the graphing engine
cacti. A separate database is created on iNetManage for handling user profiles, payment,
services and other information to reduce traffic load on iNetMonitor which will be already
busy in polling cache servers. The cacti server polls the monitored devices or the host
machines and generate graphs using inbuilt methods or SNMP protocol as required by
the graph. The web UI server fetches the graphs for the customers and embed the same
into a consolidated UI for the admin.
GUI is configured on the iNetMonitor server in the US VPN network. Each client has a
user account to the GUI and will have access to only their cache server’s database which
includes the Cacti link for all the reporting graphs and the tabs for troubleshooting and
basis configuration. Cacti Software has been configured on the iNetManage server in the
US VPN network. And the information will be fetched from the cache servers using SNMP
protocol.
11. 11
The GUI also has the admin panel which creates the users and hosts, and monitors their
usage and payment status. It also lists the services subscribed to by the users.
Step 1: Installed Apache web server, PHP, MySql on both iNetManage (208.50.229.72)
and iNetMonitor (208.50.229.71).
Step 2: Configured cacti software on iNetManage.
Step 3: Setup a web UI application on iNetMonitor using HTML, CSS, JavaScript and
PHP.
The web UI has 2 implementations:
a) Admin Page
b) User Page
Admin Page
This page has 3 sections:
a) Add new host: For each user, admin will add
a. One server IP address;
b. Description of server;
c. SNMP community string for that server;
d. SNMP version for that server;
e. Username and password to create unique profile for viewing graphs.
f. The billing cycle as subscribed.
b) Modify host: For each server desired graphs can be assigned from templates
from the list of given choices: (currently)
a. Load Average
b. Logged in Users
c. Memory Usage
d. Processes
e. Ping Latency
12. 12
f. Interface traffic (in/out using 64 bit counter)(only for cache servers
with SNMP version 2)
On this section, the admin can enlist the services the user subscribes to and
can also provide a changed password if the user so requires.
c) Payment Details: Admin can keep track of the payment history of each
customers and also their respective expiration dates. The admin can also generate
bills for each customer when necessary.
User Page
This page has 2 sections:
a) Dashboard: The user gets an overview of all the payment history, the services
subscribed, the sizing, the license expiration date and the graphs being generated
to keep track of their usage.
b) View Graphs: Each user can view all graphs, which are currently being
generated for their respective host servers to keep track of their usage of the
services. Further on clicking “View More”, they can get daily, weekly, monthly and
yearly graphs of that selected type of graph. All graphs generated on 1 minute
average.
3.2 Interface & Screenshots
The following are the screenshots taken from the various web pages developed. Test
values and live data have both been used for the screenshots.
Fig 1: Login Page
15. 15
3.3 Database and Server
The database has been setup in MySQL. Both the inbuilt Cacti database and the user created
databases has been setup and used for various purposes. The Cacti database has been set up
in iNetManage and the user created database has been setup in iNetMonitor.
Both the servers run on CentOS and has been configured individually so as to incorporate the
websites.
4. PROJECT SOURCE CODES
Admin Page:
<?PHP
session_start();
if($_SESSION['username']!='admin')
header("Location:index.PHP");
?>
<html class="no-js">
<head>
<title>Admin </title>
<!-- Bootstrap -->
<link href="bootstrap/css/bootstrap.css" rel="stylesheet" media="screen">
<link href="bootstrap/css/bootstrap-responsive.css" rel="stylesheet" media="screen">
<link href="assets/styles.css" rel="stylesheet" media="screen">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="vendors/modernizr-2.6.2-respond-1.1.0.min.js"></script>
<script src="js/jquery-1.11.3.js"></script>
</head>
<body vlink="black">
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-
collapse"> <span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="#">Quick Panel</a>
<div class="nav-collapse collapse">
<ul class="nav pull-right">
<li class="dropdown">
<a href="#" role="button" class="dropdown-toggle" data-
toggle="dropdown"> <i class="icon-user"></i> <?PHP echo $_SESSION['username']; ?> <i
class="caret"></i>
</a>
<ul class="dropdown-menu">
<li><a tabindex="-1" href="logout.PHP">Logout</a></li>
</ul>
</li>
</ul>
<ul class="nav">
46. 46
while($row_templates = $result_graph_templates->fetch_assoc()) {
$templateId=$row_templates["id"]; //graph_template_id
if($templateId==2) {
// Run a command that will probably write to stderr (unless you have a folder
named /hom)
$cmd="PHP -q /var/www/html/cacti-0.8.8f/cli/add_graphs.PHP --host-id=".$host." --
graph-type=ds --graph-template-id=2 --snmp-query-id=1 --snmp-query-type-id=14 --snmp-
field=ifOperStatus --snmp-value=Up";
$stream = ssh2_exec($connection, $cmd);
$errorStream = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR);
// Enable blocking for both streams
stream_set_blocking($errorStream, true);
stream_set_blocking($stream, true);
// Whichever of the two below commands is listed first will receive its
appropriate output. The second command receives nothing
$output= stream_get_contents($stream);
$error= stream_get_contents($errorStream);
// Close the streams
fclose($errorStream);
fclose($stream);
//echo strpos($output,'Error')."<br>";
//echo strpos($output,'ERROR')."<br>";
if ((strpos($output,'ERROR') !== false) || (strpos($output,'Error') !== false)) {
$flag = 2;
header("Location:graphSelect.PHP?flag=".$flag);
exit();
}
else {
$flag = 1;
header("Location:graphSelect.PHP?flag=".$flag);
exit();
}
}
else {
// Run a command that will probably write to stderr (unless you have a folder
named /hom)
$cmd="PHP -q /var/www/html/cacti-0.8.8f/cli/add_graphs.PHP --host-id=".$host." --
graph-type=cg --graph-template-id=".$templateId;
$stream = ssh2_exec($connection, $cmd);
$errorStream = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR);
// Enable blocking for both streams
stream_set_blocking($errorStream, true);
stream_set_blocking($stream, true);
47. 47
// Whichever of the two below commands is listed first will receive its
appropriate output. The second command receives nothing
$output= stream_get_contents($stream);
$error= stream_get_contents($errorStream);
// Close the streams
fclose($errorStream);
fclose($stream);
if ((strpos($output,'ERROR') !== false) || (strpos($output,'Error') !== false)) {
$flag = 2;
header("Location:graphSelect.PHP?flag=".$flag);
exit();
}
else {
$flag = 1;
header("Location:graphSelect.PHP?flag=".$flag);
exit();
}
}
echo "<br>"."Successful";
exec ('success.PHP)');
?>
Login.PHP:
<?PHP
$con=mysqli_connect(DB_HOST,DB_USER,DB_PASSWORD);
$db=mysqli_select_db($con,DB_NAME) or die("Failed to connect to MySQL: " .
mysqli_error($con));
session_start();
session_name("iNetManage");
function SignIn($con)
{
//starting the session for user profile page
if(!empty($_POST['login_username']))
//checking the 'user' name which is from Sign-In.html, is it empty or have some text
{
$user=$_POST['login_username'];
$pass=$_POST['login_password'];
$query = mysqli_query($con, "SELECT * FROM users WHERE uname = '".$user. "' AND pass
='".$pass."'") or die(mysqli_error($con));
$row = mysqli_fetch_array($query);
if((!empty($row['uname']) AND !empty($row['pass'])) )
{
$_SESSION['username'] = $row['uname'];
$_SESSION['success']='success';
if($row['uname']=='admin')
header("Location:admin.PHP");
else
header("Location:dashboard.PHP");
}
else {
49. 49
5. CONCLUSION
5.1 What Has Been Done
We have successfully implemented the website according to the above mentioned
specifications within the duration of the internship.
5.2 Contribution and Role in the Project
All the server side configurations on both the provided server were done by me,
including setting up the Cacti software on the server side used for polling. The required
Apache, PHP, MySQL versions were also configured. I was also responsible for developing
the front end web pages with help from my team members.
5.3 What I Have Learnt
When I started the internship, I was not very well accustomed to using Linux and
its various commands. Cacti and SNMP protocol were also completely new to me.
Throughout the duration of my internship, I got to learn and apply all of these techniques
to setup the Linux servers and work on them, successfully generate graphs using Cacti
and build the website. While delivering the website within stipulated deadlines, I have
learnt time management and team work.
5.4 What I Would Do Differently In Future
In future I would definitely use PHP and Linux machines more often. Even though
the SNMP protocol has been used here to monitor remote servers and generate graphs, I
would also like to explore other possible methods, like using the MRTG software for the
same. The Webmin interface which has also been introduced to us, albeit briefly, has
motivated to seek further uses for it in the future.
50. 50
BIBLIOGRAPHY
BOOKS:
1. The Cacti Manual.
2. The PHP Manual.
3. Cacti 0.8 Beginner's Guide By Thomas Urban.
WEBSITES:
4. www.stackoverflow.com
5. www.w3schools.com
6. www.tutorialspoint.com
7. forums.cacti.net
8. https://www.digitalocean.com/community/tutorials/how-to-install-linux-
apache-mysql-PHP-lamp-stack-on-centos-6
9. www.codeacademy.com