Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Zabbix item for last line of a log file Post 303031970 by rbatte1 on Friday 8th of March 2019 08:11:46 AM
Old 03-08-2019
Got it at last!! It's quite convoluted, so why not share and see if someone else might benefit or suggest how to improve it:-
  1. Create the Zabbix item in a template for the file as type log and key logrt[/path/to/log] with a history of 1 day and a refresh of 3 seconds (don't want old logs and need it reasonably up to date without hammering the servers) The logrt key allows it to cope with logs that are rotated.
  2. Assign the template to the required hosts, although in my case the template was already on several servers so it appears in various places straight away.
  3. Wait a few minutes for the data to be picked up, ensuring that some new data is actually written to the log.
  4. Determine the Zabbix item number for the log file on the particular host I'm interested in
  5. Use a web-request to get the log file from the Zabbix server
  6. Get the first record (stored so newest is at the top)
  7. Drop the log reference number (first item, tab separated)
  8. Hey presto, I have the message that I can display.
Quite a palaver. I'm also not sure if we have bespoke tools that do things like working out the item number or if having a webserver that can share the log files is default.

I hope that this helps someone. Does anyone think I need to add more detail on each step?



Robin
These 3 Users Gave Thanks to rbatte1 For This Post:
 

10 More Discussions You Might Find Interesting

1. Infrastructure Monitoring

A Review of Zabbix - Zabbix Rules! (Part 1)

Tim Bass 03-20-2009 07:02 AM Source... (0 Replies)
Discussion started by: Linux Bot
0 Replies

2. Infrastructure Monitoring

A Review of Zabbix - Zabbix Rules! (Part 2)

Tim Bass 03-23-2009 03:45 PM Source... (0 Replies)
Discussion started by: Linux Bot
0 Replies

3. Shell Programming and Scripting

shell script to read a line in gps receiver log file and append that line to new file

Hi, I have gps receiver log..its giving readings .like below Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. GPSD,R=1 $GPGSV,3,1,11,08,16,328,40,11,36,127,00,28,33,283,39,20,11,165,00*71... (3 Replies)
Discussion started by: gudivada213
3 Replies

4. Shell Programming and Scripting

Searching for file and stopping at first item found

Hello, I try to write a shell script that would list all files on a directory and stop when it finds the first item specified on a find or ls command. How can I tell to the find or ls command to stop when it finds the first ".doc" file for example ? Thank you (7 Replies)
Discussion started by: davchris
7 Replies

5. Shell Programming and Scripting

Reading each item from a formatted file

Hi, I have a file generated like this - 1. Fire SQL and store the formatted output in a temp file echo "select path, empid, age from emp_tbl" | /usr/sql emp_db 2 > count_file | grep vol > tempFile 2. The tempFile looks like this after the above statement /vol/emp1 0732 ... (9 Replies)
Discussion started by: angshuman_ag
9 Replies

6. Shell Programming and Scripting

Print new item in file with symbol

Dear all, I have encountered some problem here. I prompt the user for input and store it into a data file, eg. key in name and marks so the data file will look like this andrew 80 ben 75 and the next input is carine 90. So the problem here is i want to print... (2 Replies)
Discussion started by: branred
2 Replies

7. Shell Programming and Scripting

HELP: Shell Script to read a Log file line by line and extract Info based on KEYWORDS matching

I have a LOG file which looks like this Import started at: Mon Jul 23 02:13:01 EDT 2012 Initialization completed in 2.146 seconds. -------------------------------------------------------------------------------- -- Import summary for Import item: PolicyInformation... (8 Replies)
Discussion started by: biztank
8 Replies

8. Shell Programming and Scripting

Reading line by line from live log file using while loop and considering only those lines start from

Hi, I want to read a live log file line by line and considering those line which start from time stamp; Below code I am using, which read line but throws an exception when comparing line that does not contain error code tail -F /logs/COMMON-ERROR.log | while read myline; do... (2 Replies)
Discussion started by: ketanraut
2 Replies

9. Shell Programming and Scripting

Read a lis, find items in a file from the list, change each item

Hello, I have some tab delimited text data, file: final_temp1 aname val NAME;r'(1,) 3.28584 r'(2,)<tab> NAME;r'(3,) 6.13003 NAME;r'(4,) 4.18037 r'(5,)<tab> You can see that the data is incomplete in some cases. There is a trailing tab after the first column for each incomplete row. I... (2 Replies)
Discussion started by: LMHmedchem
2 Replies

10. Shell Programming and Scripting

Script to process a list of items and uncomment lines with that item in a second file

Hello, I have a src code file where I need to uncomment many lines. The lines I need to uncomment look like, C CALL l_r(DESNAME,DESOUT, 'Gmax', ESH(10), NO_APP, JJ) The comment is the "C" in the first column. This needs to be deleted so that there are 6 spaces preceding "CALL".... (7 Replies)
Discussion started by: LMHmedchem
7 Replies
cronolog(1m)															      cronolog(1m)

NAME
cronolog - write log messages to log files named according to a template SYNOPSIS
cronolog [OPTION]... template DESCRIPTION
cronolog is a simple program that reads log messages from its input and writes them to a set of output files, the names of which are con- structed using template and the current date and time. The template uses the same format specifiers as the Unix date(1) command (which are the same as the standard C strftime library function). Before writing a message cronolog checks the time to see whether the current log file is still valid and if not it closes the current file, expands the template using the current date and time to generate a new file name, opens the new file (creating missing directories on the path of the new log file as needed unless the program is compiled with -DDONT_CREATE_SUBDIRS) and calculates the time at which the new file will become invalid. cronolog is intended to be used in conjunction with a Web server, such as Apache to split the access log into daily or monthly logs. For example the Apache configuration directives: TransferLog "|/usr/bin/cronolog /www/logs/%Y/%m/%d/access.log" ErrorLog "|/usr/bin/cronolog /www/logs/%Y/%m/%d/errors.log" would instruct Apache to pipe its access and error log messages into separate copies of cronolog, which would create new log files each day in a directory hierarchy structured by date, i.e. on 31 December 1996 messages would be written to /www/logs/1996/12/31/access.log /www/logs/1996/12/31/errors.log after midnight the files /www/logs/1997/01/01/access.log /www/logs/1997/01/01/errors.log would be used, with the directories 1997, 1997/01 and 1997/01/01 being created if they did not already exist. (Note that prior to version 1.2 Apache did not allow a program to be specified as the argument of the ErrorLog directive.) Options cronolog accepts the following options and arguments: -H NAME --hardlink=NAME maintain a hard link from NAME to the current log file. -S NAME --symlink=NAME -l NAME --link=NAME maintain a symbolic link from NAME to the current log file. -P NAME --prev-simlink=NAME maintain a symbolic link from NAME to the previous log file. Requires that the --symlink option is specified, as cronolog renames the current link to the name specified for the previous link. -h --help print a help message and then exit. -p PERIOD --period=PERIOD specifies the period explicitly as an optional digit string followed by one of units: seconds, minutes, hours, days, weeks or months. The count cannot be greater than the number of units in the next larger unit, i.e. you cannot specify "120 minutes", and for seconds, minutes and hours the count must be a factor of the next higher unit, i.e you can specify 1, 2, 3, 4, 5, 6, 10, 15, 20 or 30 minutes but not say 7 minutes. -d PERIOD --delay=PERIOD specifies the delay from the start of the period before the log file is rolled over. For example specifying (explicitly or implic- itly) a period of 15 minutes and a delay of 5 minutes results in the log files being rotated at five past, twenty past, twentyfive to and ten to each hour. The delay cannot be longer than the period. -o --once-only create single output log from template, which is not rotated. -x FILE --debug=FILE write debug messages to FILE or to the standard error stream if FILE is "-". (See the README file for more details.) -s TIME --start-time=TIME pretend that the starting time is TIME (for debugging purposes). TIME should be something like DD MONTH YYYY HH:MM:SS (the day and month are reversed if the american option is specified). If the seconds are omitted then they are taken as zero and if the hours and minutes are omitted then the time of day is taken as 00:00:00 (i.e. midnight). The day, month and year can be separated by spa- ces, hyphens (-) or solidi (/). -a --american Interprete the date part of the starting time the American way (month then day). -e --european Interprete the date part of the starting time the European way (day then month). This is the default. -v --version print version information and exit. Template format Each character in the template represents a character in the expanded filename, except for date and time format specifiers, which are replaced by their expansion. Format specifiers consist of a `%' followed by one of the following characters: % a literal % character n a new-line character t a horizontal tab character Time fields: H hour (00..23) I hour (01..12) p the locale's AM or PM indicator M minute (00..59) S second (00..61, which allows for leap seconds) X the locale's time representation (e.g.: "15:12:47") Z time zone (e.g. GMT), or nothing if the time zone cannot be determined Date fields: a the locale's abbreviated weekday name (e.g.: Sun..Sat) A the locale's full weekday name (e.g.: Sunday .. Saturday) b the locale's abbreviated month name (e.g.: Jan .. Dec) B the locale's full month name, (e.g.: January .. December) c the locale's date and time (e.g.: "Sun Dec 15 14:12:47 GMT 1996") d day of month (01 .. 31) j day of year (001 .. 366) m month (01 .. 12) U week of the year with Sunday as first day of week (00..53, where week 1 is the week containing the first Sunday of the year) W week of the year with Monday as first day of week (00..53, where week 1 is the week containing the first Monday of the year) w day of week (0 .. 6, where 0 corresponds to Sunday) x locale's date representation (e.g. today in April in Britain: "13/04/97") y year without the century (00 .. 99) Y year with the century (1970 .. 2038) Other specifiers may be available depending on the C library's implementation of the strftime function. SEE ALSO
apache(1m) date(1) strftime(3) environ(5) More information and the latest version of cronolog can be obtained from http://www.ford-mason.co.uk/resources/cronolog/ If you have any suggestions, bug reports, fixes, or enhancements, please mail them to the author. More about Apache Documentation for the Apache http server is available from http://www.apache.org FUTURE DIRECTIONS
The functionality of cronolog could be built into Apache, thus saving the overhead of having a process per log stream and that of transfer- ring data from the server process to the cronolog process. The main complication is handling the case where multiple log streams are writ- ten to the same file (template), for example where different virtual servers write to the same set of log files. AUTHOR
Andrew Ford <A.Ford@ford-mason.co.uk> cronolog is based on a program called rotatelogs by Ben Laurie, which is packaged with the Apache web server. The symbolic link option was suggested by Juergen Lesny. March 1998 cronolog(1m)
All times are GMT -4. The time now is 10:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy