Skip to content

Commit

Permalink
Add ability to hide the index page. Update the default location to to…
Browse files Browse the repository at this point in the history
…p for alert message.
  • Loading branch information
jomann09 committed Jun 19, 2019
1 parent 89aa3f2 commit ddc843c
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 42 deletions.
8 changes: 5 additions & 3 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
2.0.0 - ??/??/????
2.0.0 - 06/20/2019
------------------
- Changed license to GPLv3 (#32) -BH,EG
- Fixed debug_log variable not being used (#36)
- Added the config option to hide the index.php submit commands page -JO
- Updated license to GPLv3 (#32) -BH,EG
- Updated default location of alert on the main index.php when running checks -JO
- Fixed debug_log variable not being used (#36) -JO

1.5.2 - 04/02/2018
------------------
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Download the latest tarball and extract to start the install:

```
cd /tmp
wget https://github.com/NagiosEnterprises/nrdp/archive/1.5.2.tar.gz
tar xvf 1.5.2.tar.ggz
wget https://github.com/NagiosEnterprises/nrdp/archive/2.0.0.tar.gz
tar xvf 2.0.0.tar.gz
cd nrdp-*
```

Expand All @@ -37,14 +37,14 @@ Edit the NRDP server config file and add your token to the `$cfg['authorized_tok
vi /usr/local/nrdp/server/config.inc.php
```

Configure Apache depending on the current Apache version and operating system. If you're using a newer version of Apache you may need to change this file slightly. This has been tested to work with CentOS 6:
Configure Apache depending on the current Apache version and operating system. If you're using a newer version of Apache you may need to change this file slightly. This has been tested to work with CentOS 6 and 7:

```
cp nrdp.conf /etc/httpd/conf.d
service httpd restart
```

And on Ubuntu 16.0.4:
And on Ubuntu 16 and 18 LTS:

```
cp nrdp.conf /etc/apache2/sites-enabled/nrdp.conf
Expand Down
17 changes: 13 additions & 4 deletions clients/send_nrdp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
#
#############################################################################
#
# 2017-09-25 Troy Lea aka BOX293
# 2019-06-19 Jake Omann
# - Fixed issue with XML output formatting on some PHP versions
#
# 2017-09-25 Troy Lea aka BOX293
# - Fixed script not working with arguments when run as a cron job
# or if being used as a nagios command like obsessive compulsive.
# ... "if [ ! -t 0 ]" was the reason why.
Expand Down Expand Up @@ -236,7 +238,8 @@ if [ $host ]; then
exit 2
fi
if [ "$service" != "" ]; then
xml="$xml<checkresult type='service' checktype='$checktype'><servicename>$service</servicename>"
xml="$xml<checkresult type='service' checktype='$checktype'>
<servicename>$service</servicename>"
else
xml="$xml<checkresult type='host' checktype='$checktype'>"
fi
Expand All @@ -246,7 +249,10 @@ if [ $host ]; then
output=${output//</%3C}
output=${output//>/%3E}

xml="$xml<hostname>$host</hostname><state>$State</state><output><![CDATA["$output"]]></output></checkresult>"
xml="$xml<hostname>$host</hostname>
<state>$State</state>
<output><![CDATA["$output"]]></output>
</checkresult>"
checkcount=1
fi

Expand Down Expand Up @@ -301,7 +307,10 @@ if [ $directory ]; then
fi

if [ "x$file" == "x" ] && [ "x$directory" == "x" ]; then
xml="<?xml version='1.0'?><checkresults>$xml</checkresults>"
xml="<?xml version='1.0'?>
<checkresults>
$xml
</checkresults>"
send_data "$xml"
echo "Sent $checkcount checks to $url"
fi
10 changes: 10 additions & 0 deletions server/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@



/////////////////////////////////////////////////////////////
//
// hide_display_page
//
// Should the main NRDP display page that allows submissions be hidden? true/false

$cfg["hide_display_page"] = false;



/////////////////////////////////////////////////////////////
//
// debug
Expand Down
3 changes: 1 addition & 2 deletions server/includes/bootstrap.bundle.min.js

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions server/includes/bootstrap.min.css

Large diffs are not rendered by default.

38 changes: 11 additions & 27 deletions server/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,46 +26,33 @@
*****************************************************************************/



//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
// Page Settings
// (Change these variables to customize your NRDP landing page)
///////////////////



// Should we display a token by default?
$display_token = true;
$page_token = "token";



// There are several tabs you can land on

//$default_tab = "command";
//$default_tab = "checkresult";
//$default_tab = "xml";
$default_tab = "json";



// Do you want the alerts at the top of the page? Or on the bottom?
//$display_alerts = "top";
$display_alerts = "bottom";

//$display_alerts = "bottom";
$display_alerts = "top";


// What is the alert message timeout? (in seconds)

$alert_timeout = 3;



// This is the example data that will be populated in the data on the page

$fake_command = "DISABLE_HOST_NOTIFICATIONS";
$fake_host_name = "somehost";
$fake_service_description = "someservice";
Expand All @@ -77,8 +64,6 @@
//////////////////////////////////////////////////////////////////////////////////




require_once(dirname(__FILE__) . "/config.inc.php");
require_once(dirname(__FILE__) . "/includes/utils.inc.php");

Expand All @@ -97,27 +82,26 @@

function route_request()
{
global $cfg;
$cmd = strtolower(grab_request_var("cmd"));

// if no command was specified
if (empty($cmd)) {
// If no command was specified check if we should show the options
if (empty($cmd) && empty($cfg['hide_display_page'])) {
display_form();
}


if ($cmd == "hello") {
say_hello();
}


$args = array(
"cmd" => $cmd
);
do_callbacks(CALLBACK_PROCESS_REQUEST, $args);


// a callback should have exited already
echo "NO REQUEST HANDLER";
// A callback should have exited already
echo "No command specified or request handler";
exit();
}

Expand Down Expand Up @@ -215,8 +199,8 @@ function check_message_status(status, msg) {

function success_xml(xml) {

console.log("success_xml(xml) data:");
console.log(xml);
//console.log("success_xml(xml) data:");
//console.log(xml);

var status = $(xml).find("status").text();
var msg = $(xml).find("message").text();
Expand All @@ -226,8 +210,8 @@ function success_xml(xml) {

function success_json(json) {

console.log("success_json(json) data:");
console.log(json);
//console.log("success_json(json) data:");
//console.log(json);

var status = json.result.status;
var msg = json.result.message;
Expand Down

0 comments on commit ddc843c

Please sign in to comment.