Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Shell script newbie- how to generate service log from shell script Post 303031584 by xiaogeji on Saturday 2nd of March 2019 07:18:42 AM
Old 03-02-2019
Hey bakunin,


Many thanks for your reply!


the following is my plan and let me know if anything doesnt make sense :


1. Ideally the script should print out the log file in the following format:
2019-02-26 09:15:00 +1100,Success,ntpd,restart 2019-02-26 09:16:00 +1100,Error,ntpd,other-activity

But if I am really stuck,as long as the "$(success status),$(service name),$(activity)" are in the output then it will still be fine, someone will extend the script later on..
2. and the fields that I want in the log should include, the last three fields are the minimum and the date is optional depending on the complexity:

$(date and time in fixed format), $(success status), $(service name), $(activity)



3. single log vs multiple logs: I shouldve clarified earlier that the only service I need to work on is ntpd. So a single log would be fine for me.


4. I am not sure if it will be more complicated to write a separate error log since I only need to focus on one service which is ntpd.



Let me know if it makes sense to move on to the next step. thanks again for your help!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

generate xml from a shell script

Hello! I would like to generate an xml file from the output of various commands generated from within a shell script (some will be in CDATA). At the moment the only solution I have come up with is echoing xml tags around the commands eg. echo "<bitism>" >> outputfile /usr/sbin/prtconf... (1 Reply)
Discussion started by: speedieB
1 Replies

2. Shell Programming and Scripting

Help - shell script newbie

My problem looks like it should have a simple solution but it seems that after many days of research I cannot find a good solution. What I have is an input file that contains lines of information. What I need is to extract specific information from that file. What I know is that somewhere in the... (2 Replies)
Discussion started by: eback
2 Replies

3. Shell Programming and Scripting

how do i generate random integer using only shell script

Hi All, I need to generate 4 digit random no using only shell script. Please help in this ASAP. Thanks in advance... Regards, sridhar. (1 Reply)
Discussion started by: sridhusha
1 Replies

4. Shell Programming and Scripting

Shell Script Help -I'm a newbie

Can someone help me write this shell script? I am completely new to shell and as a fun task my uncle has challenged me a problem (out of all other people). Basically, all he wants me to do is to create backup file in a folder that is named “disables.” This is what he said: create a shell script... (0 Replies)
Discussion started by: hotcutiepie05
0 Replies

5. Infrastructure Monitoring

Shell Script - Generate SNMP Traps

Good morning to you all I´m kinda of a noob to scripting, and my knowledge is still very basic: anyway, I´ve developed a small .sh script with the following purpose: - it will check a result file, checking if it has any values, or if it´s empty - if it´s empty it will send an email What... (0 Replies)
Discussion started by: zarahel
0 Replies

6. Shell Programming and Scripting

Shell Script for a newbie

Hello all, I want to write a shell script to list the contents of a directory and number them and write them to a file. For example, if I have a directory temp and the contents of the directory are alpha, beta and gamma. I want to write these filenames to a file "test" in a numbered manner. ... (7 Replies)
Discussion started by: grajp002
7 Replies

7. Shell Programming and Scripting

generate logfile in a shell script

Unix Gurus, I have a shell script which has few "echo" statements. I am trying to create a logfile where all the outputs of the echo statement sare stored. I will have to add this as the final step in the existing script so that everytime the script runs, a logfile is generated with all the... (1 Reply)
Discussion started by: shankar1dada
1 Replies

8. Shell Programming and Scripting

Shell script newbie, what is problem with my script?

Hello, Ubuntu server 11.10 can anybody help what is problem with my shell script? #!/bin/bash #script to find out currently logged on user is root or not. if ] then echo "You are super" else echo "You are awesome!" fi When I run script, I get following output ./uid: line 3: I... (4 Replies)
Discussion started by: kaustubh
4 Replies

9. Shell Programming and Scripting

Shell script to compare and generate a new file

Requirement is I have two files their format is File1 - input_file ----- tmp_value|3|number|| tmp_value1|3|alpha|| tmp_value2|6|alpha|AA AA| tmp_value3|15|number|000000005| tmp_value4|15|number|000000000000000| tmp_value5|11|alpha|bbbbbbbbbbb| tmp_value6|11|alpha|bb bb| input_file ... (4 Replies)
Discussion started by: greenworld123
4 Replies

10. Shell Programming and Scripting

Generate documentation for a shell script

Hi, I've written a shell script with proper intentation and commenting structure. However, I would like to generate documentation for the shell which I have written. Is there any tool as such to generate it like we have javagen/docgen ? Please help. Thanks, Arjun (0 Replies)
Discussion started by: arjun_arippa
0 Replies
RADIOCLKD(1)						   Network Time Protocol Daemon 					      RADIOCLKD(1)

NAME
radioclkd - decode time from radio clock(s) attached to serial port SYNOPSIS
radioclkd [ -tphv ] device DESCRIPTION
radioclkd is a simple daemon that decodes the time from a radio clock device attached to the DCD and/or CTS and/or DSR status lines of serial port of a computer. It is able to decode the DCF77, MSF and WWVB time signals. The received time is then sent to ntpd using the shared memory reference clock driver. The type of time signal being received is automatically determined. If you have problems getting the program to work using interrupts, the following command is known to help in many instances. If this fails you can always fall back to the polling method. stty crtscts < /dev/ttyS0 Details on a cheap and easy to make device for receiving these time signals can be found at http://www.buzzard.org.uk/jonathan/radioclock.html OPTIONS
-p, --poll Poll the serial port for changes of status in the DCD, CTS and DSR lines rather than use interrupts -t, --test Enter test mode printing the length of each pulse and the decoded time at the end of each minute on stdout. The time is not sent to ntpd using the shared memory reference clock driver in this mode. -h, --help Print a short synopsis of the command line arguments. -v, --version Print the version number and then exit. CONFIGURATION
Configuration is very simple. Use server 127.127.28.0 in your ntp.conf file for a clock attached to the DCD line, server 127.127.28.1 for a clock attached to the CTS line, and server 127.127.28.2 for a clock attached to the DSR line. You will also want to use a fudge line on the server to change the displayed refid. CALIBRATION
Due to delays in the propogation of the radio signal, it's processing by the receiver board and the latency of the operating system the time decoded by the receiver will be slightly offset from actual UTC. Typically this delay will be less than 20ms, so unless you are very fussy about the time, or are using more than one time source, such as a GPS unit, other radio clock or NTP server on the internet you can ignore this section. The basics of the calibration procedure is to determine the average offset of the radio receiver, and use the time1 fudge factor in ntp.conf to bring the receiver as close as possible to the real time. The easiest way of determining the offset of the radio receivers time is to run it against a reference clock that does not suffer from these problems. The best reference clock would be a GPS unit. This might be a GPS unit that you don't wish to dedicate to time keeping, or a borrowed unit. If this is not possible you could use a stratum 1 server on the internet. The method of calibration is quite simple. We attach the calibration reference clock to the computer and fudge the stratum of our radio receiver up to say 5. This way we can be sure that ntpd will lock onto the calibration reference clock. We need to make sure that ntpd is configured to collect peer statistics so make sure we have some lines similar to these in ntp.conf statsdir /var/log/ntpstats/ statistics loopstats peerstats clockstats filegen peerstats file peerstats type day enable After that we restart ntpd and leave it running for several hours. We can then make a copy the peerstats file. The trick is to remove all the entries before ntpd has come into close aggrement with the calibration reference clock and then run the peer.awk script in the scripts/stats directory of the ntp distribution. This will give us a mean offset of our radio receivers in milliseconds. This can them be converted into seconds and added to the fudge line in ntp.conf for our receiver. The final step is to remove the change in stratum level for our reference clock and restart ntpd. If you move the receiver any significant distance then you will need to repeat this calibration step. Across the room or around the current building will be fine, but if you move it to the next town/city then you will need to recalibrate. IN USE
The version of ntpd that comes with most Linux distributions does not have the shared memory reference clock driver compiled in by default. This can be identified by checking the logs after ntpd is started. If the shared memory reference clock driver is not compiled in then the logs will contain warnings about the reference clock driver not being recognized. To compile ntpd with the shared memory reference clock driver you must specify the --enable-SHM option when running configure. Neither radioclkd or ntpd ever mark the shared memory segment for deletion. If you stop using the shared memory reference clock driver therefore any shared memory segments will persist until you reboot or manually delete the segment using ipcrm. The segments can be identi- fied as the one with key 0x4e545030, 0x4e545031 or 0x4e545032 using the ipcs command. BUGS
If you are running a kernel with the PPS kit and have a clock attached to the DCD line you may experience lockups. If you encounter this problem the currently recomended solution is to move the clock to either the CTS or DSR lines. AUTHOR
This program was written by Jonathan Buzzard <jonathan@buzzard.org.uk> and may be freely distributed under the terms of the GNU General Public License. There is ABSOLUTELY NO WARRANTY for this program. Version 1.0 19 Jan 2003 RADIOCLKD(1)
All times are GMT -4. The time now is 08:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy