Skip to content

[CrateDB] Replace crate-pdo with REST-API #9

@nook24

Description

@nook24

Replace crate-pdo with the Crate HTTP Rest API.

Example

<?php

    /**
     * @param bool $isRecursion
     * @return bool
     */
    public function insert($isRecursion = false){
        /**
         * @var Servicestatus $Servicestatus
         */
        $restQuery = [
            'stmt' => sprintf($this->baseQuery, $this->baseValue),
            'bulk_args' => []
        ];
        foreach ($this->BulkInsertObjectStore->getObjects() as $key => $Servicestatus) {
            $restQuery['bulk_args'][] = [
                $Servicestatus->getHostname(),
                $Servicestatus->getServicedescription(),
                $Servicestatus->getStatusUpdateTime(),
                $Servicestatus->getPluginOutput(),
                $Servicestatus->getLongPluginOutput(),
                $Servicestatus->getPerfdata(),
                $Servicestatus->getCurrentState(),
                $Servicestatus->getCurrentAttempt(),
                $Servicestatus->getMaxAttempts(),
                $Servicestatus->getLastCheck(),
                $Servicestatus->getNextCheck(),
                $Servicestatus->getIsActiveCheckResult(),
                $Servicestatus->getLastStateChange(),
                $Servicestatus->getLastHardStateChange(),
                $Servicestatus->getLastHardState(),
                $Servicestatus->isHardState(),
                $Servicestatus->getLastNotification(),
                $Servicestatus->getNextNotification(),
                $Servicestatus->isNotificationsEnabled(),
                $Servicestatus->isProblemHasBeenAcknowledged(),
                $Servicestatus->getAcknowledgementType(),
                $Servicestatus->getAcceptPassiveChecks(),
                $Servicestatus->getChecksEnabled(),
                $Servicestatus->getEventHandlerEnabled(),
                $Servicestatus->getFlapDetectionEnabled(),
                $Servicestatus->getIsFlapping(),
                $Servicestatus->getLatency(),
                $Servicestatus->getExecutionTime(),
                $Servicestatus->getScheduledDowntimeDepth(),
                $Servicestatus->isProcessPerformanceData(),
                $Servicestatus->isObsess(),
                $Servicestatus->getCheckInterval(),
                $Servicestatus->getRetryInterval(),
                $Servicestatus->getCheckPeriod(),
                $this->nodeName,
                $Servicestatus->getLastTimeOk(),
                $Servicestatus->getLastTimeWarning(),
                $Servicestatus->getLastTimeCritical(),
                $Servicestatus->getLastTimeUnknown(),
                $Servicestatus->getCurrentNotificationNumber(),
                $Servicestatus->getPercentStateChange(),
                $Servicestatus->getEventHandler(),
                $Servicestatus->getCheckCommand(),
            ];
        }
            $response = $this->client->post('http://192.168.1.1:4200/_sql', [
                RequestOptions::JSON => $restQuery
            ]);
        if($response->getStatusCode() !== 200){
            print_r($response->getBody()->getContents());
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions