SlideShare a Scribd company logo
1 of 50
Download to read offline
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
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
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
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
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
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
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
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
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
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
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
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
13
Fig 2: Admin Panel – First Page
Fig 3: Modify Host (Admin Side)
Fig 4: Modify Host Part 2 (Admin Side)
14
Fig 5: Payment Details (Admin Side)
Fig 6: Dashboard (Client Side)
Fig 7: Graph Page (Client Side)
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">
16
<li><a href="#">Dashboard</a></li>
<li class="dropdown">
<a href="#" data-toggle="dropdown" class="dropdown-
toggle">Settings <b class="caret"></b></a>
<ul class="dropdown-menu" id="menu1">
<li><a href="#">Change Theme</a></li>
</ul>
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span3" id="sidebar">
<ul class="nav nav-list bs-docs-sidenav nav-collapse collapse">
<li class="active">
<a href="#"> Create New Host</a>
</li>
<li><a href="graphSelect.PHP"> Modify Host</a></li>
<li><a href="hostDetails.PHP"> Payment Details</a></li>
</ul>
</div>
<!--/span-->
<div class="span9" id="content">
<?PHP
if($_SESSION['success']=='success'){
echo '<div class="row-fluid">';
echo '<div class="alert alert-success">';
echo '<button type="button" class="close" data-
dismiss="alert">&times;</button>';
echo '<h4>Success</h4>';
echo 'You have successfully logged in.';
echo '</div>';
echo '</div>';
$_SESSION['success']='';
}
if($_SESSION['uiInsert']=='success'){
echo '<div class="row-fluid">';
echo '<div class="alert alert-success alert-block">';
echo '<button type="button" class="close" data-
dismiss="alert">&times;</button>';
echo '<h4 class="alert-heading">Success</h4>';
echo 'New host has been successfully added.';
echo '</div>';
echo'</div>';
$_SESSION['uiInsert']=='';
}
if($_SESSION['uiInsert']=='error'){
echo '<div class="row-fluid">';
echo '<div class="alert alert-error alert-block">';
echo '<button type="button" class="close" data-
dismiss="alert">&times;</button>';
echo '<h4 class="alert-heading">Failed</h4>';
echo 'Adding new host failed.';
echo '</div>';
17
echo'</div>';
$_SESSION['uiInsert']=='';
}
?>
<div class="row-fluid">
<!-- block -->
<div class="block">
<div class="navbar navbar-inner block-header">
<div class="muted pull-left">Add Host</div>
</div>
<div class="block-content collapse in">
<div class="span12">
<form class="form-horizontal" action="uiInsert.PHP"
method="post">
<fieldset>
<legend>Host Details</legend>
<div class="control-group">
<label class="control-label" for="focusedInput">Host IP
Address:</label>
<div class="controls">
<input class="input-xlarge focused" id="focusedInput"
type="text" name="hostname" placeholder="IP Address">
</div>
</div>
<div class="control-group">
<label class="control-label"
for="focusedInput">Description:</label>
<div class="controls">
<input class="input-xlarge focused" id="focusedInput"
type="text" name="description" placeholder="Enter Description">
</div>
</div>
<div class="control-group">
<label class="control-label" for="focusedInput">SNMP
Community String:</label>
<div class="controls">
<input class="input-xlarge focused" id="focusedInput"
type="text" name="community" placeholder="Community String">
</div>
</div>
<legend>User Details</legend>
<div class="control-group">
<label class="control-label"
for="focusedInput">Username:</label>
<div class="controls">
<input class="input-xlarge focused" id="focusedInput"
type="text" name="login_username" placeholder="Username">
</div>
</div>
<div class="control-group">
<label class="control-label"
for="focusedInput">Password:</label>
<div class="controls">
<input class="input-xlarge focused" id="focusedInput"
name= "login_password" type="password">
</div>
</div>
<div class="control-group success">
18
<label class="control-label" for="selectError">Billing
Cycle:</label>
<div class="controls">
<select id="selectError" name="billing_cycle">
<option value="0">1st of the Month</option>
<option value="1">15th of the Month</option>
</select>
</div>
</div>
<div class="form-actions">
<button type="submit" name ="submit" class="btn btn-
primary">Create</button>
<button type="reset" class="btn">Reset</button>
</div>
</fieldset>
</form>
</div>
</div>
</div>
<!-- /block -->
</div>
</div>
</div>
</div>
<footer>
<div class="hr"></div>
<p style="margin:5px;color:#333333;">&copy; X-Verse</p>
</footer>
</div>
<!--/.fluid-container-->
<script src="vendors/jquery-1.9.1.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="assets/scripts.js"></script>
<link href="vendors/uniform.default.css" rel="stylesheet" media="screen">
<link href="vendors/chosen.min.css" rel="stylesheet" media="screen">
<script src="vendors/jquery.uniform.min.js"></script>
<script src="vendors/chosen.jquery.min.js"></script>
<script src="vendors/wizard/jquery.bootstrap.wizard.min.js"></script>
<script type="text/javascript" src="vendors/jquery-
validation/dist/jquery.validate.min.js"></script>
<script src="assets/form-validation.js"></script>
<script>
$(function() {
});
</script>
</body>
</html>
Modify Host:
<?PHP
session_start();
if(!isset($_SESSION['username']) || $_SESSION['username']=='admin')
19
header("Location:index.PHP");
?>
<html class="no-js">
<head>
<title>Graph Page</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="vendors/easypiechart/jquery.easy-pie-chart.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="bootstrap/js/bootstrap.min.js"></script>
<script src="js/jquery-1.11.3.js"></script>
<script src="assets/scripts.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">
<li><a href="dashboard.PHP">Dashboard</a></li>
<li class="dropdown">
<a href="#" data-toggle="dropdown" class="dropdown-
toggle">Settings <b class="caret"></b></a>
<ul class="dropdown-menu" id="menu1">
<li><a href="#">Change Theme</a></li>
</ul>
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
20
<div class="span3" id="sidebar">
<ul class="nav nav-list bs-docs-sidenav nav-collapse collapse">
<li><a href="dashboard.PHP"> Dashboard</a></li>
<li class="active"><a href="graPHPage.PHP"> Graph</a></li>
<!-- <li><a href="system.PHP"> System</a></li> -->
</ul>
</div>
<!--/span-->
<div class="span9" id="content">
<div class="row-fluid">
<div class="alert alert-success">
<button type="button"
class="close" data-dismiss="alert">&times;</button>
<h4>Success</h4>
Graphs fetched successfully.
</div>
<div class="navbar">
<div class="navbar-inner">
<ul class="breadcrumb">
<i class="icon-chevron-left hide-sidebar"><a href='#'
title="Hide Sidebar" rel='tooltip'>&nbsp;</a></i>
<i class="icon-chevron-right show-sidebar"
style="display:none;"><a href='#' title="Show Sidebar" rel='tooltip'>&nbsp;</a></i>
<li><a href="dashboard.PHP">Dashboard</a> <span
class="divider"><span class="divider">/</span></li>
<li><a href="#">Graphs</a></li>
</ul>
</div>
</div>
</div>
<?PHP
$id=$_GET["id"];
?>
<div class="row-fluid">
<div class="block">
<div class="navbar navbar-inner block-header">
<div class="muted pull-left">Hourly</div>
</div>
<div class="block-content collapse in">
<div class="span12">
<img
src="http://208.50.229.72:2080/cacti/graph_image.PHP?local_graph_id=<?PHP echo $id
?>&amp;rra_id=5&amp;graph_height=120&amp;graph_width=500&amp;title_font_size=10&amp;view_type=
tree&amp;" alt="graph" style="width:50%; height:30%;">
</div>
</div>
</div>
</div>
<div class="row-fluid">
<div class="block">
<div class="navbar navbar-inner block-header">
<div class="muted pull-left">Daily</div>
</div>
<div class="block-content collapse in">
<div class="span12">
21
<img
src="http://208.50.229.72:2080/cacti/graph_image.PHP?local_graph_id=<?PHP echo $id
?>&amp;rra_id=1&amp;graph_height=120&amp;graph_width=500&amp;title_font_size=10&amp;view_type=
tree&amp;" alt="graph" style="width:50%; height:30%;">
</div>
</div>
</div>
</div>
<div class="row-fluid">
<div class="block">
<div class="navbar navbar-inner block-header">
<div class="muted pull-left">Weekly</div>
</div>
<div class="block-content collapse in">
<div class="span12">
<img
src="http://208.50.229.72:2080/cacti/graph_image.PHP?local_graph_id=<?PHP echo $id
?>&amp;rra_id=2&amp;graph_height=120&amp;graph_width=500&amp;title_font_size=10&amp;view_type=
tree&amp;" alt="graph" style="width:50%; height:30%;">
</div>
</div>
</div>
</div>
<div class="row-fluid">
<div class="block">
<div class="navbar navbar-inner block-header">
<div class="muted pull-left">Monthly</div>
</div>
<div class="block-content collapse in">
<div class="span12">
<img
src="http://208.50.229.72:2080/cacti/graph_image.PHP?local_graph_id=<?PHP echo $id
?>&amp;rra_id=3&amp;graph_height=120&amp;graph_width=500&amp;title_font_size=10&amp;view_type=
tree&amp;" alt="graph" style="width:50%; height:30%;">
</div>
</div>
</div>
</div>
<div class="row-fluid">
<div class="block">
<div class="navbar navbar-inner block-header">
<div class="muted pull-left">Yearly</div>
</div>
<div class="block-content collapse in">
<div class="span12">
<img
src="http://208.50.229.72:2080/cacti/graph_image.PHP?local_graph_id=<?PHP echo $id
?>&amp;rra_id=3&amp;graph_height=120&amp;graph_width=500&amp;title_font_size=10&amp;view_type=
tree&amp;" alt="graph" style="width:50%; height:30%;">
</div>
</div>
</div>
</div>
</div>
22
</div>
</div>
<footer>
<div class="hr"></div>
<p style="margin:5px;color:#333333;">&copy; X-Verse</p>
</footer>
</div>
<!--/.fluid-container-->
<script src="vendors/jquery-1.9.1.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="assets/scripts.js"></script>
</body>
</html>
Payment Details:
<?PHP
session_start();
if($_SESSION['username']!='admin')
header("Location:index.PHP");
?>
<html class="no-js">
<head>
<title>Payment Details </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>
23
</li>
</ul>
<ul class="nav">
<li><a href="#">Dashboard</a></li>
<li class="dropdown">
<a href="#" data-toggle="dropdown" class="dropdown-
toggle">Settings <b class="caret"></b></a>
<ul class="dropdown-menu" id="menu1">
<li><a href="#">Change Theme</a></li>
</ul>
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span3" id="sidebar">
<ul class="nav nav-list bs-docs-sidenav nav-collapse collapse">
<li>
<a href="admin.PHP"> Create New Host</a>
</li>
<li> <a href="graphSelect.PHP"> Modify Host</a></li>
<li class="active"><a href="#"> Payment Details</a></li>
</ul>
</div>
<!--/span-->
<div class="span9" id="content">
<div class="row-fluid">
<!-- block -->
<div class="block">
<div class="navbar navbar-inner block-header">
<div class="muted pull-left">Host Payment Details</div>
</div>
<div class="block-content collapse in">
<div class="span12">
<form class="form-horizontal" action="" method="post">
<fieldset>
<legend>Select Host</legend>
<div class="control-group success">
<label class="control-label" for="selectError">Select
Host:</label>
<div class="controls">
<select id="selectError" name="uname">
<option></option>
<?PHP
// Create connection
$conn71 = new mysqli($servername, $username,
$password, $dbname);
// Check connection
if ($conn71->connect_error) {
echo "Connection failed: " . $connection-
>connect_error;
}
$sql = $conn71->query( "SELECT uname FROM
users" ) or die(mysqli_error($conn71));
while($row=$sql->fetch_assoc()) {
if($row["uname"]!='admin'){
24
$option_div="<option
value=".$row['uname'];
if($_POST['uname'] == $row['uname'])
$option_div = $option_div.'
selected="selected">'.$row['uname'].'</option>';
else
$option_div =
$option_div.'>'.$row['uname'].'</option>';
echo $option_div;
}
}
?>
</select> &nbsp;&nbsp;
<button type="submit" name ="getGraphs" class="btn">
<i class="icon-eye-open"></i> View
</button>
</div>
</div>
</fieldset>
</form>
<!-- GET GRAPHS -->
<?PHP
if (isset($_POST['getGraphs'])) {
$username = $_POST['uname'];
$sql="select hostid from users where
uname='".$username."'";
$result = $conn71->query($sql);
$row = $result->fetch_assoc();
$hostid=$row['hostid'];
echo '<div class="span12">';
echo '<table class="table table-striped">';
echo'<thead>';
echo '<tr colspan="2"><th>Payment
Record:</th></tr>';
$sql="select * from host where hostid=".$hostid;
$result = $conn71->query($sql);
$flag = $result->num_rows;
$row = $result->fetch_assoc();
$bill_cycle = (int)$row['bill_cycle'];
$m=date("n");
$y=date("Y");
$sql="select * from payment where
hostid=".$row["hostid"]." and month=".$m." and year =".$y;
$sql_result=$conn71->query($sql);
$r=$sql_result->num_rows;
$sql_row=$sql_result->fetch_assoc();
if($r>0){
$date=$sql_row["day"]."/".$sql_row["month"]."/".$sql_row["year"];
}
else {
$m=$m-1;
if($m==0) {
$m=12;
$y=$y-1;
}
$sql="select * from payment where
hostid=".$row["hostid"]." and month=". $m." and year =". $y;
25
$sql_result=$conn71->query($sql);
$r=$sql_result->num_rows;
$sql_row=$sql_result->fetch_assoc();
if($r>0) {
$date=$sql_row["day"]."/".$sql_row["month"]."/".$sql_row["year"];
}
else
$date = "License expired";
}
echo '<tbody>';
echo '<tr>';
echo '<td>Last Payment Date:</td>';
if($flag>0) {
echo '<td>'.$date.'</td>';
} else {
echo '<td>Not Paid</td>';
}
echo '</tr>';
echo '<tr>';
echo '<td>Billed Amount:</td>';
if($flag>0 && $r>0) {
echo '<td>Rs.
'.$sql_row["bill_amt"].'</td>';
} else {
echo '<td>Not Paid</td>';
}
echo '</tr>';
echo '<tr>';
echo '<td>Next Billing Date:</td>';
if($flag>0 && $r>0) {
$sql="select * from host where
hostid=".$hostid;
$result = $conn71->query($sql);
$r = $result->num_rows;
$row = $result->fetch_assoc();
$bill_cycle = (int)$row['bill_cycle'];
if($bill_cycle == 0)
{
$bill_day = 23;
}
else if($bill_cycle == 1)
{
$bill_day = 7;
}
$m=$m+1;
if($m==13)
{
$m=1;
$y=$y+1;
}
$str=$bill_day."/".$m."/".$y;
if($r>0){
echo '<td>'.$str.'</td>';
}else echo '<td>"Not Paid"</td>';
} else {
echo '<td>Not Paid</td>';
}
echo '</tr>';
echo '<tr>';
26
echo '<td>License Expiry:</td>';
if($flag>0 && $r>0) {
if($bill_cycle == 0)
{
$exp_day = 1;
$m=$m+1;
if($m==13)
{
$m=1;
$y=$y+1;
}
}
else if($bill_cycle == 1)
{
$exp_day = 15;
}
$str=$exp_day."/".$m."/".$y;
if($r>0){
echo '<td>'.$str.'</td>';
}
else echo '<td>"Not Paid"</td>';
} else {
echo '<td>Not Paid</td>';
}
echo '</tr>';
echo '</tbody>';
echo '</table>';
echo '<table class="table table-striped">';
echo '<thead>';
echo '<tr colspan="2"><th>Payment
History:</th></tr>';
echo
'<tr><th>Date</th><th>Amount</th></tr>';
echo '</thead>';
echo '<tbody>';
$sql="select * from payment where
hostid=".$row["hostid"];
$result = $conn71->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$date=$row["day"]."/".$row["month"]."/".$row["year"];
echo '<tr>';
echo '<td>'.$date.'</td>';
echo '<td>Rs.
'.$row["bill_amt"].'</td>';
echo '</tr>';
}
}
echo '</tbody>';
echo '</table>';
echo '</div>';
echo '<form class="form-horizontal" action="?"
method="post">';
echo '<fieldset>';
27
echo '<legend>Pay Bill</legend>';
echo '<div class="control-group success">';
echo '<label class="control-label"
for="selectError">Select Graph:</label>';
echo '<div class="controls">';
$hidden_input = '<input type="hidden"
name="uname" value="'.$username.'"/>';
echo
$hidden_input;
echo '<select id="selectError" name="graphid"
value="'.$record['graphid'].'">';
echo '<option></option>';
echo '<option selected="selected">Interface -
Traffic (bits/sec)</option>';
echo '</select> &nbsp;&nbsp;';
echo '<button type="submit" name
="getGraphHistory" class="btn">';
echo '<i class="icon-pencil"></i> Generate
Bill';
echo '</button>';
echo '</div>';
echo '</div>';
echo '</fieldset>';
echo '</form>';
}
//GET GRAPH HISTORY
else if (isset($_POST['getGraphHistory'])){
$username = $_POST['uname'];
$sql="select hostid from users where
uname='".$username."'";
$result = $conn71->query($sql);
$row = $result->fetch_assoc();
$hostid = (int)$row['hostid'];
$sql="select bill_cycle from host where
hostid=".hostid;
$result = $conn71-
>query($sql);
$row = $result->fetch_assoc();
$bill_cycle = $row['bill_cycle'];
echo '<div class="span12">';
echo '<table class="table table-striped">';
echo'<thead>';
echo '<tr colspan="2"><th>Payment
Record:</th></tr>';
$sql="select * from payment where
hostid=".$hostid;
$result = $conn71->query($sql);
$flag = $result->num_rows;
$row = $result->fetch_assoc();
echo '<tbody>';
echo '<tr>';
echo '<td>Last Payment Date:</td>';
if($flag > 0) {
echo
'<td>'.$row["day"].'/'.$row["month"].'/'.$row["year"].'</td>';
} else {
echo '<td>Not Paid</td>';
}
echo '</tr>';
28
echo '<tr>';
echo
'<td>Billed Amount:</td>';
if($flag > 0) {
echo '<td>Rs.
'.$row["bill_amt"].'</td>';
} else {
echo '<td>Not Paid</td>';
}
echo '</tr>';
echo '<tr>';
echo
'<td>Next Billing Date:</td>';
if($flag > 0) {
$mn =
(int)($row["month"])+1;
$yr = (int)($row["year"]);
if($mn>12) {
$mn = $mn - 12;
$yr = $yr + 1;
}
echo
'<td>7/'.$mn.'/'.$yr.'</td>';
} else {
echo '<td>Not Paid</td>';
}
echo '</tr>';
echo '<tr>';
echo
'<td>License Expiry:</td>';
if($flag >
0) {
$mn =
(int)($row["month"])+1;
$yr = (int)($row["year"]);
if($mn>12) {
$mn = $mn - 12;
$yr = $yr + 1;
}
echo
'<td>15/'.$mn.'/'.$yr.'</td>';
} else {
echo '<td>Not Paid</td>';
}
echo '</tr>';
echo '</tbody>';
echo '</table>';
echo '</div>';
echo '<form class="form-horizontal" action="?"
method="post">';
echo '<fieldset>';
echo '<legend>Bill Details</legend>';
echo '<div class="control-group success">';
echo '<label class="control-label"
for="selectError">Select Graph:</label>';
echo '<div class="controls">';
$hidden_input = '<input type="hidden"
name="uname" value="'.$username.'"/>';
echo
$hidden_input;
29
echo '<select id="selectError" name="graphid"
value="'.$record['graphid'].'">';
echo '<option selected="selected">Interface -
Traffic (bits/sec)</option>';
echo '</select> &nbsp;&nbsp;';
echo '<button type="submit" name
="getGraphHistory" class="btn">';
echo '<i class="icon-pencil"></i> Generate
Bill';
echo '</button>';
echo '</div>';
echo '</div>';
echo '</fieldset>';
echo '</form>';
echo '<div class="span12">';
echo '<form class="form-horizontal" action="?"
method="post">';
$hidden_input = '<input type="hidden" name="uname"
value="'.$username.'"/>';
echo $hidden_input;
echo '<table class="table">';
echo '<tbody>';
echo '<tr>';
echo '<td>Payment Date:</td>';
echo '<td>';
echo '<input type="text"
class="datepicker" name="pay_date" id="date01" value=""/>';
echo '</div>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td>Payment Amount:</td>';
echo '<td>';
echo '<input type="text" name="pay_amt"
value="" />';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td>Downtime Credit:</td>';
echo '<td>';
echo '<select id="selectError"
name="credit">';
echo '<option>0</option>';
echo '<option>1</option>';
echo '<option>2</option>';
echo '<option>3</option>';
echo '<option>4</option>';
echo '<option>5</option>';
echo '<option>6</option>';
echo '<option>7</option>';
echo '<option>8</option>';
echo '<option>9</option>';
echo '<option>10</option>';
echo '<option>11</option>';
echo '<option>12</option>';
echo '<option>13</option>';
echo '<option>14</option>';
echo '<option>15</option>';
echo '<option>16</option>';
echo '<option>17</option>';
30
echo '<option>18</option>';
echo '<option>19</option>';
echo '<option>20</option>';
echo '<option>21</option>';
echo '<option>22</option>';
echo '<option>23</option>';
echo '<option>24</option>';
echo '<option>25</option>';
echo '<option>26</option>';
echo '<option>27</option>';
echo '<option>28</option>';
echo '<option>29</option>';
echo '<option>30</option>';
echo '</select>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td colspan=2>';
echo '<button type="submit" name
="billSubmit" class="btn btn-primary">';
echo '<i class="icon-ok icon-
white"></i> Submit';
echo '</button>';
echo '</td>';
echo '</tr>';
echo '</tbody>';
echo '</table>';
echo '</form>';
echo '</div>';
}
else if(isset($_POST['billSubmit'])) {
$username = $_POST['uname'];
$sql="select hostid from users where
uname='".$username."'";
$result = $conn71->query($sql);
$row = $result->fetch_assoc();
$hostid = $row['hostid'];
$date = $_POST['pay_date'];
$amt = $_POST['pay_amt'];
$credit=$_POST['credit'];
$date = explode('/', $date);
$sql = 'INSERT INTO payment VALUES
(0,'.$row['hostid'].','.(int)$date[1].','.(int)$date[0].','.(int)$date[2].','.(int)$amt.','.(i
nt)$credit.')';
$res = $conn71->query($sql);
}
?>
</div>
</div>
</div>
<!-- /block -->
</div>
</div>
</div>
</div>
<footer>
31
<div class="hr"></div>
<p style="margin:5px;color:#333333;">&copy; X-Verse</p>
</footer>
</div>
<!--/.fluid-container-->
<script src="vendors/jquery-1.9.1.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="assets/scripts.js"></script>
<link href="vendors/datepicker.css" rel="stylesheet" media="screen">
<link href="vendors/uniform.default.css" rel="stylesheet" media="screen">
<link href="vendors/chosen.min.css" rel="stylesheet" media="screen">
<script src="vendors/jquery.uniform.min.js"></script>
<script src="vendors/chosen.jquery.min.js"></script>
<script src="vendors/wizard/jquery.bootstrap.wizard.min.js"></script>
<script type="text/javascript" src="vendors/jquery-
validation/dist/jquery.validate.min.js"></script>
<script src="assets/form-validation.js"></script>
<script src="vendors/bootstrap-datepicker.js"></script>
<script type="text/javascript">
$(function() {
$(".datepicker").datepicker();
});
</script>
<style>
div.legend {
display: block;
padding-left: 2px;
padding-right: 2px;
border: none;
}
</style>
</body>
</html>
Dashboard:
<?PHP
session_start();
if(!isset($_SESSION['username']) || $_SESSION['username']=='admin')
header("Location:index.PHP");
?>
<html class="no-js">
<head>
<title>Dashboard </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="vendors/easypiechart/jquery.easy-pie-chart.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>
32
<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">
<li class="active"><a href="#">Dashboard</a></li>
<li class="dropdown">
<a href="#" data-toggle="dropdown" class="dropdown-
toggle">Settings <b class="caret"></b></a>
<ul class="dropdown-menu" id="menu1">
<li><a href="#">Change Theme</a></li>
</ul>
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span3" id="sidebar">
<ul class="nav nav-list bs-docs-sidenav nav-collapse collapse">
<li class="active">
<a href="#"> Dashboard</a>
</li>
<li><a href="graPHPage.PHP"> Graphs</a></li>
<!--<li ><a href="system.PHP"> System</a></li>-->
</ul>
</div>
<?PHP
$user=$_SESSION['username'];
// Create connection
$conn71 = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn71->connect_error) {
echo "Connection failed: " . $connection->connect_error;
}
$query = mysqli_query($conn71, "SELECT * FROM users WHERE uname =
'".$user."'" ) or die(mysqli_error($conn71));
33
$row = mysqli_fetch_array($query);
$sql = "SELECT * FROM host where hostid=".$row["hostid"];
$result = $conn71->query($sql);
if ($result->num_rows > 0) {
// output data of each row
$host_row = $result->fetch_assoc() ;
$hostname = $host_row["hostname"];
$community = $host_row["snmp_community"];
$version = $host_row["snmp_version"];
$description = $host_row["description"];
}
if($version==1) {
//snmpget -v 1 -c public 103.43.80.18 sysUpTime.0
$cmd="snmpget -v 1 -c ".$community." ".$hostname." sysUpTime.0";
}
if($version==2) {
$cmd="snmpget -v 2c -c ".$community." ".$hostname." sysUpTime.0";
}
// Run a command that will probably write to stderr (unless you have a
folder named /hom)
$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);
// echo "Error: " . stream_get_contents($errorStream);
$out = stream_get_contents($stream);
// Close the streams
fclose($errorStream);
fclose($stream);
$out = substr($out, (strrpos($out, ')', -1) + 2));
$token = strtok($out, ":");
$uptime = $token . " hours, ";
$token = strtok(":");
$uptime = $uptime . $token . " minutes.";
?>
<!--/span-->
<div class="span9" id="content">
<div class="row-fluid">
<?PHP
if($_SESSION['success']=='success') {
echo '<div class="alert alert-success">';
echo '<button type="button" class="close" data-
dismiss="alert">&times;</button>';
echo '<h4>Success</h4>';
echo 'You have successfully logged in.';
echo '</div>';
$_SESSION['success']='';
}
?>
<div class="navbar">
34
<div class="navbar-inner">
<ul class="breadcrumb">
<i class="icon-chevron-left hide-sidebar"><a href='#'
title="Hide Sidebar" rel='tooltip'>&nbsp;</a></i>
<i class="icon-chevron-right show-sidebar"
style="display:none;"><a href='#' title="Show Sidebar" rel='tooltip'>&nbsp;</a></i>
<li><a href="#">Dashboard</a></li>
</ul>
</div>
</div>
</div>
<div class="row-fluid">
<div class="row-fluid">
<!-- block -->
<!--<div class="block">
<div class="navbar navbar-inner block-header">
<div class="muted pull-left">Service Status</div>
</div>
<div class="block-content collapse in">
<div class="span12">
<form class="form-horizontal" action="#"
method="post">
<fieldset>
<legend>Status</legend>
<div class="well" style="margin-top:30px;">
<?PHP
$hid=$row["hostid"];
$user=$_SESSION['username'];
// Create connection
$conn71 = new mysqli($servername, $username,
$password, $dbname);
// Check connection
if ($conn71->connect_error) {
echo "Connection failed: " . $connection-
>connect_error;
}
$m=date("n");
$y=date("Y");
/*$sql="select * from payment where
hostid=".$hid." and month=".$m." and year =".$y;
$sql_result=$conn71->query($sql);
$r=$sql_result->num_rows;
$sql_row=$sql_result->fetch_assoc();
if($r>0)
echo '<button type="submit" class="btn
btn-large btn-block btn-success" name="restart">Restart Services</button>';
else {
$m=$m-1;
if($m==0) {
$m=12;
$y=$y-1;
}
35
$sql="select * from payment where
hostid=".$hid." and month=".$m." and year =".$y;
$sql_result=$conn71->query($sql);
$r=$sql_result->num_rows;
$sql_row=$sql_result->fetch_assoc();
if($r>0)
echo '<button type="submit" class="btn
btn-large btn-block btn-success" name="restart">Restart Services</button>';
else
echo '<button type="submit" class="btn
btn-large btn-block btn-info" name="restart" disabled>Restart Services</button>';
}*/
?>
</div>
<fieldset>
</form>
</div>
</div>
</div>-->
<!-- /block -->
</div>
<div class="row-fluid">
<!-- block -->
<div class="block">
<div class="navbar navbar-inner block-header">
<div class="muted pull-left">Details</div>
</div>
<div class="block-content collapse in">
<div class="span12">
<table class="table table-striped">
<thead>
<tr colspan=2>
<th>General Details</td>
</tr>
</thead>
<tbody>
<tr>
<td>Device Name:</td>
<td><?PHP echo $description ?></td>
</tr>
<tr>
<td>IP Address:</td>
<td><?PHP echo $hostname ?></td>
</tr>
<tr>
<td>Device Up Time:</td>
<td><?PHP echo $uptime ?></td>
</tr>
<tr>
<td>Sizing:</td>
<td>
<?PHP
$sql = 'SELECT sizing FROM host WHERE
hostid='.$row["hostid"];
$result=$conn71->query($sql);
$r=$result->fetch_assoc();
if((int)$r['sizing'] == 1)
{
$sizing = 'I - STM';
36
}
else if((int)$r['sizing'] == 2)
{
$sizing = 'II - STM';
}
else if((int)$r['sizing'] == 3)
{
$sizing = 'III - STM';
}
else if((int)$r['sizing'] == 4)
{
$sizing = 'IV - STM';
}
else if((int)$r['sizing'] == 5)
{
$sizing = 'V - STM';
}
echo $sizing;
?>
</td>
</tr>
</tbody>
</table>
<table class="table table-striped">
<thead>
<tr colspan=2>
<th>Payment Details</td>
</tr>
</thead>
<tbody>
<tr>
<td>Last Payment Date:</td>
<td>
<?PHP
$m=date("n");
$y=date("Y");
$sql="select * from payment where
hostid=".$row["hostid"]." and month=".$m." and year =".$y;
$sql_result=$conn71->query($sql);
$r=$sql_result->num_rows;
$sql_row=$sql_result->fetch_assoc();
if($r>0){
$date=$sql_row["day"]."/".$sql_row["month"]."/".$sql_row["year"];
echo $date;
}
else {
$m=$m-1;
if($m==0) {
$m=12;
$y=$y-1;
}
$sql="select * from payment where
hostid=".$row["hostid"]." and month=".$m." and year =".$y;
$sql_result=$conn71->query($sql);
$r=$sql_result->num_rows;
$sql_row=$sql_result->fetch_assoc();
if($r>0){
37
$date=$sql_row["day"]."/".$sql_row["month"]."/".$sql_row["year"];
echo $date;
}
else
echo "License expired";
}
?>
</td>
</tr>
<tr>
<td>Paid Bill Amount:</td>
<td>
<?PHP
if($r>0){
echo 'Rs. ' . $sql_row["bill_amt"];
}
else echo "License expired";
?>
</td>
</tr>
<tr>
<td>Next Billing Date:</td>
<td>
<?PHP
$sql="select * from host where
hostid=".$row["hostid"];
$result = $conn71->query($sql);
$flag = $result->num_rows;
$row = $result->fetch_assoc();
$bill_cycle = (int)$row['bill_cycle'];
if($bill_cycle == 0) {
$bill_day = 23;
}
else if($bill_cycle == 1) {
$bill_day = 7;
}
$m=$m+1;
if($m==13) {
$m=1;
$y=$y+1;
}
$str=$bill_day."/".$m."/".$y;
if($r>0) {
echo $str;
}
else
echo "Not Paid";
?>
</td>
</tr>
<tr>
<td>License Expiry:</td>
<td>
<?PHP
if($bill_cycle == 0)
{
$exp_day = 1;
$m=$m+1;
if($m==13)
{
38
$m=1;
$y=$y+1;
}
}
else if($bill_cycle == 1)
{
$exp_day = 15;
}
$str=$exp_day."/".$m."/".$y;
if($r>0){
echo $str;
}
else echo "Not Paid";
?>
</td>
</tr>
<tr>
<td>Downtime Credit:</td>
<td>
<?PHP
$sql = 'SELECT downgrace FROM payment
WHERE hostid='.$row["hostid"];
$result=$conn71->query($sql);
$r=$result->fetch_assoc();
echo (int)$r['downgrace']. ' days';
?>
</td>
</tr>
</tbody>
</table>
<br>
<table class="table table-striped">
<thead>
<tr>
<th>Services Enlisted</td>
</tr>
</thead>
<tbody>
<tr>
<td>
<?PHP
$sql="select * from host where
hostid=".$row["hostid"];
$sql_result=$conn71->query($sql);
$sql_row=$sql_result->fetch_assoc();
$flag = 0;
if($sql_row['service_http']==1)
{
$flag = 1;
echo 'HTTP <br>';
}
if($sql_row['service_p2p']==1)
{
$flag = 1;
echo 'P2P <br>';
}
if($sql_row['service_dns_cache']==1)
{
$flag = 1;
39
echo 'DNS Caching <br>';
}
if($sql_row['service_antispam']==1)
{
$flag = 1;
echo 'Anti-Spam <br>';
}
if($sql_row['service_url_filter']==1)
{
$flag = 1;
echo 'URL Filtering <br>';
}
if($flag==0)
if($sql_row['service_url_filter'] +$sql_row['service_antispam'] +$sql_row['service_dns_cache']
+$sql_row['service_p2p'] +$sql_row['service_http'] ==0)
echo "No
service";
?>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<!-- /block -->
</div>
<div class="row-fluid">
<!-- block -->
<div class="block">
<div class="navbar navbar-inner block-header">
<div class="muted pull-left">Graphs</div>
<div class="pull-right">
<a href="graPHPage.PHP"><span class="badge badge-
info">View More</span></a>
</div>
</div>
<div class="block-content collapse in">
<div class="span12">
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<?PHP
// Create connection
$conn72 = new mysqli($servername, $username,
$password, $dbname);
// Check connection
if ($conn72->connect_error) {
echo "Connection failed: " .
$conn72->connect_error;
}
40
$user=$_POST['login_username'];
$pass=$_POST['login_password'];
// Create connection
$conn71 = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn71->connect_error) {
echo "Connection failed: " . $connection->connect_error;
}
$query = mysqli_query($conn71, "SELECT * FROM users WHERE uname = '".$_SESSION['username']."'"
) or die(mysqli_error($conn71));
$row = mysqli_fetch_array($query);
$sql = "SELECT id FROM graph_local where host_id=".$row["hostid"];
$result = $conn72->query($sql);
$index = 1;
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$id=$row["id"];
$sql = "SELECT title_cache FROM graph_templates_graph where local_graph_id=".$id;
$title_assoc = $conn72->query($sql);
$title = $title_assoc->fetch_assoc();
$t_array = explode('-', $title['title_cache']);
$t_array[1] = trim($t_array[1]);
$billable = '';
if(strcmp(trim($t_array[2]),'eth0')==0
&& strcmp($t_array[1],'Traffic')==0)
{
$billable = " --- BILLABLE";
}
if(strlen(trim($t_array[2]))>0)
$t_array[1] = $t_array[1] . ' - '
. trim($t_array[2]);
echo '<tr> <td>'.$index.'</td>';
$index = $index + 1;
echo '<td>'.$t_array[1].' -
Daily'.$billable.'</td> </tr>';
}
}
?>
</tbody>
</table>
</div>
</div>
</div>
<!-- /block -->
</div>
</div>
</div>
</div>
</div>
<footer>
<div class="hr"></div>
<p style="margin:5px;color:#333333;">&copy; X-Verse</p>
<!--<a href="updateDaily.PHP">UPDATE</a>-->
</footer>
</div>
<!--/.fluid-container-->
<script src="vendors/jquery-1.9.1.min.js"></script>
41
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="vendors/easypiechart/jquery.easy-pie-chart.js"></script>
<script src="assets/scripts.js"></script>
<script>
$(function() {
// Easy pie charts
$('.chart').easyPieChart({animate: 1000});
$('.barchart').easyBarChart({animate: 1000});
});
</script>
</body>
</html>
Graph Page:
<?PHP
session_start();
if(!isset($_SESSION['username']) || $_SESSION['username']=='admin')
header("Location:index.PHP");
?>
<html class="no-js">
<head>
<title>Graph Page</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="vendors/easypiechart/jquery.easy-pie-chart.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="bootstrap/js/bootstrap.min.js"></script>
<script src="js/jquery-1.11.3.js"></script>
<script src="assets/scripts.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">
42
<li><a tabindex="-1" href="logout.PHP">Logout</a></li>
</ul>
</li>
</ul>
<ul class="nav">
<li><a href="dashboard.PHP">Dashboard</a></li>
<li class="dropdown">
<a href="#" data-toggle="dropdown" class="dropdown-
toggle">Settings <b class="caret"></b></a>
<ul class="dropdown-menu" id="menu1">
<li><a href="#">Change Theme</a></li>
</ul>
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span3" id="sidebar">
<ul class="nav nav-list bs-docs-sidenav nav-collapse collapse">
<li><a href="dashboard.PHP"> Dashboard</a></li>
<li class="active"><a href="#"> Graphs</a></li>
<!--<li><a href="system.PHP"> System</a></li>-->
</ul>
</div>
<!--/span-->
<div class="span9" id="content">
<div class="row-fluid">
<div class="alert alert-success">
<button type="button"
class="close" data-dismiss="alert">&times;</button>
<h4>Success</h4>
Graphs fetched successfully.
</div>
<div class="navbar">
<div class="navbar-inner">
<ul class="breadcrumb">
<i class="icon-chevron-left hide-sidebar"><a href='#'
title="Hide Sidebar" rel='tooltip'>&nbsp;</a></i>
<i class="icon-chevron-right show-sidebar"
style="display:none;"><a href='#' title="Show Sidebar" rel='tooltip'>&nbsp;</a></i>
<li><a href="dashboard.PHP">Dashboard</a> <span
class="divider"><span class="divider">/</span></li>
<li><a href="#">Graphs</a></li>
</ul>
</div>
</div>
</div>
<?PHP
// Create connection
$conn72 = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn72->connect_error) {
echo "Connection failed: " . $conn72->connect_error;
}
43
$user=$_POST['login_username'];
$pass=$_POST['login_password'];
// Create connection
$conn71 = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn71->connect_error) {
echo "Connection failed: " . $connection->connect_error;
}
$query = mysqli_query($conn71, "SELECT * FROM users WHERE uname =
'".$_SESSION['username']."'" ) or die(mysqli_error($conn71));
$row = mysqli_fetch_array($query);
$sql = "SELECT id FROM graph_local where host_id=".$row["hostid"];
$result = $conn72->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$id=$row["id"];
$sql = "SELECT title_cache FROM graph_templates_graph
where local_graph_id=".$id;
$title_assoc = $conn72->query($sql);
$title = $title_assoc->fetch_assoc();
$t_array = explode('-', $title['title_cache']);
$t_array[1] = trim($t_array[1]);
$billable = '';
if(strcmp(trim($t_array[2]),'eth0')==0 &&
strcmp($t_array[1],'Traffic')==0)
{
$billable = " --- BILLABLE";
}
if(strlen(trim($t_array[2]))>0)
$t_array[1] = $t_array[1] . ' - ' .
trim($t_array[2]);
?>
<div class="row-fluid">
<div class="block">
<div class="navbar navbar-inner block-header">
<div class="muted pull-left"><?PHP echo $t_array[1]." -
Daily".$billable; ?></div>
<div class="pull-right">
<a href="graphDetails.PHP?id=<?PHP echo $id;?>"><span
class="badge badge-info">View More</span></a>
</div>
</div>
<div class="block-content collapse in">
<div class="span12">
<img
src="http://208.50.229.72:2080/cacti/graph_image.PHP?local_graph_id=<?PHP echo $id
?>&amp;rra_id=0&amp;graph_height=120&amp;graph_width=500&amp;title_font_size=10&amp;view_type=
tree&amp;" alt="graph" style="width:50%; height:30%;">
</div>
</div>
</div>
</div>
<?PHP
}
}
44
?>
</div>
</div>
</div>
<footer>
<div class="hr"></div>
<p style="margin:5px;color:#333333;">&copy; X-Verse</p>
</footer>
</div>
<!--/.fluid-container-->
<script src="vendors/jquery-1.9.1.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="assets/scripts.js"></script>
</body>
</html>
Login:
<?PHP
session_start();
if(isset($_SESSION['username']))
if($_SESSION['username'] == 'admin')
header('Location:admin.PHP');
else
header('Location:dashboard.PHP');
if(isset($_SESSION['error']) && $_SESSION['error']=='WRONG') {
echo '<div class="row-fluid">';
echo '<div class="alert alert-error alert-block">';
echo '<button type="button" class="close" data-
dismiss="alert">&times;</button>';
echo '<h4 class="alert-heading">Failed</h4>';
echo 'INVALID USERNAME AND PASSWORD.';
echo '</div>';
echo'</div>';
$_SESSION['error']='';
}
?>
<html>
<head>
<title>Login</title>
<!-- Bootstrap -->
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="bootstrap/css/bootstrap-responsive.min.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="js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>
</head>
<body id="login">
<div class="container">
<table style="margin:0 auto; padding = 0px; box-shadow: 0px 0px 40px black;background-
color: white; border-radius:5px">
<tr>
45
<td style="padding: 20px">
<table style="margin:0 auto; padding-left: 20px; padding-right: 20px; box-shadow:
0px 0px 10px black; border-radius:5px">
<tr>
<td>
<form class="form-signin" method="POST" action="login.PHP">
<img src="images/Inet_cache.jpg" alt="logo"/>
<h2 class="form-signin-heading"><b>Log In</b></h2>
<span><hr style="background-color: #000000; height: 1px;"></span>
<input type="text" class="input-block-level" placeholder="Username"
name="login_username">
<input type="password" class="input-block-level" placeholder="Password"
name="login_password" >
<label class="checkbox">
<input type="checkbox" value="remember-me"> Remember Me
</label>
<button class="btn btn-large btn-primary" type="submit" name="submit">Sign
In</button>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div> <!-- /container -->
<script src="vendors/jquery-1.9.1.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
</body>
</html>
GenerateGraph.PHP:
<?PHP
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
echo "<br>"."Connection failed: " . $conn72->connect_error;
}
// Create connection
$conn71 = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn71->connect_error) {
echo "Connection failed: " . $connection->connect_error;
}
$sql =$conn71->query( "SELECT hostid FROM users where uname='".$_POST["uname"]."'" ) or
die(mysqli_error($conn71));
$hostrow=$sql->fetch_assoc();
$host=$hostrow["hostid"];
$sql = "SELECT id FROM graph_templates where name='".$_POST["template"]."'";
$result_graph_templates = $conn->query($sql);
$color=10;
if ($result_graph_templates->num_rows > 0) {
// output data of each row
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
// 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 {
48
$_SESSION['error']="WRONG";
header("Location:index.PHP");
}
}
else {
$_SESSION['error']="WRONG";
header("Location:index.PHP");
}
}
if(isset($_POST['submit']))
{
SignIn($con);
}
?>
Logout.PHP:
<?PHP
session_start();
session_unset();
session_destroy();
header("Location: index.PHP");
exit;
?>
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
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

More Related Content

What's hot

Online bus pass registration
Online bus pass registrationOnline bus pass registration
Online bus pass registrationYesu Raj
 
Event Management System Document
Event Management System Document Event Management System Document
Event Management System Document LJ PROJECTS
 
Plannaing And Management Of Project Report
Plannaing And Management Of Project ReportPlannaing And Management Of Project Report
Plannaing And Management Of Project ReportMJ Ferdous
 
Subhajit_Das_Resume_2015
Subhajit_Das_Resume_2015Subhajit_Das_Resume_2015
Subhajit_Das_Resume_2015Subhajit Das
 
2.1 project management srs
2.1 project management   srs2.1 project management   srs
2.1 project management srsAnil Kumar
 
Example Software Requirements Specification Document for ReqView
Example Software Requirements Specification Document for ReqViewExample Software Requirements Specification Document for ReqView
Example Software Requirements Specification Document for ReqViewEccam
 

What's hot (11)

Live chat srs
Live chat srsLive chat srs
Live chat srs
 
Online bus pass registration
Online bus pass registrationOnline bus pass registration
Online bus pass registration
 
Event Management System Document
Event Management System Document Event Management System Document
Event Management System Document
 
Parani_Profile
Parani_ProfileParani_Profile
Parani_Profile
 
Banking java project
Banking java projectBanking java project
Banking java project
 
Plannaing And Management Of Project Report
Plannaing And Management Of Project ReportPlannaing And Management Of Project Report
Plannaing And Management Of Project Report
 
Subhajit_Das_Resume_2015
Subhajit_Das_Resume_2015Subhajit_Das_Resume_2015
Subhajit_Das_Resume_2015
 
2.1 project management srs
2.1 project management   srs2.1 project management   srs
2.1 project management srs
 
CustomerCopy
CustomerCopyCustomerCopy
CustomerCopy
 
Nandita FTF
Nandita FTFNandita FTF
Nandita FTF
 
Example Software Requirements Specification Document for ReqView
Example Software Requirements Specification Document for ReqViewExample Software Requirements Specification Document for ReqView
Example Software Requirements Specification Document for ReqView
 

Similar to ProjectReport_Subhayu

IRJET - Code Compiler Shell
IRJET -  	  Code Compiler ShellIRJET -  	  Code Compiler Shell
IRJET - Code Compiler ShellIRJET Journal
 
PratheshBV_Resume
PratheshBV_ResumePratheshBV_Resume
PratheshBV_Resumepradeesh bv
 
Issue tracking system
Issue tracking systemIssue tracking system
Issue tracking systemAkshay Surve
 
14.project online eamination system
14.project online eamination system14.project online eamination system
14.project online eamination systemVivek Mehta
 
SathishKumar Natarajan
SathishKumar NatarajanSathishKumar Natarajan
SathishKumar NatarajanSathish Kumar
 
Configuring LIFA for remote communication using web architecture
Configuring LIFA for remote communication using web architecture Configuring LIFA for remote communication using web architecture
Configuring LIFA for remote communication using web architecture Ami Goswami
 
IRJET - Banquet Hall Reservation
IRJET - Banquet Hall ReservationIRJET - Banquet Hall Reservation
IRJET - Banquet Hall ReservationIRJET Journal
 
Appalanaidu_4.4 Years Exp in DotNet Technology
Appalanaidu_4.4 Years Exp in DotNet TechnologyAppalanaidu_4.4 Years Exp in DotNet Technology
Appalanaidu_4.4 Years Exp in DotNet TechnologyAPPALANAIDU KONDALA
 
ProjectPDF_pagenumber.docx project documentation
ProjectPDF_pagenumber.docx project documentationProjectPDF_pagenumber.docx project documentation
ProjectPDF_pagenumber.docx project documentationkomkar98230
 
Issue Tracking System - My B.E. Project
Issue Tracking System - My B.E. ProjectIssue Tracking System - My B.E. Project
Issue Tracking System - My B.E. ProjectDharmendra Vishwakarma
 
Renuka Devi with 4+ yr Exp
Renuka Devi with 4+ yr ExpRenuka Devi with 4+ yr Exp
Renuka Devi with 4+ yr ExpRenuka Devi
 
ops300 Project(3)
ops300 Project(3)ops300 Project(3)
ops300 Project(3)trayyoo
 

Similar to ProjectReport_Subhayu (20)

IRJET - Code Compiler Shell
IRJET -  	  Code Compiler ShellIRJET -  	  Code Compiler Shell
IRJET - Code Compiler Shell
 
PratheshBV_Resume
PratheshBV_ResumePratheshBV_Resume
PratheshBV_Resume
 
Issue tracking system
Issue tracking systemIssue tracking system
Issue tracking system
 
Chinnasamy Manickam
Chinnasamy ManickamChinnasamy Manickam
Chinnasamy Manickam
 
PRASANTHI P
PRASANTHI PPRASANTHI P
PRASANTHI P
 
14.project online eamination system
14.project online eamination system14.project online eamination system
14.project online eamination system
 
SathishKumar Natarajan
SathishKumar NatarajanSathishKumar Natarajan
SathishKumar Natarajan
 
Configuring LIFA for remote communication using web architecture
Configuring LIFA for remote communication using web architecture Configuring LIFA for remote communication using web architecture
Configuring LIFA for remote communication using web architecture
 
IRJET - Banquet Hall Reservation
IRJET - Banquet Hall ReservationIRJET - Banquet Hall Reservation
IRJET - Banquet Hall Reservation
 
locker presentation (1)
locker presentation (1)locker presentation (1)
locker presentation (1)
 
Appalanaidu_4.4 Years Exp in DotNet Technology
Appalanaidu_4.4 Years Exp in DotNet TechnologyAppalanaidu_4.4 Years Exp in DotNet Technology
Appalanaidu_4.4 Years Exp in DotNet Technology
 
Blue book
Blue bookBlue book
Blue book
 
Case study on search engine and toolbar with a chance to win prizes
Case study on search engine and toolbar with a chance to win prizesCase study on search engine and toolbar with a chance to win prizes
Case study on search engine and toolbar with a chance to win prizes
 
ProjectPDF_pagenumber.docx project documentation
ProjectPDF_pagenumber.docx project documentationProjectPDF_pagenumber.docx project documentation
ProjectPDF_pagenumber.docx project documentation
 
Issue Tracking System - My B.E. Project
Issue Tracking System - My B.E. ProjectIssue Tracking System - My B.E. Project
Issue Tracking System - My B.E. Project
 
combinepdf
combinepdfcombinepdf
combinepdf
 
Subrata sarma chowdhury resume
Subrata sarma chowdhury resumeSubrata sarma chowdhury resume
Subrata sarma chowdhury resume
 
Renuka Devi with 4+ yr Exp
Renuka Devi with 4+ yr ExpRenuka Devi with 4+ yr Exp
Renuka Devi with 4+ yr Exp
 
Resume
ResumeResume
Resume
 
ops300 Project(3)
ops300 Project(3)ops300 Project(3)
ops300 Project(3)
 

ProjectReport_Subhayu

  • 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
  • 13. 13 Fig 2: Admin Panel – First Page Fig 3: Modify Host (Admin Side) Fig 4: Modify Host Part 2 (Admin Side)
  • 14. 14 Fig 5: Payment Details (Admin Side) Fig 6: Dashboard (Client Side) Fig 7: Graph Page (Client Side)
  • 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">
  • 16. 16 <li><a href="#">Dashboard</a></li> <li class="dropdown"> <a href="#" data-toggle="dropdown" class="dropdown- toggle">Settings <b class="caret"></b></a> <ul class="dropdown-menu" id="menu1"> <li><a href="#">Change Theme</a></li> </ul> </li> </ul> </div> <!--/.nav-collapse --> </div> </div> </div> <div class="container-fluid"> <div class="row-fluid"> <div class="span3" id="sidebar"> <ul class="nav nav-list bs-docs-sidenav nav-collapse collapse"> <li class="active"> <a href="#"> Create New Host</a> </li> <li><a href="graphSelect.PHP"> Modify Host</a></li> <li><a href="hostDetails.PHP"> Payment Details</a></li> </ul> </div> <!--/span--> <div class="span9" id="content"> <?PHP if($_SESSION['success']=='success'){ echo '<div class="row-fluid">'; echo '<div class="alert alert-success">'; echo '<button type="button" class="close" data- dismiss="alert">&times;</button>'; echo '<h4>Success</h4>'; echo 'You have successfully logged in.'; echo '</div>'; echo '</div>'; $_SESSION['success']=''; } if($_SESSION['uiInsert']=='success'){ echo '<div class="row-fluid">'; echo '<div class="alert alert-success alert-block">'; echo '<button type="button" class="close" data- dismiss="alert">&times;</button>'; echo '<h4 class="alert-heading">Success</h4>'; echo 'New host has been successfully added.'; echo '</div>'; echo'</div>'; $_SESSION['uiInsert']==''; } if($_SESSION['uiInsert']=='error'){ echo '<div class="row-fluid">'; echo '<div class="alert alert-error alert-block">'; echo '<button type="button" class="close" data- dismiss="alert">&times;</button>'; echo '<h4 class="alert-heading">Failed</h4>'; echo 'Adding new host failed.'; echo '</div>';
  • 17. 17 echo'</div>'; $_SESSION['uiInsert']==''; } ?> <div class="row-fluid"> <!-- block --> <div class="block"> <div class="navbar navbar-inner block-header"> <div class="muted pull-left">Add Host</div> </div> <div class="block-content collapse in"> <div class="span12"> <form class="form-horizontal" action="uiInsert.PHP" method="post"> <fieldset> <legend>Host Details</legend> <div class="control-group"> <label class="control-label" for="focusedInput">Host IP Address:</label> <div class="controls"> <input class="input-xlarge focused" id="focusedInput" type="text" name="hostname" placeholder="IP Address"> </div> </div> <div class="control-group"> <label class="control-label" for="focusedInput">Description:</label> <div class="controls"> <input class="input-xlarge focused" id="focusedInput" type="text" name="description" placeholder="Enter Description"> </div> </div> <div class="control-group"> <label class="control-label" for="focusedInput">SNMP Community String:</label> <div class="controls"> <input class="input-xlarge focused" id="focusedInput" type="text" name="community" placeholder="Community String"> </div> </div> <legend>User Details</legend> <div class="control-group"> <label class="control-label" for="focusedInput">Username:</label> <div class="controls"> <input class="input-xlarge focused" id="focusedInput" type="text" name="login_username" placeholder="Username"> </div> </div> <div class="control-group"> <label class="control-label" for="focusedInput">Password:</label> <div class="controls"> <input class="input-xlarge focused" id="focusedInput" name= "login_password" type="password"> </div> </div> <div class="control-group success">
  • 18. 18 <label class="control-label" for="selectError">Billing Cycle:</label> <div class="controls"> <select id="selectError" name="billing_cycle"> <option value="0">1st of the Month</option> <option value="1">15th of the Month</option> </select> </div> </div> <div class="form-actions"> <button type="submit" name ="submit" class="btn btn- primary">Create</button> <button type="reset" class="btn">Reset</button> </div> </fieldset> </form> </div> </div> </div> <!-- /block --> </div> </div> </div> </div> <footer> <div class="hr"></div> <p style="margin:5px;color:#333333;">&copy; X-Verse</p> </footer> </div> <!--/.fluid-container--> <script src="vendors/jquery-1.9.1.min.js"></script> <script src="bootstrap/js/bootstrap.min.js"></script> <script src="assets/scripts.js"></script> <link href="vendors/uniform.default.css" rel="stylesheet" media="screen"> <link href="vendors/chosen.min.css" rel="stylesheet" media="screen"> <script src="vendors/jquery.uniform.min.js"></script> <script src="vendors/chosen.jquery.min.js"></script> <script src="vendors/wizard/jquery.bootstrap.wizard.min.js"></script> <script type="text/javascript" src="vendors/jquery- validation/dist/jquery.validate.min.js"></script> <script src="assets/form-validation.js"></script> <script> $(function() { }); </script> </body> </html> Modify Host: <?PHP session_start(); if(!isset($_SESSION['username']) || $_SESSION['username']=='admin')
  • 19. 19 header("Location:index.PHP"); ?> <html class="no-js"> <head> <title>Graph Page</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="vendors/easypiechart/jquery.easy-pie-chart.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="bootstrap/js/bootstrap.min.js"></script> <script src="js/jquery-1.11.3.js"></script> <script src="assets/scripts.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"> <li><a href="dashboard.PHP">Dashboard</a></li> <li class="dropdown"> <a href="#" data-toggle="dropdown" class="dropdown- toggle">Settings <b class="caret"></b></a> <ul class="dropdown-menu" id="menu1"> <li><a href="#">Change Theme</a></li> </ul> </li> </ul> </div> <!--/.nav-collapse --> </div> </div> </div> <div class="container-fluid"> <div class="row-fluid">
  • 20. 20 <div class="span3" id="sidebar"> <ul class="nav nav-list bs-docs-sidenav nav-collapse collapse"> <li><a href="dashboard.PHP"> Dashboard</a></li> <li class="active"><a href="graPHPage.PHP"> Graph</a></li> <!-- <li><a href="system.PHP"> System</a></li> --> </ul> </div> <!--/span--> <div class="span9" id="content"> <div class="row-fluid"> <div class="alert alert-success"> <button type="button" class="close" data-dismiss="alert">&times;</button> <h4>Success</h4> Graphs fetched successfully. </div> <div class="navbar"> <div class="navbar-inner"> <ul class="breadcrumb"> <i class="icon-chevron-left hide-sidebar"><a href='#' title="Hide Sidebar" rel='tooltip'>&nbsp;</a></i> <i class="icon-chevron-right show-sidebar" style="display:none;"><a href='#' title="Show Sidebar" rel='tooltip'>&nbsp;</a></i> <li><a href="dashboard.PHP">Dashboard</a> <span class="divider"><span class="divider">/</span></li> <li><a href="#">Graphs</a></li> </ul> </div> </div> </div> <?PHP $id=$_GET["id"]; ?> <div class="row-fluid"> <div class="block"> <div class="navbar navbar-inner block-header"> <div class="muted pull-left">Hourly</div> </div> <div class="block-content collapse in"> <div class="span12"> <img src="http://208.50.229.72:2080/cacti/graph_image.PHP?local_graph_id=<?PHP echo $id ?>&amp;rra_id=5&amp;graph_height=120&amp;graph_width=500&amp;title_font_size=10&amp;view_type= tree&amp;" alt="graph" style="width:50%; height:30%;"> </div> </div> </div> </div> <div class="row-fluid"> <div class="block"> <div class="navbar navbar-inner block-header"> <div class="muted pull-left">Daily</div> </div> <div class="block-content collapse in"> <div class="span12">
  • 21. 21 <img src="http://208.50.229.72:2080/cacti/graph_image.PHP?local_graph_id=<?PHP echo $id ?>&amp;rra_id=1&amp;graph_height=120&amp;graph_width=500&amp;title_font_size=10&amp;view_type= tree&amp;" alt="graph" style="width:50%; height:30%;"> </div> </div> </div> </div> <div class="row-fluid"> <div class="block"> <div class="navbar navbar-inner block-header"> <div class="muted pull-left">Weekly</div> </div> <div class="block-content collapse in"> <div class="span12"> <img src="http://208.50.229.72:2080/cacti/graph_image.PHP?local_graph_id=<?PHP echo $id ?>&amp;rra_id=2&amp;graph_height=120&amp;graph_width=500&amp;title_font_size=10&amp;view_type= tree&amp;" alt="graph" style="width:50%; height:30%;"> </div> </div> </div> </div> <div class="row-fluid"> <div class="block"> <div class="navbar navbar-inner block-header"> <div class="muted pull-left">Monthly</div> </div> <div class="block-content collapse in"> <div class="span12"> <img src="http://208.50.229.72:2080/cacti/graph_image.PHP?local_graph_id=<?PHP echo $id ?>&amp;rra_id=3&amp;graph_height=120&amp;graph_width=500&amp;title_font_size=10&amp;view_type= tree&amp;" alt="graph" style="width:50%; height:30%;"> </div> </div> </div> </div> <div class="row-fluid"> <div class="block"> <div class="navbar navbar-inner block-header"> <div class="muted pull-left">Yearly</div> </div> <div class="block-content collapse in"> <div class="span12"> <img src="http://208.50.229.72:2080/cacti/graph_image.PHP?local_graph_id=<?PHP echo $id ?>&amp;rra_id=3&amp;graph_height=120&amp;graph_width=500&amp;title_font_size=10&amp;view_type= tree&amp;" alt="graph" style="width:50%; height:30%;"> </div> </div> </div> </div> </div>
  • 22. 22 </div> </div> <footer> <div class="hr"></div> <p style="margin:5px;color:#333333;">&copy; X-Verse</p> </footer> </div> <!--/.fluid-container--> <script src="vendors/jquery-1.9.1.min.js"></script> <script src="bootstrap/js/bootstrap.min.js"></script> <script src="assets/scripts.js"></script> </body> </html> Payment Details: <?PHP session_start(); if($_SESSION['username']!='admin') header("Location:index.PHP"); ?> <html class="no-js"> <head> <title>Payment Details </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>
  • 23. 23 </li> </ul> <ul class="nav"> <li><a href="#">Dashboard</a></li> <li class="dropdown"> <a href="#" data-toggle="dropdown" class="dropdown- toggle">Settings <b class="caret"></b></a> <ul class="dropdown-menu" id="menu1"> <li><a href="#">Change Theme</a></li> </ul> </li> </ul> </div> <!--/.nav-collapse --> </div> </div> </div> <div class="container-fluid"> <div class="row-fluid"> <div class="span3" id="sidebar"> <ul class="nav nav-list bs-docs-sidenav nav-collapse collapse"> <li> <a href="admin.PHP"> Create New Host</a> </li> <li> <a href="graphSelect.PHP"> Modify Host</a></li> <li class="active"><a href="#"> Payment Details</a></li> </ul> </div> <!--/span--> <div class="span9" id="content"> <div class="row-fluid"> <!-- block --> <div class="block"> <div class="navbar navbar-inner block-header"> <div class="muted pull-left">Host Payment Details</div> </div> <div class="block-content collapse in"> <div class="span12"> <form class="form-horizontal" action="" method="post"> <fieldset> <legend>Select Host</legend> <div class="control-group success"> <label class="control-label" for="selectError">Select Host:</label> <div class="controls"> <select id="selectError" name="uname"> <option></option> <?PHP // Create connection $conn71 = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn71->connect_error) { echo "Connection failed: " . $connection- >connect_error; } $sql = $conn71->query( "SELECT uname FROM users" ) or die(mysqli_error($conn71)); while($row=$sql->fetch_assoc()) { if($row["uname"]!='admin'){
  • 24. 24 $option_div="<option value=".$row['uname']; if($_POST['uname'] == $row['uname']) $option_div = $option_div.' selected="selected">'.$row['uname'].'</option>'; else $option_div = $option_div.'>'.$row['uname'].'</option>'; echo $option_div; } } ?> </select> &nbsp;&nbsp; <button type="submit" name ="getGraphs" class="btn"> <i class="icon-eye-open"></i> View </button> </div> </div> </fieldset> </form> <!-- GET GRAPHS --> <?PHP if (isset($_POST['getGraphs'])) { $username = $_POST['uname']; $sql="select hostid from users where uname='".$username."'"; $result = $conn71->query($sql); $row = $result->fetch_assoc(); $hostid=$row['hostid']; echo '<div class="span12">'; echo '<table class="table table-striped">'; echo'<thead>'; echo '<tr colspan="2"><th>Payment Record:</th></tr>'; $sql="select * from host where hostid=".$hostid; $result = $conn71->query($sql); $flag = $result->num_rows; $row = $result->fetch_assoc(); $bill_cycle = (int)$row['bill_cycle']; $m=date("n"); $y=date("Y"); $sql="select * from payment where hostid=".$row["hostid"]." and month=".$m." and year =".$y; $sql_result=$conn71->query($sql); $r=$sql_result->num_rows; $sql_row=$sql_result->fetch_assoc(); if($r>0){ $date=$sql_row["day"]."/".$sql_row["month"]."/".$sql_row["year"]; } else { $m=$m-1; if($m==0) { $m=12; $y=$y-1; } $sql="select * from payment where hostid=".$row["hostid"]." and month=". $m." and year =". $y;
  • 25. 25 $sql_result=$conn71->query($sql); $r=$sql_result->num_rows; $sql_row=$sql_result->fetch_assoc(); if($r>0) { $date=$sql_row["day"]."/".$sql_row["month"]."/".$sql_row["year"]; } else $date = "License expired"; } echo '<tbody>'; echo '<tr>'; echo '<td>Last Payment Date:</td>'; if($flag>0) { echo '<td>'.$date.'</td>'; } else { echo '<td>Not Paid</td>'; } echo '</tr>'; echo '<tr>'; echo '<td>Billed Amount:</td>'; if($flag>0 && $r>0) { echo '<td>Rs. '.$sql_row["bill_amt"].'</td>'; } else { echo '<td>Not Paid</td>'; } echo '</tr>'; echo '<tr>'; echo '<td>Next Billing Date:</td>'; if($flag>0 && $r>0) { $sql="select * from host where hostid=".$hostid; $result = $conn71->query($sql); $r = $result->num_rows; $row = $result->fetch_assoc(); $bill_cycle = (int)$row['bill_cycle']; if($bill_cycle == 0) { $bill_day = 23; } else if($bill_cycle == 1) { $bill_day = 7; } $m=$m+1; if($m==13) { $m=1; $y=$y+1; } $str=$bill_day."/".$m."/".$y; if($r>0){ echo '<td>'.$str.'</td>'; }else echo '<td>"Not Paid"</td>'; } else { echo '<td>Not Paid</td>'; } echo '</tr>'; echo '<tr>';
  • 26. 26 echo '<td>License Expiry:</td>'; if($flag>0 && $r>0) { if($bill_cycle == 0) { $exp_day = 1; $m=$m+1; if($m==13) { $m=1; $y=$y+1; } } else if($bill_cycle == 1) { $exp_day = 15; } $str=$exp_day."/".$m."/".$y; if($r>0){ echo '<td>'.$str.'</td>'; } else echo '<td>"Not Paid"</td>'; } else { echo '<td>Not Paid</td>'; } echo '</tr>'; echo '</tbody>'; echo '</table>'; echo '<table class="table table-striped">'; echo '<thead>'; echo '<tr colspan="2"><th>Payment History:</th></tr>'; echo '<tr><th>Date</th><th>Amount</th></tr>'; echo '</thead>'; echo '<tbody>'; $sql="select * from payment where hostid=".$row["hostid"]; $result = $conn71->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { $date=$row["day"]."/".$row["month"]."/".$row["year"]; echo '<tr>'; echo '<td>'.$date.'</td>'; echo '<td>Rs. '.$row["bill_amt"].'</td>'; echo '</tr>'; } } echo '</tbody>'; echo '</table>'; echo '</div>'; echo '<form class="form-horizontal" action="?" method="post">'; echo '<fieldset>';
  • 27. 27 echo '<legend>Pay Bill</legend>'; echo '<div class="control-group success">'; echo '<label class="control-label" for="selectError">Select Graph:</label>'; echo '<div class="controls">'; $hidden_input = '<input type="hidden" name="uname" value="'.$username.'"/>'; echo $hidden_input; echo '<select id="selectError" name="graphid" value="'.$record['graphid'].'">'; echo '<option></option>'; echo '<option selected="selected">Interface - Traffic (bits/sec)</option>'; echo '</select> &nbsp;&nbsp;'; echo '<button type="submit" name ="getGraphHistory" class="btn">'; echo '<i class="icon-pencil"></i> Generate Bill'; echo '</button>'; echo '</div>'; echo '</div>'; echo '</fieldset>'; echo '</form>'; } //GET GRAPH HISTORY else if (isset($_POST['getGraphHistory'])){ $username = $_POST['uname']; $sql="select hostid from users where uname='".$username."'"; $result = $conn71->query($sql); $row = $result->fetch_assoc(); $hostid = (int)$row['hostid']; $sql="select bill_cycle from host where hostid=".hostid; $result = $conn71- >query($sql); $row = $result->fetch_assoc(); $bill_cycle = $row['bill_cycle']; echo '<div class="span12">'; echo '<table class="table table-striped">'; echo'<thead>'; echo '<tr colspan="2"><th>Payment Record:</th></tr>'; $sql="select * from payment where hostid=".$hostid; $result = $conn71->query($sql); $flag = $result->num_rows; $row = $result->fetch_assoc(); echo '<tbody>'; echo '<tr>'; echo '<td>Last Payment Date:</td>'; if($flag > 0) { echo '<td>'.$row["day"].'/'.$row["month"].'/'.$row["year"].'</td>'; } else { echo '<td>Not Paid</td>'; } echo '</tr>';
  • 28. 28 echo '<tr>'; echo '<td>Billed Amount:</td>'; if($flag > 0) { echo '<td>Rs. '.$row["bill_amt"].'</td>'; } else { echo '<td>Not Paid</td>'; } echo '</tr>'; echo '<tr>'; echo '<td>Next Billing Date:</td>'; if($flag > 0) { $mn = (int)($row["month"])+1; $yr = (int)($row["year"]); if($mn>12) { $mn = $mn - 12; $yr = $yr + 1; } echo '<td>7/'.$mn.'/'.$yr.'</td>'; } else { echo '<td>Not Paid</td>'; } echo '</tr>'; echo '<tr>'; echo '<td>License Expiry:</td>'; if($flag > 0) { $mn = (int)($row["month"])+1; $yr = (int)($row["year"]); if($mn>12) { $mn = $mn - 12; $yr = $yr + 1; } echo '<td>15/'.$mn.'/'.$yr.'</td>'; } else { echo '<td>Not Paid</td>'; } echo '</tr>'; echo '</tbody>'; echo '</table>'; echo '</div>'; echo '<form class="form-horizontal" action="?" method="post">'; echo '<fieldset>'; echo '<legend>Bill Details</legend>'; echo '<div class="control-group success">'; echo '<label class="control-label" for="selectError">Select Graph:</label>'; echo '<div class="controls">'; $hidden_input = '<input type="hidden" name="uname" value="'.$username.'"/>'; echo $hidden_input;
  • 29. 29 echo '<select id="selectError" name="graphid" value="'.$record['graphid'].'">'; echo '<option selected="selected">Interface - Traffic (bits/sec)</option>'; echo '</select> &nbsp;&nbsp;'; echo '<button type="submit" name ="getGraphHistory" class="btn">'; echo '<i class="icon-pencil"></i> Generate Bill'; echo '</button>'; echo '</div>'; echo '</div>'; echo '</fieldset>'; echo '</form>'; echo '<div class="span12">'; echo '<form class="form-horizontal" action="?" method="post">'; $hidden_input = '<input type="hidden" name="uname" value="'.$username.'"/>'; echo $hidden_input; echo '<table class="table">'; echo '<tbody>'; echo '<tr>'; echo '<td>Payment Date:</td>'; echo '<td>'; echo '<input type="text" class="datepicker" name="pay_date" id="date01" value=""/>'; echo '</div>'; echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td>Payment Amount:</td>'; echo '<td>'; echo '<input type="text" name="pay_amt" value="" />'; echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td>Downtime Credit:</td>'; echo '<td>'; echo '<select id="selectError" name="credit">'; echo '<option>0</option>'; echo '<option>1</option>'; echo '<option>2</option>'; echo '<option>3</option>'; echo '<option>4</option>'; echo '<option>5</option>'; echo '<option>6</option>'; echo '<option>7</option>'; echo '<option>8</option>'; echo '<option>9</option>'; echo '<option>10</option>'; echo '<option>11</option>'; echo '<option>12</option>'; echo '<option>13</option>'; echo '<option>14</option>'; echo '<option>15</option>'; echo '<option>16</option>'; echo '<option>17</option>';
  • 30. 30 echo '<option>18</option>'; echo '<option>19</option>'; echo '<option>20</option>'; echo '<option>21</option>'; echo '<option>22</option>'; echo '<option>23</option>'; echo '<option>24</option>'; echo '<option>25</option>'; echo '<option>26</option>'; echo '<option>27</option>'; echo '<option>28</option>'; echo '<option>29</option>'; echo '<option>30</option>'; echo '</select>'; echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td colspan=2>'; echo '<button type="submit" name ="billSubmit" class="btn btn-primary">'; echo '<i class="icon-ok icon- white"></i> Submit'; echo '</button>'; echo '</td>'; echo '</tr>'; echo '</tbody>'; echo '</table>'; echo '</form>'; echo '</div>'; } else if(isset($_POST['billSubmit'])) { $username = $_POST['uname']; $sql="select hostid from users where uname='".$username."'"; $result = $conn71->query($sql); $row = $result->fetch_assoc(); $hostid = $row['hostid']; $date = $_POST['pay_date']; $amt = $_POST['pay_amt']; $credit=$_POST['credit']; $date = explode('/', $date); $sql = 'INSERT INTO payment VALUES (0,'.$row['hostid'].','.(int)$date[1].','.(int)$date[0].','.(int)$date[2].','.(int)$amt.','.(i nt)$credit.')'; $res = $conn71->query($sql); } ?> </div> </div> </div> <!-- /block --> </div> </div> </div> </div> <footer>
  • 31. 31 <div class="hr"></div> <p style="margin:5px;color:#333333;">&copy; X-Verse</p> </footer> </div> <!--/.fluid-container--> <script src="vendors/jquery-1.9.1.min.js"></script> <script src="bootstrap/js/bootstrap.min.js"></script> <script src="assets/scripts.js"></script> <link href="vendors/datepicker.css" rel="stylesheet" media="screen"> <link href="vendors/uniform.default.css" rel="stylesheet" media="screen"> <link href="vendors/chosen.min.css" rel="stylesheet" media="screen"> <script src="vendors/jquery.uniform.min.js"></script> <script src="vendors/chosen.jquery.min.js"></script> <script src="vendors/wizard/jquery.bootstrap.wizard.min.js"></script> <script type="text/javascript" src="vendors/jquery- validation/dist/jquery.validate.min.js"></script> <script src="assets/form-validation.js"></script> <script src="vendors/bootstrap-datepicker.js"></script> <script type="text/javascript"> $(function() { $(".datepicker").datepicker(); }); </script> <style> div.legend { display: block; padding-left: 2px; padding-right: 2px; border: none; } </style> </body> </html> Dashboard: <?PHP session_start(); if(!isset($_SESSION['username']) || $_SESSION['username']=='admin') header("Location:index.PHP"); ?> <html class="no-js"> <head> <title>Dashboard </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="vendors/easypiechart/jquery.easy-pie-chart.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>
  • 32. 32 <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"> <li class="active"><a href="#">Dashboard</a></li> <li class="dropdown"> <a href="#" data-toggle="dropdown" class="dropdown- toggle">Settings <b class="caret"></b></a> <ul class="dropdown-menu" id="menu1"> <li><a href="#">Change Theme</a></li> </ul> </li> </ul> </div> <!--/.nav-collapse --> </div> </div> </div> <div class="container-fluid"> <div class="row-fluid"> <div class="span3" id="sidebar"> <ul class="nav nav-list bs-docs-sidenav nav-collapse collapse"> <li class="active"> <a href="#"> Dashboard</a> </li> <li><a href="graPHPage.PHP"> Graphs</a></li> <!--<li ><a href="system.PHP"> System</a></li>--> </ul> </div> <?PHP $user=$_SESSION['username']; // Create connection $conn71 = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn71->connect_error) { echo "Connection failed: " . $connection->connect_error; } $query = mysqli_query($conn71, "SELECT * FROM users WHERE uname = '".$user."'" ) or die(mysqli_error($conn71));
  • 33. 33 $row = mysqli_fetch_array($query); $sql = "SELECT * FROM host where hostid=".$row["hostid"]; $result = $conn71->query($sql); if ($result->num_rows > 0) { // output data of each row $host_row = $result->fetch_assoc() ; $hostname = $host_row["hostname"]; $community = $host_row["snmp_community"]; $version = $host_row["snmp_version"]; $description = $host_row["description"]; } if($version==1) { //snmpget -v 1 -c public 103.43.80.18 sysUpTime.0 $cmd="snmpget -v 1 -c ".$community." ".$hostname." sysUpTime.0"; } if($version==2) { $cmd="snmpget -v 2c -c ".$community." ".$hostname." sysUpTime.0"; } // Run a command that will probably write to stderr (unless you have a folder named /hom) $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); // echo "Error: " . stream_get_contents($errorStream); $out = stream_get_contents($stream); // Close the streams fclose($errorStream); fclose($stream); $out = substr($out, (strrpos($out, ')', -1) + 2)); $token = strtok($out, ":"); $uptime = $token . " hours, "; $token = strtok(":"); $uptime = $uptime . $token . " minutes."; ?> <!--/span--> <div class="span9" id="content"> <div class="row-fluid"> <?PHP if($_SESSION['success']=='success') { echo '<div class="alert alert-success">'; echo '<button type="button" class="close" data- dismiss="alert">&times;</button>'; echo '<h4>Success</h4>'; echo 'You have successfully logged in.'; echo '</div>'; $_SESSION['success']=''; } ?> <div class="navbar">
  • 34. 34 <div class="navbar-inner"> <ul class="breadcrumb"> <i class="icon-chevron-left hide-sidebar"><a href='#' title="Hide Sidebar" rel='tooltip'>&nbsp;</a></i> <i class="icon-chevron-right show-sidebar" style="display:none;"><a href='#' title="Show Sidebar" rel='tooltip'>&nbsp;</a></i> <li><a href="#">Dashboard</a></li> </ul> </div> </div> </div> <div class="row-fluid"> <div class="row-fluid"> <!-- block --> <!--<div class="block"> <div class="navbar navbar-inner block-header"> <div class="muted pull-left">Service Status</div> </div> <div class="block-content collapse in"> <div class="span12"> <form class="form-horizontal" action="#" method="post"> <fieldset> <legend>Status</legend> <div class="well" style="margin-top:30px;"> <?PHP $hid=$row["hostid"]; $user=$_SESSION['username']; // Create connection $conn71 = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn71->connect_error) { echo "Connection failed: " . $connection- >connect_error; } $m=date("n"); $y=date("Y"); /*$sql="select * from payment where hostid=".$hid." and month=".$m." and year =".$y; $sql_result=$conn71->query($sql); $r=$sql_result->num_rows; $sql_row=$sql_result->fetch_assoc(); if($r>0) echo '<button type="submit" class="btn btn-large btn-block btn-success" name="restart">Restart Services</button>'; else { $m=$m-1; if($m==0) { $m=12; $y=$y-1; }
  • 35. 35 $sql="select * from payment where hostid=".$hid." and month=".$m." and year =".$y; $sql_result=$conn71->query($sql); $r=$sql_result->num_rows; $sql_row=$sql_result->fetch_assoc(); if($r>0) echo '<button type="submit" class="btn btn-large btn-block btn-success" name="restart">Restart Services</button>'; else echo '<button type="submit" class="btn btn-large btn-block btn-info" name="restart" disabled>Restart Services</button>'; }*/ ?> </div> <fieldset> </form> </div> </div> </div>--> <!-- /block --> </div> <div class="row-fluid"> <!-- block --> <div class="block"> <div class="navbar navbar-inner block-header"> <div class="muted pull-left">Details</div> </div> <div class="block-content collapse in"> <div class="span12"> <table class="table table-striped"> <thead> <tr colspan=2> <th>General Details</td> </tr> </thead> <tbody> <tr> <td>Device Name:</td> <td><?PHP echo $description ?></td> </tr> <tr> <td>IP Address:</td> <td><?PHP echo $hostname ?></td> </tr> <tr> <td>Device Up Time:</td> <td><?PHP echo $uptime ?></td> </tr> <tr> <td>Sizing:</td> <td> <?PHP $sql = 'SELECT sizing FROM host WHERE hostid='.$row["hostid"]; $result=$conn71->query($sql); $r=$result->fetch_assoc(); if((int)$r['sizing'] == 1) { $sizing = 'I - STM';
  • 36. 36 } else if((int)$r['sizing'] == 2) { $sizing = 'II - STM'; } else if((int)$r['sizing'] == 3) { $sizing = 'III - STM'; } else if((int)$r['sizing'] == 4) { $sizing = 'IV - STM'; } else if((int)$r['sizing'] == 5) { $sizing = 'V - STM'; } echo $sizing; ?> </td> </tr> </tbody> </table> <table class="table table-striped"> <thead> <tr colspan=2> <th>Payment Details</td> </tr> </thead> <tbody> <tr> <td>Last Payment Date:</td> <td> <?PHP $m=date("n"); $y=date("Y"); $sql="select * from payment where hostid=".$row["hostid"]." and month=".$m." and year =".$y; $sql_result=$conn71->query($sql); $r=$sql_result->num_rows; $sql_row=$sql_result->fetch_assoc(); if($r>0){ $date=$sql_row["day"]."/".$sql_row["month"]."/".$sql_row["year"]; echo $date; } else { $m=$m-1; if($m==0) { $m=12; $y=$y-1; } $sql="select * from payment where hostid=".$row["hostid"]." and month=".$m." and year =".$y; $sql_result=$conn71->query($sql); $r=$sql_result->num_rows; $sql_row=$sql_result->fetch_assoc(); if($r>0){
  • 37. 37 $date=$sql_row["day"]."/".$sql_row["month"]."/".$sql_row["year"]; echo $date; } else echo "License expired"; } ?> </td> </tr> <tr> <td>Paid Bill Amount:</td> <td> <?PHP if($r>0){ echo 'Rs. ' . $sql_row["bill_amt"]; } else echo "License expired"; ?> </td> </tr> <tr> <td>Next Billing Date:</td> <td> <?PHP $sql="select * from host where hostid=".$row["hostid"]; $result = $conn71->query($sql); $flag = $result->num_rows; $row = $result->fetch_assoc(); $bill_cycle = (int)$row['bill_cycle']; if($bill_cycle == 0) { $bill_day = 23; } else if($bill_cycle == 1) { $bill_day = 7; } $m=$m+1; if($m==13) { $m=1; $y=$y+1; } $str=$bill_day."/".$m."/".$y; if($r>0) { echo $str; } else echo "Not Paid"; ?> </td> </tr> <tr> <td>License Expiry:</td> <td> <?PHP if($bill_cycle == 0) { $exp_day = 1; $m=$m+1; if($m==13) {
  • 38. 38 $m=1; $y=$y+1; } } else if($bill_cycle == 1) { $exp_day = 15; } $str=$exp_day."/".$m."/".$y; if($r>0){ echo $str; } else echo "Not Paid"; ?> </td> </tr> <tr> <td>Downtime Credit:</td> <td> <?PHP $sql = 'SELECT downgrace FROM payment WHERE hostid='.$row["hostid"]; $result=$conn71->query($sql); $r=$result->fetch_assoc(); echo (int)$r['downgrace']. ' days'; ?> </td> </tr> </tbody> </table> <br> <table class="table table-striped"> <thead> <tr> <th>Services Enlisted</td> </tr> </thead> <tbody> <tr> <td> <?PHP $sql="select * from host where hostid=".$row["hostid"]; $sql_result=$conn71->query($sql); $sql_row=$sql_result->fetch_assoc(); $flag = 0; if($sql_row['service_http']==1) { $flag = 1; echo 'HTTP <br>'; } if($sql_row['service_p2p']==1) { $flag = 1; echo 'P2P <br>'; } if($sql_row['service_dns_cache']==1) { $flag = 1;
  • 39. 39 echo 'DNS Caching <br>'; } if($sql_row['service_antispam']==1) { $flag = 1; echo 'Anti-Spam <br>'; } if($sql_row['service_url_filter']==1) { $flag = 1; echo 'URL Filtering <br>'; } if($flag==0) if($sql_row['service_url_filter'] +$sql_row['service_antispam'] +$sql_row['service_dns_cache'] +$sql_row['service_p2p'] +$sql_row['service_http'] ==0) echo "No service"; ?> </td> </tr> </tbody> </table> </div> </div> </div> <!-- /block --> </div> <div class="row-fluid"> <!-- block --> <div class="block"> <div class="navbar navbar-inner block-header"> <div class="muted pull-left">Graphs</div> <div class="pull-right"> <a href="graPHPage.PHP"><span class="badge badge- info">View More</span></a> </div> </div> <div class="block-content collapse in"> <div class="span12"> <table class="table table-striped"> <thead> <tr> <th>#</th> <th>Name</th> </tr> </thead> <tbody> <?PHP // Create connection $conn72 = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn72->connect_error) { echo "Connection failed: " . $conn72->connect_error; }
  • 40. 40 $user=$_POST['login_username']; $pass=$_POST['login_password']; // Create connection $conn71 = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn71->connect_error) { echo "Connection failed: " . $connection->connect_error; } $query = mysqli_query($conn71, "SELECT * FROM users WHERE uname = '".$_SESSION['username']."'" ) or die(mysqli_error($conn71)); $row = mysqli_fetch_array($query); $sql = "SELECT id FROM graph_local where host_id=".$row["hostid"]; $result = $conn72->query($sql); $index = 1; if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { $id=$row["id"]; $sql = "SELECT title_cache FROM graph_templates_graph where local_graph_id=".$id; $title_assoc = $conn72->query($sql); $title = $title_assoc->fetch_assoc(); $t_array = explode('-', $title['title_cache']); $t_array[1] = trim($t_array[1]); $billable = ''; if(strcmp(trim($t_array[2]),'eth0')==0 && strcmp($t_array[1],'Traffic')==0) { $billable = " --- BILLABLE"; } if(strlen(trim($t_array[2]))>0) $t_array[1] = $t_array[1] . ' - ' . trim($t_array[2]); echo '<tr> <td>'.$index.'</td>'; $index = $index + 1; echo '<td>'.$t_array[1].' - Daily'.$billable.'</td> </tr>'; } } ?> </tbody> </table> </div> </div> </div> <!-- /block --> </div> </div> </div> </div> </div> <footer> <div class="hr"></div> <p style="margin:5px;color:#333333;">&copy; X-Verse</p> <!--<a href="updateDaily.PHP">UPDATE</a>--> </footer> </div> <!--/.fluid-container--> <script src="vendors/jquery-1.9.1.min.js"></script>
  • 41. 41 <script src="bootstrap/js/bootstrap.min.js"></script> <script src="vendors/easypiechart/jquery.easy-pie-chart.js"></script> <script src="assets/scripts.js"></script> <script> $(function() { // Easy pie charts $('.chart').easyPieChart({animate: 1000}); $('.barchart').easyBarChart({animate: 1000}); }); </script> </body> </html> Graph Page: <?PHP session_start(); if(!isset($_SESSION['username']) || $_SESSION['username']=='admin') header("Location:index.PHP"); ?> <html class="no-js"> <head> <title>Graph Page</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="vendors/easypiechart/jquery.easy-pie-chart.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="bootstrap/js/bootstrap.min.js"></script> <script src="js/jquery-1.11.3.js"></script> <script src="assets/scripts.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">
  • 42. 42 <li><a tabindex="-1" href="logout.PHP">Logout</a></li> </ul> </li> </ul> <ul class="nav"> <li><a href="dashboard.PHP">Dashboard</a></li> <li class="dropdown"> <a href="#" data-toggle="dropdown" class="dropdown- toggle">Settings <b class="caret"></b></a> <ul class="dropdown-menu" id="menu1"> <li><a href="#">Change Theme</a></li> </ul> </li> </ul> </div> <!--/.nav-collapse --> </div> </div> </div> <div class="container-fluid"> <div class="row-fluid"> <div class="span3" id="sidebar"> <ul class="nav nav-list bs-docs-sidenav nav-collapse collapse"> <li><a href="dashboard.PHP"> Dashboard</a></li> <li class="active"><a href="#"> Graphs</a></li> <!--<li><a href="system.PHP"> System</a></li>--> </ul> </div> <!--/span--> <div class="span9" id="content"> <div class="row-fluid"> <div class="alert alert-success"> <button type="button" class="close" data-dismiss="alert">&times;</button> <h4>Success</h4> Graphs fetched successfully. </div> <div class="navbar"> <div class="navbar-inner"> <ul class="breadcrumb"> <i class="icon-chevron-left hide-sidebar"><a href='#' title="Hide Sidebar" rel='tooltip'>&nbsp;</a></i> <i class="icon-chevron-right show-sidebar" style="display:none;"><a href='#' title="Show Sidebar" rel='tooltip'>&nbsp;</a></i> <li><a href="dashboard.PHP">Dashboard</a> <span class="divider"><span class="divider">/</span></li> <li><a href="#">Graphs</a></li> </ul> </div> </div> </div> <?PHP // Create connection $conn72 = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn72->connect_error) { echo "Connection failed: " . $conn72->connect_error; }
  • 43. 43 $user=$_POST['login_username']; $pass=$_POST['login_password']; // Create connection $conn71 = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn71->connect_error) { echo "Connection failed: " . $connection->connect_error; } $query = mysqli_query($conn71, "SELECT * FROM users WHERE uname = '".$_SESSION['username']."'" ) or die(mysqli_error($conn71)); $row = mysqli_fetch_array($query); $sql = "SELECT id FROM graph_local where host_id=".$row["hostid"]; $result = $conn72->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { $id=$row["id"]; $sql = "SELECT title_cache FROM graph_templates_graph where local_graph_id=".$id; $title_assoc = $conn72->query($sql); $title = $title_assoc->fetch_assoc(); $t_array = explode('-', $title['title_cache']); $t_array[1] = trim($t_array[1]); $billable = ''; if(strcmp(trim($t_array[2]),'eth0')==0 && strcmp($t_array[1],'Traffic')==0) { $billable = " --- BILLABLE"; } if(strlen(trim($t_array[2]))>0) $t_array[1] = $t_array[1] . ' - ' . trim($t_array[2]); ?> <div class="row-fluid"> <div class="block"> <div class="navbar navbar-inner block-header"> <div class="muted pull-left"><?PHP echo $t_array[1]." - Daily".$billable; ?></div> <div class="pull-right"> <a href="graphDetails.PHP?id=<?PHP echo $id;?>"><span class="badge badge-info">View More</span></a> </div> </div> <div class="block-content collapse in"> <div class="span12"> <img src="http://208.50.229.72:2080/cacti/graph_image.PHP?local_graph_id=<?PHP echo $id ?>&amp;rra_id=0&amp;graph_height=120&amp;graph_width=500&amp;title_font_size=10&amp;view_type= tree&amp;" alt="graph" style="width:50%; height:30%;"> </div> </div> </div> </div> <?PHP } }
  • 44. 44 ?> </div> </div> </div> <footer> <div class="hr"></div> <p style="margin:5px;color:#333333;">&copy; X-Verse</p> </footer> </div> <!--/.fluid-container--> <script src="vendors/jquery-1.9.1.min.js"></script> <script src="bootstrap/js/bootstrap.min.js"></script> <script src="assets/scripts.js"></script> </body> </html> Login: <?PHP session_start(); if(isset($_SESSION['username'])) if($_SESSION['username'] == 'admin') header('Location:admin.PHP'); else header('Location:dashboard.PHP'); if(isset($_SESSION['error']) && $_SESSION['error']=='WRONG') { echo '<div class="row-fluid">'; echo '<div class="alert alert-error alert-block">'; echo '<button type="button" class="close" data- dismiss="alert">&times;</button>'; echo '<h4 class="alert-heading">Failed</h4>'; echo 'INVALID USERNAME AND PASSWORD.'; echo '</div>'; echo'</div>'; $_SESSION['error']=''; } ?> <html> <head> <title>Login</title> <!-- Bootstrap --> <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen"> <link href="bootstrap/css/bootstrap-responsive.min.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="js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script> </head> <body id="login"> <div class="container"> <table style="margin:0 auto; padding = 0px; box-shadow: 0px 0px 40px black;background- color: white; border-radius:5px"> <tr>
  • 45. 45 <td style="padding: 20px"> <table style="margin:0 auto; padding-left: 20px; padding-right: 20px; box-shadow: 0px 0px 10px black; border-radius:5px"> <tr> <td> <form class="form-signin" method="POST" action="login.PHP"> <img src="images/Inet_cache.jpg" alt="logo"/> <h2 class="form-signin-heading"><b>Log In</b></h2> <span><hr style="background-color: #000000; height: 1px;"></span> <input type="text" class="input-block-level" placeholder="Username" name="login_username"> <input type="password" class="input-block-level" placeholder="Password" name="login_password" > <label class="checkbox"> <input type="checkbox" value="remember-me"> Remember Me </label> <button class="btn btn-large btn-primary" type="submit" name="submit">Sign In</button> </form> </td> </tr> </table> </td> </tr> </table> </div> <!-- /container --> <script src="vendors/jquery-1.9.1.min.js"></script> <script src="bootstrap/js/bootstrap.min.js"></script> </body> </html> GenerateGraph.PHP: <?PHP // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { echo "<br>"."Connection failed: " . $conn72->connect_error; } // Create connection $conn71 = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn71->connect_error) { echo "Connection failed: " . $connection->connect_error; } $sql =$conn71->query( "SELECT hostid FROM users where uname='".$_POST["uname"]."'" ) or die(mysqli_error($conn71)); $hostrow=$sql->fetch_assoc(); $host=$hostrow["hostid"]; $sql = "SELECT id FROM graph_templates where name='".$_POST["template"]."'"; $result_graph_templates = $conn->query($sql); $color=10; if ($result_graph_templates->num_rows > 0) { // output data of each row
  • 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