Source
xxxxxxxxxx
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/******************************************************************************
* *
* Purpose: registers IPMI poller with IPMI manager *
* *
* Parameters: socket - [IN] connections socket *
* *
******************************************************************************/
static void ipmi_poller_register(zbx_ipc_async_socket_t *socket)
{
pid_t ppid = getppid();
zbx_ipc_async_socket_send(socket, ZBX_IPC_IPMI_REGISTER, (unsigned char *)&ppid, sizeof(ppid));
}
/******************************************************************************
* *
* Purpose: sends IPMI poll result to manager *
* *
* Parameters: socket - [IN] connections socket *
* code - [IN] *
* errcode - [IN] result error code *
* value - [IN] resulting value/error message *
* *
******************************************************************************/
static void ipmi_poller_send_result(zbx_ipc_async_socket_t *socket, zbx_uint32_t code, int errcode,
const char *value)
{
unsigned char *data;
zbx_uint32_t data_len;
zbx_timespec_t ts;
zbx_timespec(&ts);
data_len = zbx_ipmi_serialize_result(&data, &ts, errcode, value);
zbx_ipc_async_socket_send(socket, code, data, data_len);
zbx_free(data);
}
/******************************************************************************
* *
* Purpose: gets IPMI sensor value from specified host *
* *
* Parameters: socket - [IN] connections socket *
* message - [IN] value request message *
* *
******************************************************************************/
static void ipmi_poller_process_value_request(zbx_ipc_async_socket_t *socket, zbx_ipc_message_t *message)
{
zbx_uint64_t itemid;
char *addr, *username, *password, *sensor, *value = NULL, *key;
signed char authtype;
unsigned char privilege;
unsigned short port;
int errcode, command;
zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __func__);
zbx_ipmi_deserialize_request(message->data, &itemid, &addr, &port, &authtype, &privilege, &username, &password,
&sensor, &command, &key);
if (0 == strcmp(key, "ipmi.get") || 0 == strncmp(key, "ipmi.get[", ZBX_CONST_STRLEN("ipmi.get[")))
{
zabbix_log(LOG_LEVEL_TRACE, "%s() for discovery itemid:" ZBX_FS_UI64 " addr:%s port:%d authtype:%d"