Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update For current zabbix 6.4 #2

Open
Vitexus opened this issue May 13, 2023 · 4 comments
Open

Update For current zabbix 6.4 #2

Vitexus opened this issue May 13, 2023 · 4 comments

Comments

@Vitexus
Copy link

Vitexus commented May 13, 2023

There is some small differences:

https://www.zabbix.com/documentation/current/en/manual/appendix/protocols/header_datalen

@Vitexus
Copy link
Author

Vitexus commented May 13, 2023

My Current Override according the official docs

<?php

declare(strict_types=1);
/**
 * Multi Flexi - 
 *
 * @author Vítězslav Dvořák <[email protected]>
 * @copyright  2020 Vitex Software
 */

namespace AbraFlexi\MultiFlexi;

use \Zarplata\Zabbix\Request\Packet as ZabbixPacket;

/**
 * Description of ZabbixSender
 *
 * @author vitex
 */
class ZabbixSender extends \Zarplata\Zabbix\ZabbixSender
{

    /**
     * Make payload for Zabbix server with special Zabbix header
     * and datalen
     *
     * https://www.zabbix.com/documentation/current/en/manual/appendix/protocols/header_datalen
     */
    private function makePayload(ZabbixPacket $packet): string
    {
        $encodedPacket = json_encode($packet);
        return self::zbxCreateHeader(strlen($encodedPacket)) . $encodedPacket;
    }

    /**
     * Zabbix Packet Header 
     *  
     * @param int $plain_data_size
     * @param int $compressed_data_size
     * 
     * @return string
     */
    public static function zbxCreateHeader($plain_data_size, $compressed_data_size = null)
    {
        $flags = self::VERSION;
        if (is_null($compressed_data_size)) {
            $datalen = $plain_data_size;
            $reserved = 0;
        } else {
            $flags |= 0x02;
            $datalen = $compressed_data_size;
            $reserved = $plain_data_size;
        }
        return self::HEADER . chr($flags) . pack("VV", $datalen, $reserved);
    }
}

@williamdes
Copy link

Can some in @zarplata let me know if I can make a pull-request for this project to fix the two open issues ?
Or if this project is archived in some way /cc @dr0id

@dr0id
Copy link

dr0id commented Oct 18, 2023

you probably meant /cc @idr0id

@williamdes
Copy link

you probably meant /cc @idr0id

Yes, indeed, sorry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants