smax-postgres v0.9
PostgreSQL / TimescaleDB logger for SMA-X
Loading...
Searching...
No Matches
smax-collector.c File Reference

Macros

#define _POSIX_C_SOURCE   200809
 For clock_gettime()
 
#define CONNECT_ATTEMPTS   20
 Total number of reconnection attempts when initializing.
 
#define CONNECT_RETRY_INTERVAL   3
 (sec) Time between reconnection attempts when initializing.
 
#define REDIS_SCAN_COUNT   100
 Work-load count to use for Redis SCAN-type commands.
 
#define SYSERR_RTN   0x40
 Exit code indicating not to restart in case of error.
 
#define UPDATE_TIMEOUT   10000
 (ms) Timeout value for gathering queued SMA-X variables
 

Functions

void destroyVariable (Variable *u)
 
int initCollector ()
 

Detailed Description

Date
Created on Mar 16, 2022
Author
Attila Kovacs

smaxLogger connector module that mines SMA-X for inserting select variables into a time-series database at regular intervals.

Function Documentation

◆ destroyVariable()

void destroyVariable ( Variable u)

Destroys a variable, freeing up the memory it occupies.

Parameters
uPointer to the variable.

References Variable::field, Variable::id, XField::name, and XField::value.

◆ initCollector()

int initCollector ( )

Initializes the SMA-X collector. It connects to SMA-X and starts a grabber thread in the background, which will be pushing data to the time-series database at regular intervals.

Returns
X_SUCCESS (0) if successful or else an error code (<0).

References CONNECT_ATTEMPTS, CONNECT_RETRY_INTERVAL, dprintf, ERROR_RETURN, FALSE, getSMAXServerAddress(), smaxConnect(), smaxSetPipelined(), smaxSetResilient(), smaxSetResilientExit(), SUCCESS_RETURN, TRUE, and X_NO_SERVICE.