Code: Select all
[nagios@<client_hostname> ~]$ curl -k -vvv 'https://<host>/nrdp/' >curlk.txt
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* About to connect() to <host> port 443 (#0)
* Trying <nagiosIP>...
* Connected to <host> (<nagiosIP>) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* skipping SSL peer certificate verification
* SSL connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
* Server certificate:
* subject: OU=cse,CN=<host>,<>
* start date: Jun 27 18:16:22 2019 GMT
* expire date: Jun 24 18:16:22 2029 GMT
* common name: <host>
* issuer: <>
> GET /nrdp/ HTTP/1.1
> User-Agent: curl/7.29.0
> Host: <host>
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Fri, 17 Apr 2020 17:27:43 GMT
< Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/5.4.16
< X-Powered-By: PHP/5.4.16
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=UTF-8
<
{ [data not shown]
100 10594 0 10594 0 0 70209 0 --:--:-- --:--:-- --:--:-- 70626
* Connection #0 to host <host> left intact
[nagios@<client_hostname> ~]$ cat curlk.txt
<!doctype html>
<html>
<head>
<title>Nagios Remote Data Processor</title>
<script type="text/javascript" src="includes/jquery-3.2.1.min.js"></script>
<link href="includes/bootstrap.min.css" rel="stylesheet" />
<script type="text/javascript" src="includes/bootstrap.bundle.min.js"></script>
<style>
body {
margin: 2em 0;
}
.btn {
margin-top: 2em;
cursor: pointer;
}
.tab-content {
margin: 1em 0;
}
.token-group {
margin-top: 1em;
}
</style>
<script type="text/javascript">
// number of seconds to keep the alerts
var alert_timeout = 3;
function build_alert(cssclass, msg) {
var $alert = $("<div class=\"alert alert-" + cssclass + " form-control-sm\">" + msg + "</div>");
$(".messages").html($alert);
return $alert;
}
function check_message_status(status, msg) {
var $alertbox;
if (status != 0) {
$alertbox = build_alert("danger", msg);
} else {
$alertbox = build_alert("info", msg);
}
setTimeout(function() { $alertbox.remove(); }, (alert_timeout * 1000));
}
function success_xml(xml) {
//console.log("success_xml(xml) data:");
//console.log(xml);
var status = $(xml).find("status").text();
var msg = $(xml).find("message").text();
check_message_status(status, msg);
}
function success_json(json) {
//console.log("success_json(json) data:");
//console.log(json);
var status = json.result.status;
var msg = json.result.message;
check_message_status(status, msg);
}
$(function() {
// get the page hash so we can set the appropriate tabs
var page_hash = $(location).attr("hash").substr(1);
if (page_hash == "") {
// use the php defined default if no hash is used
page_hash = "json";
}
if (page_hash == "command") {
// this is the default, so we don't need to do anything
}
else if (page_hash == "checkresult") {
$(".nav-tabs a[href='#checkresult'").tab("show");
}
else if (page_hash == "xml") {
$(".nav-tabs a[href='#checkresult'").tab("show");
// we don't need to explicitly show the xml tab either
// since it is the default
//$(".nav-tabs a[href='#xml'").tab("show");
}
else if (page_hash == "json") {
$(".nav-tabs a[href='#checkresult'").tab("show");
$(".nav-tabs a[href='#json'").tab("show");
}
$(".submit-command").click(function() {
$.ajax({
type: "GET",
data: {
cmd: "submitcmd",
token: $("#token").val(),
command: $("#extcommand").val()
},
success: function(xml) { success_xml(xml); }
});
});
$(".submit-checkresult-xml").click(function() {
$.ajax({
type: "POST",
dataType: "xml",
data: {
cmd: "submitcheck",
token: $("#token").val(),
xml: $("#xml-data").val()
},
success: function(xml) { success_xml(xml); }
});
});
$(".submit-checkresult-json").click(function() {
$.ajax({
type: "POST",
dataType: "json",
data: {
cmd: "submitcheck",
token: $("#token").val(),
json: $("#json-data").val()
},
success: function(json) { success_json(json); }
});
});
});
</script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-12">
<h2>NRDP · Nagios Remote Data Processor</h2>
</div>
</div>
<hr />
<!-- this is where the alerts show up -->
<div class="row">
<div class="col-12 messages">
</div>
</div>
<hr />
<div class="row">
<div class="col-12">
<ul class="nav nav-tabs" id="action-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="command-tab" data-toggle="tab" href="#command" role="tab" aria-controls="command" aria-selected="true">Submit Nagios Command</a>
</li>
<li class="nav-item">
<a class="nav-link" id="checkresult-tab" data-toggle="tab" href="#checkresult" role="tab" aria-controls="checkresult" aria-selected="false">Submit Check Result</a>
</li>
</ul>
<!-- token is used everywhere -->
<div class="form-group token-group">
<label for="token">Token</label>
<input type="text" name="token" id="token" value="token" placeholder="token" class="form-control form-control-sm">
<small class="form-text">
Use the token you've configured in your <code>config.inc.php</code> file.
</small>
</div>
<!-- command / check result tabs -->
<div class="tab-content" id="action-contents">
<!-- command tab -->
<div class="tab-pane fade show active" id="command" role="tabpanel" aria-labelledby="command-tab">
<div class="form-group">
<label for="extcommand">Command</label>
<input type="text" name="command" id="extcommand" value="DISABLE_HOST_NOTIFICATIONS;somehost" class="form-control form-control-sm">
<small id="command-command-help" class="form-text">
Specify your command string here. Helpful information <a href="https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/extcommands.html">can be found here.</a>
</small>
</div>
<a href="#" class="btn btn-primary submit-command">Submit Command</a>
</div><!-- /command-tab -->
<!-- checkresult tab -->
<div class="tab-pane fade" id="checkresult" role="tabpanel" aria-labelledby="checkresult-tab">
<ul class="nav nav-tabs" id="crtype-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="xml-tab" data-toggle="tab" href="#xml" role="tab" aria-controls="xml" aria-selected="true">XML Check Result</a>
</li>
<li class="nav-item">
<a class="nav-link" id="json-tab" data-toggle="tab" href="#json" role="tab" aria-controls="json" aria-selected="false">JSON Check Result</a>
</li>
</ul>
<!-- xml / json check result tabs -->
<div class="tab-content" id="crtpe-contents">
<!-- xml tab -->
<div class="tab-pane fade show active" id="xml" role="tabpanel" aria-labelledby="xml-tab">
<form method="post">
<div class="form-group">
<textarea rows="19" name="xml" id="xml-data" class="form-control form-control-sm"><?xml version='1.0'?>
<checkresults>
<checkresult type='host'>
<hostname>somehost</hostname>
<state>0</state>
<output>Everything looks okay! | perfdata=1;</output>
</checkresult>
<checkresult type='service'>
<hostname>somehost</hostname>
<servicename>someservice</servicename>
<state>1</state>
<output>WARNING: Danger Will Robinson! | perfdata=1;</output>
</checkresult>
</checkresults></textarea>
<small class="form-text">
Check result data in XML format.
</small>
</div>
<a href="#" class="btn btn-primary submit-checkresult-xml">Submit XML Check Result</a>
</div><!-- /xmltab -->
<!-- json tab -->
<div class="tab-pane fade" id="json" role="tabpanel" aria-labelledby="json-tab">
<div class="form-group">
<textarea rows="23" name="json" id="json-data" class="form-control form-control-sm">{
"checkresults": [
{
"checkresult": {
"type": "host"
},
"hostname": "somehost",
"state": "0",
"output": "Everything looks okay! | perfdata=1;"
},
{
"checkresult": {
"type": "service"
},
"hostname": "somehost",
"servicename": "someservice",
"state": "1",
"output": "WARNING: Danger Will Robinson! | perfdata=1;"
}
]
}</textarea>
<small class="form-text">
Check result data in JSON format.
</small>
</div>
<a href="#" class="btn btn-primary submit-checkresult-json">Submit JSON Check Result</a>
</div><!-- /jsontab -->
</div><!-- /xml&json check result tabs -->
</div><!-- /checkresult tab -->
</div><!-- /action-contents -->
</div><!-- /col-12 -->
</div><!-- /row -->
</div><!-- /container -->
</body>
</html>
Code: Select all
[nagios@<client_hostname> ~]$ curl -k -L -vvv 'https://<host>/nrdp/'> curlKL.txt
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* About to connect() to <host> port 443 (#0)
* Trying <nagiosIP>...
* Connected to <host> (<nagiosIP>) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* skipping SSL peer certificate verification
* SSL connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
* Server certificate:
* subject: OU=cse,CN=<host>,<>
* start date: Jun 27 18:16:22 2019 GMT
* expire date: Jun 24 18:16:22 2029 GMT
* common name: <>
* issuer: <>
> GET /nrdp/ HTTP/1.1
> User-Agent: curl/7.29.0
> Host: <host>
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Fri, 17 Apr 2020 17:20:07 GMT
< Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/5.4.16
< X-Powered-By: PHP/5.4.16
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=UTF-8
<
{ [data not shown]
100 10594 0 10594 0 0 61897 0 --:--:-- --:--:-- --:--:-- 61953
* Connection #0 to host <host> left intact
[nagios@<client_hostname> ~]$ cat curlKL.txt
<!doctype html>
<html>
<head>
<title>Nagios Remote Data Processor</title>
<script type="text/javascript" src="includes/jquery-3.2.1.min.js"></script>
<link href="includes/bootstrap.min.css" rel="stylesheet" />
<script type="text/javascript" src="includes/bootstrap.bundle.min.js"></script>
<style>
body {
margin: 2em 0;
}
.btn {
margin-top: 2em;
cursor: pointer;
}
.tab-content {
margin: 1em 0;
}
.token-group {
margin-top: 1em;
}
</style>
<script type="text/javascript">
// number of seconds to keep the alerts
var alert_timeout = 3;
function build_alert(cssclass, msg) {
var $alert = $("<div class=\"alert alert-" + cssclass + " form-control-sm\">" + msg + "</div>");
$(".messages").html($alert);
return $alert;
}
function check_message_status(status, msg) {
var $alertbox;
if (status != 0) {
$alertbox = build_alert("danger", msg);
} else {
$alertbox = build_alert("info", msg);
}
setTimeout(function() { $alertbox.remove(); }, (alert_timeout * 1000));
}
function success_xml(xml) {
//console.log("success_xml(xml) data:");
//console.log(xml);
var status = $(xml).find("status").text();
var msg = $(xml).find("message").text();
check_message_status(status, msg);
}
function success_json(json) {
//console.log("success_json(json) data:");
//console.log(json);
var status = json.result.status;
var msg = json.result.message;
check_message_status(status, msg);
}
$(function() {
// get the page hash so we can set the appropriate tabs
var page_hash = $(location).attr("hash").substr(1);
if (page_hash == "") {
// use the php defined default if no hash is used
page_hash = "json";
}
if (page_hash == "command") {
// this is the default, so we don't need to do anything
}
else if (page_hash == "checkresult") {
$(".nav-tabs a[href='#checkresult'").tab("show");
}
else if (page_hash == "xml") {
$(".nav-tabs a[href='#checkresult'").tab("show");
// we don't need to explicitly show the xml tab either
// since it is the default
//$(".nav-tabs a[href='#xml'").tab("show");
}
else if (page_hash == "json") {
$(".nav-tabs a[href='#checkresult'").tab("show");
$(".nav-tabs a[href='#json'").tab("show");
}
$(".submit-command").click(function() {
$.ajax({
type: "GET",
data: {
cmd: "submitcmd",
token: $("#token").val(),
command: $("#extcommand").val()
},
success: function(xml) { success_xml(xml); }
});
});
$(".submit-checkresult-xml").click(function() {
$.ajax({
type: "POST",
dataType: "xml",
data: {
cmd: "submitcheck",
token: $("#token").val(),
xml: $("#xml-data").val()
},
success: function(xml) { success_xml(xml); }
});
});
$(".submit-checkresult-json").click(function() {
$.ajax({
type: "POST",
dataType: "json",
data: {
cmd: "submitcheck",
token: $("#token").val(),
json: $("#json-data").val()
},
success: function(json) { success_json(json); }
});
});
});
</script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-12">
<h2>NRDP · Nagios Remote Data Processor</h2>
</div>
</div>
<hr />
<!-- this is where the alerts show up -->
<div class="row">
<div class="col-12 messages">
</div>
</div>
<hr />
<div class="row">
<div class="col-12">
<ul class="nav nav-tabs" id="action-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="command-tab" data-toggle="tab" href="#command" role="tab" aria-controls="command" aria-selected="true">Submit Nagios Command</a>
</li>
<li class="nav-item">
<a class="nav-link" id="checkresult-tab" data-toggle="tab" href="#checkresult" role="tab" aria-controls="checkresult" aria-selected="false">Submit Check Result</a>
</li>
</ul>
<!-- token is used everywhere -->
<div class="form-group token-group">
<label for="token">Token</label>
<input type="text" name="token" id="token" value="token" placeholder="token" class="form-control form-control-sm">
<small class="form-text">
Use the token you've configured in your <code>config.inc.php</code> file.
</small>
</div>
<!-- command / check result tabs -->
<div class="tab-content" id="action-contents">
<!-- command tab -->
<div class="tab-pane fade show active" id="command" role="tabpanel" aria-labelledby="command-tab">
<div class="form-group">
<label for="extcommand">Command</label>
<input type="text" name="command" id="extcommand" value="DISABLE_HOST_NOTIFICATIONS;somehost" class="form-control form-control-sm">
<small id="command-command-help" class="form-text">
Specify your command string here. Helpful information <a href="https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/extcommands.html">can be found here.</a>
</small>
</div>
<a href="#" class="btn btn-primary submit-command">Submit Command</a>
</div><!-- /command-tab -->
<!-- checkresult tab -->
<div class="tab-pane fade" id="checkresult" role="tabpanel" aria-labelledby="checkresult-tab">
<ul class="nav nav-tabs" id="crtype-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="xml-tab" data-toggle="tab" href="#xml" role="tab" aria-controls="xml" aria-selected="true">XML Check Result</a>
</li>
<li class="nav-item">
<a class="nav-link" id="json-tab" data-toggle="tab" href="#json" role="tab" aria-controls="json" aria-selected="false">JSON Check Result</a>
</li>
</ul>
<!-- xml / json check result tabs -->
<div class="tab-content" id="crtpe-contents">
<!-- xml tab -->
<div class="tab-pane fade show active" id="xml" role="tabpanel" aria-labelledby="xml-tab">
<form method="post">
<div class="form-group">
<textarea rows="19" name="xml" id="xml-data" class="form-control form-control-sm"><?xml version='1.0'?>
<checkresults>
<checkresult type='host'>
<hostname>somehost</hostname>
<state>0</state>
<output>Everything looks okay! | perfdata=1;</output>
</checkresult>
<checkresult type='service'>
<hostname>somehost</hostname>
<servicename>someservice</servicename>
<state>1</state>
<output>WARNING: Danger Will Robinson! | perfdata=1;</output>
</checkresult>
</checkresults></textarea>
<small class="form-text">
Check result data in XML format.
</small>
</div>
<a href="#" class="btn btn-primary submit-checkresult-xml">Submit XML Check Result</a>
</div><!-- /xmltab -->
<!-- json tab -->
<div class="tab-pane fade" id="json" role="tabpanel" aria-labelledby="json-tab">
<div class="form-group">
<textarea rows="23" name="json" id="json-data" class="form-control form-control-sm">{
"checkresults": [
{
"checkresult": {
"type": "host"
},
"hostname": "somehost",
"state": "0",
"output": "Everything looks okay! | perfdata=1;"
},
{
"checkresult": {
"type": "service"
},
"hostname": "somehost",
"servicename": "someservice",
"state": "1",
"output": "WARNING: Danger Will Robinson! | perfdata=1;"
}
]
}</textarea>
<small class="form-text">
Check result data in JSON format.
</small>
</div>
<a href="#" class="btn btn-primary submit-checkresult-json">Submit JSON Check Result</a>
</div><!-- /jsontab -->
</div><!-- /xml&json check result tabs -->
</div><!-- /checkresult tab -->
</div><!-- /action-contents -->
</div><!-- /col-12 -->
</div><!-- /row -->
</div><!-- /container -->
</body>
</html>