I created new transport type Apicertauth.php and when I try to use it I get error. I troubleshooted a lot and found that I can trigger ticketing system using curl with cert and key files, also I create a php file (below) out of librenms system on the same server and tried executing and it was success.
But when I try to execute any files in Transport directory I get error at the class line. I just copied the contents of Api.php to Apicertauth.php, this new type shows up in GUI. validation is good even the dump-autoload looks good.
FAILED PHP:
root@SERVER:/opt/librenms/LibreNMS/Alert/Transport#
root@SERVER:/opt/librenms/LibreNMS/Alert/Transport# php Apicertauth.php
PHP Fatal error: Uncaught Error: Class “LibreNMS\Alert\Transport” not found in /opt/librenms/LibreNMS/Alert/Transport/Apicertauth.php:10
Stack trace:
#0 {main}
thrown in /opt/librenms/LibreNMS/Alert/Transport/Apicertauth.php on line 10
root@SERVER:/opt/librenms/LibreNMS/Alert/Transport# php Ciscospark.php
PHP Fatal error: Uncaught Error: Class “LibreNMS\Alert\Transport” not found in /opt/librenms/LibreNMS/Alert/Transport/Ciscospark.php:20
Stack trace:
#0 {main}
thrown in /opt/librenms/LibreNMS/Alert/Transport/Ciscospark.php on line 20
root@SERVER:/opt/librenms/LibreNMS/Alert/Transport#
PHP FILE:
root@SERVER:/home/azureuser# cat testapicall.php
<?php
$cert = "/path_to/cert.pem";
$key = "/path_to/key.pem";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://SOMEURL");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type: application/json"]);
curl_setopt($ch, CURLOPT_SSLCERT, $cert);
curl_setopt($ch, CURLOPT_SSLKEY, $key);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(["details" => "Test"]));
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "Response Code: " . $http_code . "\n";
echo "Response: " . $response . "\n";
?>
root@SERVER:/home/azureuser#