api: Added add_service_for_host endpoint to API (#8113)

* Add add_service_for_host endpoint to API

Signed-off-by: Rémy Jacquin <remy@remyj.fr>

* Change permissions to allow users to modify device

Signed-off-by: Rémy Jacquin <remy@remyj.fr>
This commit is contained in:
Rémy Jacquin
2018-01-21 20:56:57 +01:00
committed by Neil Lathwood
parent 8a9fc7783d
commit e12e6720f8
6 changed files with 99 additions and 7 deletions

View File

@@ -306,3 +306,20 @@ function check_service($command)
return array ($status, $response, $metrics);
}
/**
* List all available services from nagios plugins directory
*
* @return array
*/
function list_available_services()
{
global $config;
$services = array();
foreach (scandir($config['nagios_plugins']) as $file) {
if (substr($file, 0, 6) === 'check_') {
$services[] = substr($file, 6);
}
}
return $services;
}