RDK Documentation (Open Sourced RDK Components)

Description

Functions

int processTopPattern (char *logfile, GList *pchead, int pcIndex)
 This API processes the top command log file patterns to retrieve load average and process usage. More...
 
int addToJson (GList *pchead)
 This function adds the value to the telemetry output json object. More...
 
int getIPVideo (char *line, pcdata_t *pcnode)
 Function to process pattern if it has split text in the header. More...
 
int getErrorCode (char *str, char *ec, int ec_length)
 To get RDK error code. More...
 
int handleRDKErrCodes (GList **rdkec_head, char *line)
 Function to handle error codes received from the log file. More...
 
int processCountPattern (char *logfile, GList *pchead, int pcIndex, GList **rdkec_head)
 Function to process pattern count (loggrep) More...
 
int processPattern (char **prev_file, char *logfile, GList **rdkec_head, GList *pchead, int pcIndex)
 Generic pattern function based on pattern to call top/count or using ccsp message bus. More...
 
char * strSplit (char *str, char *delim)
 Function like strstr but based on the string delimiter. More...
 
void getDType (char *filename, char *header, DType_t *dtype)
 To get node data type based on pattern. More...
 
int parseFile (char *fname)
 Main logic function to parse sorted MAP file and to process pattern list. More...
 
int main (int argc, char *argv[])
 Main Function. More...
 
int main ()
 
void initSearchResultJson (cJSON **root, cJSON **sr)
 This API creates "searchResult" JSON array. More...
 
void addToSearchResult (char *key, char *value)
 This API is to append the key/value pair to the SearchResult JSON array . More...
 
void clearSearchResultJson (cJSON **root)
 This API deletes the result JSON object. More...
 
void printJson (cJSON *root)
 This API is to print Json result. More...
 
int getProcUsage (char *processName)
 To get process usage. More...
 
int getProcPidStat (int pid, procinfo *pinfo)
 To get status of a process from its process ID. More...
 
char * getResidentMemory (procMemCpuInfo *pInfo, int *processPid)
 To get the reserve memory of a given process in pages. More...
 
int ccsp_handler_init ()
 This API initalizes the ccsp message bus. More...
 
void ccsp_handler_exit ()
 This API is to uninitialize message bus.
 
int get_tr181param_value (const char *path_namespace, char *parm_value, int len)
 This API is to retrieve the value of TR181 telemetry. More...
 
int getLoadAvg ()
 This API is to find the load average of system and add it to the SearchResult JSON. More...
 
static int fsize (FILE *fp)
 This function returns file size. More...
 
void clearConfVal (void)
 This function is to clear/free the global paths.
 
void updateExecCounter ()
 To update current dca execution count.
 
void saveExecCounter ()
 
int isSkipParam (int skipInterval)
 This API is to verify whether to skip this telemetry marker. More...
 
char * getsRotatedLog (char *buf, int buflen, char *name)
 Function to return rotated log file. More...
 
void updateIncludeConfVal (char *logpath, char *perspath)
 Function to update the global paths like PERSISTENT_PATH,LOG_PATH from include.properties file. More...
 
void updateConfVal (char *logpath, char *perspath)
 Function to update the configuration values from device.properties file. More...
 
int readLogSeek (char *name, long *seek_value)
 Function to read the rotated Log file. More...
 
void writeLogSeek (char *name, long seek_value)
 Function to write the rotated Log file. More...
 
int getProcInfo (procMemCpuInfo *pmInfo)
 To get CPU and mem info. More...
 
int getMemInfo (procMemCpuInfo *pmInfo)
 To get the reserve memory of a given process. More...
 
int getCPUInfo (procMemCpuInfo *pInfo)
 To get CPU info. More...
 

Function Documentation

◆ processTopPattern()

int processTopPattern ( char *  logfile,
GList *  pchead,
int  pcIndex 
)

This API processes the top command log file patterns to retrieve load average and process usage.

Parameters
[in]logfiletop_log file
[in]pcheadNode head
[in]pcIndexNode count
Returns
Returns the status of the operation.
Return values
Returnszero on success, appropriate errorcode otherwise.

Definition at line 150 of file dca.c.

◆ addToJson()

int addToJson ( GList *  pchead)

This function adds the value to the telemetry output json object.

Parameters
[in]pcheadHeader field in the telemetry profile
Returns
Returns status of operation.

Definition at line 347 of file dca.c.

◆ getIPVideo()

int getIPVideo ( char *  line,
pcdata_t pcnode 
)

Function to process pattern if it has split text in the header.

Parameters
[in]lineLog file matched line
[in]pcnodePattern to be verified.
Returns
Returns status of operation.
Return values
Return0 on success, -1 on failure

Definition at line 390 of file dca.c.

◆ getErrorCode()

int getErrorCode ( char *  str,
char *  ec,
int  ec_length 
)

To get RDK error code.

Parameters
[in]strSource string.
[out]ecError code.
Returns
Returns status of operation.
Return values
Return0 upon success.

Definition at line 439 of file dca.c.

◆ handleRDKErrCodes()

int handleRDKErrCodes ( GList **  rdkec_head,
char *  line 
)

Function to handle error codes received from the log file.

Parameters
[in]rdkec_headNode head.
[in]lineLogfile matched line.
Returns
Returns status of operation.
Return values
Return0 upon success, -1 on failure.

Definition at line 486 of file dca.c.

◆ processCountPattern()

int processCountPattern ( char *  logfile,
GList *  pchead,
int  pcIndex,
GList **  rdkec_head 
)

Function to process pattern count (loggrep)

Parameters
[in]logfileCurrent log file
[in]pcheadNode head
[in]pcIndexNode count
[in]rdkec_headRDK errorcode head
Returns
Returns status of operation.
Return values
Return0 upon success, -1 on failure.

Definition at line 524 of file dca.c.

◆ processPattern()

int processPattern ( char **  prev_file,
char *  logfile,
GList **  rdkec_head,
GList *  pchead,
int  pcIndex 
)

Generic pattern function based on pattern to call top/count or using ccsp message bus.

Parameters
[in]prev_fileThe previous log file.
[in]logfileThe current log file.
[in]rdkec_headRDK errorcode head
[in]pcheadNode head
[in]pcIndexNode count
Returns
Returns status on operation.
Return values
Returns0 upon success.

Definition at line 567 of file dca.c.

◆ strSplit()

char* strSplit ( char *  str,
char *  delim 
)

Function like strstr but based on the string delimiter.

Parameters
[in]strString.
[in]delimDelimiter.
Returns
Returns the output string.

Definition at line 658 of file dca.c.

◆ getDType()

void getDType ( char *  filename,
char *  header,
DType_t *  dtype 
)

To get node data type based on pattern.

Parameters
[in]filenameConf filename.
[in]headernode header.
[out]dtypeData type
Returns
Returns status of operation.

Definition at line 692 of file dca.c.

◆ parseFile()

int parseFile ( char *  fname)

Main logic function to parse sorted MAP file and to process pattern list.

MAP file is of the form $header<#=#>$content<#=#>$logFileName<#=#>$skipInterval.

Parameters
[in]fnameConfiguration file.
Returns
Returns status of the operation.
Return values
Return0 upon success, -1 on failure.

Definition at line 732 of file dca.c.

◆ main()

int main ( int  argc,
char *  argv[] 
)

Main Function.

Parameters
[in]Commandline arguments(Sorted pattern conf file, previous log path, Custom persistent path).
Returns
Returns status of the operation.
Return values
Returnsthe return code of parseFile function.

Definition at line 857 of file dca.c.

◆ initSearchResultJson()

void initSearchResultJson ( cJSON **  root,
cJSON **  sr 
)

This API creates "searchResult" JSON array.

The search result list contains collection of telemetry marker headers with their value.

Eg: {"searchResult":[{"MOCA_INFO_pnc_enabled":"1"},{"samv2_boardver_split":" V3.0 ##"},{"RF_ERR_DS_lockfail":"1"},{"RF_ERR_T3_timeout":"2"}]}

Parameters
[out]rootJSON object
[in]srSearch result JSON array

Definition at line 57 of file dcajson.c.

◆ addToSearchResult()

void addToSearchResult ( char *  key,
char *  value 
)

This API is to append the key/value pair to the SearchResult JSON array .

Parameters
[in]keymarker name
[in]valuemetric count

Definition at line 71 of file dcajson.c.

◆ clearSearchResultJson()

void clearSearchResultJson ( cJSON **  root)

This API deletes the result JSON object.

Parameters
[in]rootJSON object to be deleted.

Definition at line 87 of file dcajson.c.

◆ printJson()

void printJson ( cJSON *  root)

This API is to print Json result.

Parameters
[in]rootJSON object.
Returns
Returns the status of the operation.

Definition at line 99 of file dcajson.c.

◆ getProcUsage()

int getProcUsage ( char *  processName)

To get process usage.

Parameters
[in]processNameProcess name.
Returns
Returns status of operation.
Return values
0on sucess, appropiate errorcode otherwise.

Definition at line 106 of file dcaproc.c.

◆ getProcPidStat()

int getProcPidStat ( int  pid,
procinfo pinfo 
)

To get status of a process from its process ID.

This will return information such as process priority, virtual memory size, signals etc.

Parameters
[in]pidPID value of the process.
[in]pinfoProcess info.
Returns
Returns status of operation.
Return values
Return1 on success, appropiate errorcode otherwise.

Definition at line 290 of file dcaproc.c.

◆ getResidentMemory()

char* getResidentMemory ( procMemCpuInfo pInfo,
int *  processPid 
)

To get the reserve memory of a given process in pages.

Parameters
[in]pInfoProcess Name.
[in]processPidProcess Id.
Returns
Returns reserve memory of the requested process.

Definition at line 128 of file dcaprocess.cpp.

◆ ccsp_handler_init()

int ccsp_handler_init ( )

This API initalizes the ccsp message bus.

Returns
Returns status of operation.
Return values
Returnszero on success, appropiate errorcode otherwise.

Definition at line 68 of file dcatr181.c.

◆ get_tr181param_value()

int get_tr181param_value ( const char *  path_namespace,
char *  parm_value,
int  len 
)

This API is to retrieve the value of TR181 telemetry.

Returns
Returns status of operation.
Return values
Returnszero on success, appropiate errorcode otherwise.

Definition at line 101 of file dcatr181.c.

◆ getLoadAvg()

int getLoadAvg ( )

This API is to find the load average of system and add it to the SearchResult JSON.

Returns
Returns status of operation.
Return values
Return1 on success.

Definition at line 57 of file dcautils.c.

◆ fsize()

static int fsize ( FILE *  fp)
static

This function returns file size.

Parameters
[in]fpFile name
Returns
Returns size of file.

Definition at line 85 of file dcautils.c.

◆ isSkipParam()

int isSkipParam ( int  skipInterval)

This API is to verify whether to skip this telemetry marker.

Parameters
[in]skipIntervalPolling frequency
Returns
Retuns 0 or 1 depening upon the polling frequency.

Definition at line 163 of file dcautils.c.

◆ getsRotatedLog()

char* getsRotatedLog ( char *  buf,
int  buflen,
char *  name 
)

Function to return rotated log file.

Parameters
[in]bufBuffer
[in]buflenMaximum buffer length
[in]nameCurrent Log file
Returns
Returns Seek Log file.

Definition at line 190 of file dcautils.c.

◆ updateIncludeConfVal()

void updateIncludeConfVal ( char *  logpath,
char *  perspath 
)

Function to update the global paths like PERSISTENT_PATH,LOG_PATH from include.properties file.

Parameters
[in]logpathLog file path
[in]perspathPersistent path

Definition at line 397 of file dcautils.c.

◆ updateConfVal()

void updateConfVal ( char *  logpath,
char *  perspath 
)

Function to update the configuration values from device.properties file.

Parameters
[in]logpathLog file path
[in]perspathPersistent path

Definition at line 491 of file dcautils.c.

◆ readLogSeek()

int readLogSeek ( char *  name,
long *  seek_value 
)

Function to read the rotated Log file.

Parameters
[in]nameLog file name.
[in]seek_valuePosition to seek.
Returns
Returns the status of the operation.
Return values
Returns-1 on failure, appropriate errorcode otherwise.

Definition at line 635 of file dcautils.c.

◆ writeLogSeek()

void writeLogSeek ( char *  name,
long  seek_value 
)

Function to write the rotated Log file.

Parameters
[in]nameLog file name.
[in]seek_valuePosition to seek.
Returns
Returns the status of the operation.
Return values
Returns-1 on failure, appropriate errorcode otherwise.

Definition at line 678 of file dcautils.c.

◆ getProcInfo()

bool getProcInfo ( procMemCpuInfo pmInfo)

To get CPU and mem info.

Parameters
[out]pmInfoMemory/CPU Info.
Returns
Returns status of operation.
Return values
Return1 on success.

Definition at line 397 of file dcaproc.c.

◆ getMemInfo()

int getMemInfo ( procMemCpuInfo pmInfo)

To get the reserve memory of a given process.

Parameters
[out]pmInfoMemory Info.
Returns
Returns status of operation.
Return values
Return1 on success.

Definition at line 417 of file dcaproc.c.

◆ getCPUInfo()

int getCPUInfo ( procMemCpuInfo pInfo)

To get CPU info.

Parameters
[out]pInfoCPU info.
Returns
Returns status of operation.
Return values
Return1 on success,appropiate errorcode otherwise.

Definition at line 468 of file dcaproc.c.