当前位置:网站首页>C alarm design
C alarm design
2022-07-05 12:27:00 【yang881221】
1 Alarm log module design
1.1 function analysis
The function of this module is to output the generated alarm to the serial port or log file
1.2 The basic principle
The alarm level output to the serial port defaults to info Level ; The alarm level output to the file defaults to alert Level , take alert And higher level information saved to file .
When other modules have alarms , call sysLogMsg(MODULEIDmodule, LEVELID level,const char * format, ...) Function to send an alarm message to the module , The incoming parameters have alarm module 、 Alarm level and message body . The module outputs the message to the serial port or saves it to a file according to the alarm module and alarm level .
If the message queue is full or the message length is greater than 256 byte , The message is discarded . For messages to be output to the serial port , direct printf Printout ; For messages to be saved to a file , For a while Buf in , And put the sign at 1, Each time will be Buf Before writing to the file , Use tick Count the interval between the last save time , When the interval is greater than the specified value , And the sign bit is 1 when , hold Buf Content in write to file .
1.3 Data structure design
typedef struct tagSysLogGlobalConfig {
int iCurrLofServer;
int iSendRate;
LOGHOST plServerList[SYSLOG_MAX_HOST];
LIST *plMsgBufList;
int iBufListSize;
BUFLISTELEMENT *ptBufInsertPos;
BUFLISTELEMENT *ptBufShowFirstPos;
int iConsoleSwitch;
int iConsoleServity;
ulong_t ulConsolMessages;
int iMonitorSwitch;
int iMonitorServity;
ulong_t ulMonitorMessages;
int iFileSwitch;
int iFileServity;
char * logFileName;
MSG_Q_ID logMsgQ;
int iLogSocket;
int iAppendTime;
int iGlobalSwitch;
ulong_t ulDropMessage;
SEM_ID semMemCpy;
} SYSLOGCONF;
typedef struct tagLogHost{
ulong_t ulIpAddr; /* Log host's IP Address */
ulong_t ulLevel; /* The output level of the log host */
ulong_t ulFacility; /*Unix System defined equipment number ,local0~local7(16~23);*/
ulong_t ulSwitch; /* Indicates whether the switch of the current log host is on ,0 To open */
ulong_t ulMsgSent; /* The number of discarded logs sent to this host */
ulong_t ulMsgdrop; /* Number of dropped messages */
ulong_t ulPort;
} LOGHOST;
typedef struct tagBufListElement{
NODE link;
ulong_t ulGetTick;
ulong_t ulSec;
char* buf;
ulong_t ulInUse;
int iModule; /*module */
int iLevel; /*message level*/
}BUFLISTELEMENT;
typedef struct tSYSLOGMODULE{
char *pcModuleName; /* Module name */
char *pcFacility; /**/
int iModuleDebugSwitch;
} SYSLOGMODULE;
边栏推荐
- 手机 CPU 架构类型了解
- 7月华清学习-1
- 只是巧合?苹果 iOS16 的神秘技术竟然与中国企业 5 年前产品一致!
- Learn the memory management of JVM 03 - Method area and meta space of JVM
- MySQL trigger
- MySQL installation, Windows version
- Instance + source code = see through 128 traps
- Read and understand the rendering mechanism and principle of flutter's three trees
- How to clear floating?
- [hdu 2096] Xiaoming a+b
猜你喜欢
A guide to threaded and asynchronous UI development in the "quick start fluent Development Series tutorials"
Matlab imoverlay function (burn binary mask into two-dimensional image)
About cache exceptions: solutions for cache avalanche, breakdown, and penetration
Anaconda creates a virtual environment and installs pytorch
Pytoch loads the initialization V3 pre training model and reports an error
Automated test lifecycle
C language structure is initialized as a function parameter
ZABBIX ODBC database monitoring
mmclassification 训练自定义数据
Take you hand in hand to develop a service monitoring component
随机推荐
Master the new features of fluent 2.10
Learn memory management of JVM 01 - first memory
[figure neural network] GNN from entry to mastery
Is investment and finance suitable for girls? What financial products can girls buy?
ZABBIX monitors mongodb templates and configuration operations
Solution to order timeout unpaid
只是巧合?苹果 iOS16 的神秘技术竟然与中国企业 5 年前产品一致!
Swift - enables textview to be highly adaptive
MySQL splits strings for conditional queries
Redis's memory elimination mechanism, read this article is enough.
POJ-2499 Binary Tree
Learn JVM garbage collection 05 - root node enumeration, security points, and security zones (hotspot)
Interviewer: is acid fully guaranteed for redis transactions?
ZABBIX ODBC database monitoring
Ecplise development environment configuration and simple web project construction
SENT协议译码的深入探讨
Anaconda creates a virtual environment and installs pytorch
Redis clean cache
语义分割实验:Unet网络/MSRC2数据集
MySQL multi table operation