Ad Widget

Collapse

How to monitor log file with date in name ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • maxpower
    Member
    • Jul 2007
    • 31

    #1

    How to monitor log file with date in name ?

    Hi there,

    today i installed Zabbix and have some trouble to monitor logfiles on windows.
    The Agent is running and reporting the usual OS data but how do i monitor a logfile whose name changes daily ?

    And for the easier case - how do i monitor a logfile for the string ERROR where the name of the logfile is a variable. To make it more clearly:
    Item: Error in Logfile $1
    Type: Zabbix Agent (active)
    Key: log[*,[Ee][Rr][Rr][Oo][Rr]]
    Type of Information: Log
    Now - how do i get an alert if the string ERROR occurs in a logfile and how do i tell Zabbix the name of the logfile ? How does the trigger look like ?

    Thanks in advance,
    Sven
    Last edited by maxpower; 18-07-2007, 16:28.
  • maxpower
    Member
    • Jul 2007
    • 31

    #2
    Nobody ?

    Nobody knows ? What for is the "flexible" parameter then ?

    Btw. for a logfile parser you could use perl File::Tail and strftime for the selection of the file so that a logfile could look like
    "prglog-%d.%m.%Y.log" and strftime would return "prglog-19.07.2007.log".

    Comment

    • PhilFR
      Junior Member
      • Jul 2007
      • 1

      #3
      Hi,

      Waiting a better solution, to monitor a Windows Log File, I use a constant hard link (current.log) that is modified at 00:00 in a scheduled task.

      The Item works well (history of Latest Data is OK) but I have problems with the trigger.

      The example of code (comments in French) of the vbs

      nomFichierCible : name of the log File (Cible=Target)
      dossierFichier : path to the folder containing log file
      cible : path to the log file
      lien : path of the hard link

      '########### BEGIN ###########
      '
      ' Creation d'un lien pour avoir un nom de fichier unique quel que soit le jour
      ' lancer ce script à 0H00
      ' cscript /nologo liensPourSupervision.vbs
      '
      AujourdHui = Date()
      an=year(AujourdHui)
      mois=month(AujourdHui)
      jour=day(AujourdHui)
      if jour < 10 Then jour="0"&jour
      if mois < 10 Then mois="0"&mois
      '
      ' Paramètres à éventuellement modifier (faire une fonction si nécessaire)
      '
      nomFichierCible=an&mois&jour&"."&"log"
      dossierFichier="F:\Messagerie\logs\webmail\webmail .log"
      cible=dossierFichier&"\"&nomFichierCible
      lien=dossierFichier&"\current.log"

      call creerLienDur (lien, cible)

      Function creerLienDur( lien, cible )
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      if (objFSO.FileExists(lien)) then
      Set objToDel = objFSO.GetFile(lien)
      objToDel.Delete()
      end if
      if (not objFSO.FileExists(cible)) then
      objFSO.CreateTextFile(cible)
      end if
      Set objFSO = Nothing
      commande="%SYSTEMROOT%"+"\system32\fsutil.exe hardlink create " + lien + " " + cible
      Set WshShell = WScript.CreateObject("WScript.Shell")
      Set objShell = CreateObject("Wscript.Shell")
      objShell.Run commande, 0, True
      Set objShell = Nothing
      End Function
      '########### END ###########


      I prefer nncronlt (http://www.nncron.ru/download/nncronlt117.exe) to Windows Scheduled tasks, the crontab contains the following line :
      0 * * * * cscript /nologo D:\sbin\zabbix\liensPourSupervision.vbs

      Zabbix Item is :

      Type : Zabbix agent (active)
      Key : log[F:\Messagerie\logs\webmail\webmail.log\current.log ,.*Connexion.*]
      Type of information : Log

      Comment

      • simonuk1
        Member
        • Mar 2009
        • 66

        #4
        Did anyone else find a way to do this.

        Would it be possible to use a different variable to pass the datestamp of a logfile to the agent to check a logfile that changes daily to new datestamp prefix such as dd_mm_yy.log etc

        As it cant pass the (date) in the item could a different variable be used that it gotten from a script on the zabbix server or from something that the agent could run to get the date to put into the item.

        any ideas fellow zabbixers

        Si
        Last edited by simonuk1; 18-06-2009, 00:26.

        Comment

        • Kai-Kai
          Senior Member
          • Apr 2009
          • 142

          #5
          I think it's an interesting question, and if a good solution is found, I'm interested in it.
          Last edited by Kai-Kai; 03-07-2009, 15:11.

          Comment

          • churari
            Junior Member
            • Feb 2012
            • 7

            #6
            This isn't an exact match, but here is how I solved this issue. I was trying to monitor a log file on a linux server. The server is running the agent.

            Instead of using the default vfs.size function, which as far as I could tell wouldn't take a wild card, I used the system.run command. Actually, first I used a macro I created and put that in the file name. I then had a cron update the macro every night. However, this pushed out new items to all my agents and swamped the server.

            So instead I implemented:

            system.run[" f=`date +'%Y%m%d'`; stat -c %s /home/file_$f.txt"]

            where the file name is file_20121012.txt

            Hope that helps someone.

            Comment

            • Kai-Kai
              Senior Member
              • Apr 2009
              • 142

              #7
              Interesting workaround. Thank you.

              Comment

              • mrblue
                Junior Member
                • Apr 2017
                • 3

                #8
                It's been 3 years since the last post in this thread. Did something change? Is there a simple way to monitor a daily log called for example log-rrrr-mm-dd? On Windows BTW.

                Comment

                • andris
                  Zabbix developer
                  • Feb 2012
                  • 228

                  #9
                  Hi!

                  You can try something like
                  logrt["C:\path\to\file\^ log-...-[01][0-9]-[0-3][0-9]$,[Ee][Rr][Rr][Oo][Rr]]

                  Zabbix agent will automatically pick up logfiles in (hopefully) correct order based on their timestamp and size changes. It is importand that file names match the regexp (.e.g. ^ log-...-[01][0-9]-[0-3][0-9]$). Naming scheme used for log rotation is not important.

                  Andris

                  Comment

                  Working...