diff --git a/LibreNMS/Alert/Transport/Canopsis.php b/LibreNMS/Alert/Transport/Canopsis.php index d65fb6266d..e3e7895460 100644 --- a/LibreNMS/Alert/Transport/Canopsis.php +++ b/LibreNMS/Alert/Transport/Canopsis.php @@ -3,6 +3,9 @@ namespace LibreNMS\Alert\Transport; use LibreNMS\Alert\Transport; +use PhpAmqpLib\Connection\AMQPStreamConnection; +use PhpAmqpLib\Exchange\AMQPExchangeType; +use PhpAmqpLib\Message\AMQPMessage; class Canopsis extends Transport { @@ -30,12 +33,12 @@ class Canopsis extends Transport $exchange = 'canopsis.events'; // Connection - $conn = new \PhpAmqpLib\Connection\AMQPConnection($host, $port, $user, $pass, $vhost); + $conn = new AMQPStreamConnection($host, $port, $user, $pass, $vhost); $ch = $conn->channel(); // Declare exchange (if not exist) // exchange_declare($exchange, $type, $passive=false, $durable=false, $auto_delete=true, $internal=false, $nowait=false, $arguments=null, $ticket=null) - $ch->exchange_declare($exchange, 'topic', false, true, false); + $ch->exchange_declare($exchange, AMQPExchangeType::TOPIC, false, true, false); // Create Canopsis event, see: https://github.com/capensis/canopsis/wiki/Event-specification switch ($obj['severity']) { @@ -66,6 +69,7 @@ class Canopsis extends Transport $msg_raw = json_encode($msg_body); // Build routing key + $msg_rk = ''; if ($msg_body['source_type'] == 'resource') { $msg_rk = $msg_rk . '.' . $msg_body['resource']; } else { @@ -73,7 +77,7 @@ class Canopsis extends Transport } // Publish Event - $msg = new \PhpAmqpLib\Message\AMQPMessage($msg_raw, ['content_type' => 'application/json', 'delivery_mode' => 2]); + $msg = new AMQPMessage($msg_raw, ['content_type' => 'application/json', 'delivery_mode' => 2]); $ch->basic_publish($msg, $exchange, $msg_rk); // Close connection diff --git a/LibreNMS/Alert/Transport/Hipchat.php b/LibreNMS/Alert/Transport/Hipchat.php index 58342ee24d..1a722017ee 100644 --- a/LibreNMS/Alert/Transport/Hipchat.php +++ b/LibreNMS/Alert/Transport/Hipchat.php @@ -50,9 +50,7 @@ class Hipchat extends Transport if ($version == 2) { $url .= '/' . urlencode($option['room_id']) . '/notification?auth_token=' . urlencode($option['auth_token']); } - foreach ($obj as $key => $value) { - $api = str_replace('%' . $key, $method == 'get' ? urlencode($value) : $value, $api); - } + $curl = curl_init(); if (empty($obj['msg'])) { diff --git a/LibreNMS/Alerting/QueryBuilderParser.php b/LibreNMS/Alerting/QueryBuilderParser.php index 2acc291a69..2011e37438 100644 --- a/LibreNMS/Alerting/QueryBuilderParser.php +++ b/LibreNMS/Alerting/QueryBuilderParser.php @@ -82,6 +82,7 @@ class QueryBuilderParser implements \JsonSerializable protected $builder; protected $schema; + private $tables; private function __construct(array $builder) { diff --git a/LibreNMS/IRCBot.php b/LibreNMS/IRCBot.php index a8dcec2469..ff17b01c4a 100644 --- a/LibreNMS/IRCBot.php +++ b/LibreNMS/IRCBot.php @@ -29,6 +29,10 @@ use Permissions; class IRCBot { + private $config; + + private $user; + private $last_activity = 0; private $data = ''; @@ -78,6 +82,14 @@ class IRCBot private $floodcount = 0; + private $max_retry = 5; + + private $nickwait; + + private $buff; + + private $tokens; + public function __construct() { $this->log('Setting up IRC-Bot..'); @@ -802,7 +814,7 @@ class IRCBot foreach ($tmp as $logline) { $response = $logline['datetime'] . ' '; - $response .= $this->_color($hostid['hostname'], null, null, 'bold') . ' '; + $response .= $this->_color($logline['hostname'], null, null, 'bold') . ' '; if ($this->config['irc_alert_utf8']) { if (preg_match('/critical alert/', $logline['message'])) { $response .= preg_replace('/critical alert/', $this->_color('critical alert', 'red'), $logline['message']) . ' '; diff --git a/LibreNMS/Modules/OS.php b/LibreNMS/Modules/OS.php index 64331a35af..33005c994f 100644 --- a/LibreNMS/Modules/OS.php +++ b/LibreNMS/Modules/OS.php @@ -72,7 +72,9 @@ class OS implements Module $deviceModel->hardware = ($hardware ?? $deviceModel->hardware) ?: null; $deviceModel->features = ($features ?? $deviceModel->features) ?: null; $deviceModel->serial = ($serial ?? $deviceModel->serial) ?: null; + if (! empty($location)) { // legacy support, remove when no longer needed + /** @phpstan-ignore-next-line */ $deviceModel->setLocation($location); optional($deviceModel->location)->save(); } diff --git a/app/Models/Notification.php b/app/Models/Notification.php index 7299f01448..8919baca56 100644 --- a/app/Models/Notification.php +++ b/app/Models/Notification.php @@ -63,7 +63,7 @@ class Notification extends Model $read = new NotificationAttrib; $read->user_id = \Auth::user()->user_id; $read->key = $name; - $read->value = 1; + $read->value = '1'; $this->attribs()->save($read); return true;