PHP code example of xp-forge / nsca

1. Go to this page and download the library: Download xp-forge/nsca library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xp-forge / nsca example snippets


use org\nagios\nsca\{NscaClient, NscaMessage, NscaProtocol};

$c= new NscaClient('nagios.example.com');
$c->connect();

$c->send(new NscaMessage(
  'ws.example.com', 
  'queue_check', 
  NscaProtocol::OK,
  'Up and running'
));
$c->send(new NscaMessage(
  'ws.example.com', 
  'queue_check', 
  NscaProtocol::ERROR,
  'No answer on port 80 after 2 seconds'
));

$c->close();