Commit 3cc75121 authored by Seth D. Galitzer's avatar Seth D. Galitzer

import and sanitize files

parents
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?php
/*
* Kansas State University
* Computer Science
*
* CS System Monitoring
*
* config.php
*
* contains configuration data used by application
*
* Created by Seth Galitzer <sgsax@ksu.edu>
* Date Created: 10/22/2014
* Updated: 10/17/2016
*/
// indicate the version of Icinga you are connectiong to: [1|2]
$icingaversion=2;
// Icinga1 connection parameters
$icingaurl="https://your.icinga.host.org";
$icingaport=8443; // use your port here
$icingacgi="cgi-bin/icinga/status.cgi";
// Icinga2 connection parameters
$icinga2url="https://your.icinga2.host.org";
$icinga2port=5665; // change if using non-standard port
$icinga2apipath="v1/objects";
$icinga2ca="/path/to/your/ca/cert.crt";
// authentication for either version
$icingauser="username";
$icingapass="password";
// Icinga 1 queries are filters passed as url parameters
$queryhosts="style=hostdetail&hostprops=10&hoststatustypes=12&jsonoutput";
$querysvcs="serviceprops=10&servicestatustypes=28&jsonoutput";
$queryall="allproblems&hostprops=10&hoststatustypes=12&serviceprops=10&servicestatustypes=28&jsonoutput";
$queryhostgroups="hostgroup=all&style=summary&jsonoutput";
$queryhostgroup="style=overview&jsonoutput&hostgroup=";
$queryhost="style=detaili&jsonoutput&host=";
$queryhostgroupdetail="style=detail&jsonoutput&hostgroup=";
$queryservicedetail="jsonoutput&style=detail&servicestatustypes=28&hostgroup=";
// Icinga 2 queries are passed as an array to the RESTful web service
$query2hosts = array(
'attrs' => array('name', 'state', 'last_check_result', 'display_name'),
'filter' => 'host.state!=0&&host.downtime_depth==0&&host.acknowledgement==0'
);
$query2services = array(
'attrs' => array('name', 'state', 'last_check', 'last_check_result', 'display_name', 'acknowledgement'),
'joins' => array('host.name', 'host.state'),
'filter' => 'service.state!=ServiceOK&&service.downtime_depth==0&&service.acknowledgement==0&&host.downtime_depth==0&&host.acknowledgement==0&&host.state==0'
);
$query2hostgroups = array(
'attrs' => array('name','state'),
'joins' => array('host.name','host.state','host.groups')
);
?>
/* add special scrollable class for dropdown */
.scrollable-menu {
height: auto;
max-height: 400px; /* modify to suit your needs */
overflow-x: hidden;
}
/* need this to pad for fixed navbar */
body { padding-top: 80px; }
This diff is collapsed.
<?php
/*
* Kansas State University
* Computer Science
*
* CS System Monitoring
*
* host.php
*
* prepare and display information for a specific host
*
* Created by Seth Galitzer <sgsax@ksu.edu>
* Date Created: 10/22/2014
* Updated: 10/17/2016
*/
// session_start();
require_once "config.php";
require_once "handler.php";
// // initialize session token
// $_SESSION["token"] = md5(mt_rand());
$host="";
if (!empty($_GET)) {
$host=htmlspecialchars($_GET["host"]);
}
if($host != "") {
if ($icingaversion == 1) {
$json_data = getJSON($queryhost . $host);
} else {
$json_data = getJSON2(query2host($host), "services");
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Systems Status - <?php echo $host; ?></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="css/icingahud.css" />
</head>
<body>
<?php include "nav.php"; ?>
<div class="container">
<div class="row">
<div class="span12">
<p class="lead">Host Details</p>
<h2><?php print $host; ?></h2>
<?php printHostDetails($json_data, $icingaversion); ?>
</div><!-- /.span12 -->
</div><!-- /.row -->
</div><!-- /.container -->
</body>
</html>
<?php
/*
* Kansas State University
* Computer Science
*
* CS System Monitoring
*
* hostgroup.php
*
* prepare and display infomration for a specific hostgroup
*
* Created by Seth Galitzer <sgsax@ksu.edu>
* Date Created: 10/22/2014
* Updated: 10/17/2016
*/
// session_start();
require_once "config.php";
require_once "handler.php";
// // initialize session token
// $_SESSION["token"] = md5(mt_rand());
$hostgroup="";
if (!empty($_GET)) {
$hostgroup=htmlspecialchars($_GET["hostgroup"]);
}
if($hostgroup != "") {
if ($icingaversion == 1) {
$json_data = getJSON($queryhostgroup . $hostgroup);
$hostcount = countHostsInGroup($json_data, $icingaversion);
} else {
$json_data = getJSON2(query2hostgroup($hostgroup), "services");
$hostcount = countHostsInGroup($json_data, $icingaversion);
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Systems Status - <?php echo $hostgroup; ?></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="css/icingahud.css" />
</head>
<body>
<?php include "nav.php"; ?>
<div class="container">
<div class="row">
<div class="span12">
<p class="lead">Hostgroup Overview for <?php print $hostgroup; ?></p>
<h2><?php print $hostgroup; ?> (<?php print $hostcount; ?> hosts)</h2>
<?php
if($hostgroup != "") {
printHostgroupDetails($json_data, $icingaversion);
} else {
print "No hostgroup selected<br>\n";
}
?>
</div><!-- /.span12 -->
</div><!-- /.row -->
</div><!-- /.container -->
</body>
</html>
<?php
/*
* Kansas State University
* Computer Science
*
* CS System Monitoring
*
* hostgroups.php
*
* prepare and display information for all hostgroups
*
* Created by Seth Galitzer <sgsax@ksu.edu>
* Date Created: 10/22/2014
* Updated: 10/17/2016
*/
// session_start();
require_once "config.php";
require_once "handler.php";
// // initialize session token
// $_SESSION["token"] = md5(mt_rand());
if ($icingaversion == 1) {
$json_data = getJSON($queryhostgroups);
$hostgroups = getHostgroupInfo($json_data);
} else {
$json_data = getJSON2($query2hostgroups, "services");
$hostgroups = getHostgroupInfo2($json_data);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Systems Status - All Hostgroups</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="css/icingahud.css" />
</head>
<body>
<?php include "nav.php"; ?>
<div class="container">
<div class="row">
<div class="span12">
<p class="lead">Hostgroups Overview</p>
<h2>Hostgroups (<?php print count($hostgroups); ?> groups)</h2>
<?php printHostgroupInfo($hostgroups); ?>
</div><!-- /.span12 -->
</div><!-- /.row -->
</div><!-- /.container -->
</body>
</html>
<?php
/*
* Kansas State University
* Computer Science
*
* CS System Monitoring
*
* hosts.php
*
* prepare and display information for all hosts with problems
*
* Created by Seth Galitzer <sgsax@ksu.edu>
* Date Created: 10/22/2014
* Updated: 10/17/2016
*/
// session_start();
require_once "config.php";
require_once "handler.php";
// // initialize session token
// $_SESSION["token"] = md5(mt_rand());
if ($icingaversion == 1) {
$json_data = getJSON($queryhosts);
} else {
$json_hosts = getJSON2($query2hosts, "hosts");
$json_data = array('hosts' => $json_hosts);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Systems Status - All Host Problems</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="css/icingahud.css" />
</head>
<body>
<?php include "nav.php"; ?>
<div class="container">
<div class="row">
<div class="span12">
<p class="lead">Host Problems Overview</p>
<h2>Hosts</h2>
<?php printHostInfo($json_data, $icingaversion); ?>
</div><!-- /.span12 -->
</div><!-- /.row -->
</div><!-- /.container -->
</body>
</html>
<?php
/*
* Kansas State University
* Computer Science
*
* CS System Monitoring
*
* index.php
*
* main page
* prepare and display information for hosts and services with problems.
*
* Created by Seth Galitzer <sgsax@ksu.edu>
* Date Created: 10/22/2014
* Updated: 10/17/2016
*/
// session_start();
require_once "config.php";
require_once "handler.php";
// // initialize session token
// $_SESSION["token"] = md5(mt_rand());
if ($icingaversion == 1) {
$json_data = getJSON($queryall);
} else {
$json_hosts = getJSON2($query2hosts, "hosts");
$json_services = getJSON2($query2services, "services");
$json_data = array('hosts' => $json_hosts, 'services' => $json_services);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>CS Systems Status Overview</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="css/icingahud.css" />
<script src="bootstrap/js/bootstrap.min.js"></script>
</head>
<body>
<?php include "nav.php"; ?>
<div class="container">
<div class="row">
<div class="span12">
<p class="lead">All Problems Overview</p>
<h2>Hosts</h2>
<?php printHostInfo($json_data, $icingaversion); ?>
<h2>Services</h2>
<?php printServiceInfo($json_data, $icingaversion); ?>
</div><!-- /.span12 -->
</div><!-- /.row -->
</div><!-- /.container -->
</body>
</html>
<?php
/*
* Kansas State University
* Computer Science
*
* CS System Monitoring
*
* nav.php
*
* prepare and display navagation header used for all pages
*
* Created by Seth Galitzer <sgsax@ksu.edu>
* Date Created: 10/22/2014
* Updated: 10/17/2016
*/
require_once "config.php";
require_once "handler.php";
function echoActiveClassIfRequestMatches($requestUri) {
/* highlight menu item for current page */
$current_file_name = basename($_SERVER['REQUEST_URI'], ".php");
if ($current_file_name == $requestUri) {
echo 'class="active"';
}
}
function buildHostgroupMenu() {
/* get list of all hostgroups and generate list of links to show data for */
/* each of them; used in drop-down menu item */
require "config.php";
if ($icingaversion == 1) {
$json_data = getJSON($queryhostgroups);
$hostgrps = getHostgroupInfo($json_data);
} else {
$json_data = getJSON2($query2hostgroups, "services");
$hostgrps = getHostgroupInfo2($json_data);
}
foreach($hostgrps as $hostgrp) {
print "<li><a href=\"hostgroup.php?hostgroup=$hostgrp[hostgroup_name]\">$hostgrp[hostgroup_name]</a></li>\n";
}
}
?>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Systems</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li <?=echoActiveClassIfRequestMatches("")?>><a href="/">Overview</a></li>
<li <?=echoActiveClassIfRequestMatches("hosts")?>><a href="/hosts.php">Hosts</a></li>
<li <?=echoActiveClassIfRequestMatches("services")?>><a href="/services.php">Services</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Hostgroups <span class="caret"></span></a>
<ul class="dropdown-menu scrollable-menu" role="menu">
<li><a href="hostgroups.php">All</a></li>
<li class="divider"></li>
<?php buildHostgroupMenu() ?>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<?php
/*
* Kansas State University
* Computer Science
*
* CS System Monitoring
*
* services.php
*
* prepare and display information for services with problems
*
* Created by Seth Galitzer <sgsax@ksu.edu>
* Date Created: 10/22/2014
* Updated: 10/17/2016
*/
// session_start();
require_once "config.php";
require_once "handler.php";
// // initialize session token
// $_SESSION["token"] = md5(mt_rand());
if ($icingaversion == 1) {
$json_data = getJSON($queryall);
} else {
$json_services = getJSON2($query2services, "services");
$json_data = array('services' => $json_services);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Systems Status - All Service Problems</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="css/icingahud.css" />
</head>
<body>
<?php include "nav.php"; ?>
<div class="container">
<div class="row">
<div class="span12">
<p class="lead"> Service Problems Overview</p>
<h2>Services</h2>
<?php printServiceInfo($json_data, $icingaversion); ?>
</div><!-- /.span12 -->
</div><!-- /.row -->
</div><!-- /.container -->
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment