Changes between Initial Version and Version 1 of naemonlog


Ignore:
Timestamp:
02/03/22 03:07:10 (3 years ago)
Author:
krit
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • naemonlog

    v1 v1  
     1= Write Naemon Log =
     2
     3We can write to naemon.log file by issue command
     4{{{
     5#!sh
     6OMD[monitor@501264b41d2d]:~/var/naemon$ pwd
     7/omd/sites/monitor/var/naemon
     8OMD[monitor@501264b41d2d]:~/var/naemon$ echo "[$(date +%s)] User Activity msg TEST log" >> naemon.log
     9}}}
     10Linux command '''date +%s''' will print time in current time since Epoch 1970
     11
     12In C program, we can implement this function with bash shell via '''system( bash cmd )'''
     13{{{
     14#!C
     15int writeLogFile( char *msg )
     16{
     17   char str_msg[1024];
     18   sprintf( str_msg, "echo \"[%d] User Activity %s \" >> /omd/sites/monitor/var/naemon/naemon.log",(int)time(NULL), msg);
     19   printf(str_msg);
     20   system(str_msg);
     21   return 0;
     22}
     23}}}
     24
     25
     26}}}