Ad Widget

Collapse

extract two string log file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lib95
    Junior Member
    • Feb 2013
    • 21

    #1

    extract two string log file

    Hello,

    I search to extract the lines containing two string <Begin_DateTime> and <End_Datetime> and RC 0 or 1 from a logfile.
    How is it possible to do it ?

    Thank you

    Best regards

    lib95
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    That's 4 things you want to find from the log, based on my counting....

    But making all of them match .. https://regex101.com/r/jQvDQ1/1

    Comment

    • lib95
      Junior Member
      • Feb 2013
      • 21

      #3
      Hello,

      Thank you, I will try .* <(Begin|End)_Date[Tt]ime> .*RC (\d) on logrt

      Best regards

      Comment

      • lib95
        Junior Member
        • Feb 2013
        • 21

        #4
        Hello,

        Ok thank you but doesn't resolve my issue
        I have created two items logs for get Start and End data, but items are empty
        log[/logmsg,,"*Start : [(a-zA-Z0-9+)]"]
        log[/logmsg,,"*End [RC*] : [(a-zA-Z0-9+)]"]

        Best regards​

        Comment

        • cyber
          Senior Member
          Zabbix Certified SpecialistZabbix Certified Professional
          • Dec 2006
          • 4807

          #5
          So fix it... that's about all I can say based on the info that you provided...

          None of your regexes match anything in your initial examples... Those might be bogus, but you should provide some real examples to expect any help. Show us the item config, provide some examples etc.. We are no miracle workers...

          Comment

          • lib95
            Junior Member
            • Feb 2013
            • 21

            #6
            Hello,

            Thank you, my question was not clear, sorry, on the log file, I try to get the last entries like below :
            2023-03-03 02:10:13 Log : ############### END [RC= 0] : 2023-03-02 19:02:59 ################################
            2023-03-03 02:10:13 Log : ############### START : 2023-03-03 02:10:13 ########################################​

            Best regards

            Comment

            • cyber
              Senior Member
              Zabbix Certified SpecialistZabbix Certified Professional
              • Dec 2006
              • 4807

              #7
              First regex "*Start : [(a-zA-Z0-9+)]"...
              1. you cannot start regex with a multiplier... because it has no preceding tokens...
              2. your pattern is START not Start...
              your regex might be simply ".* START : .*"

              Second regex: "*End [RC*] : [(a-zA-Z0-9+)]"...
              1. again .. do not start with quantifier...
              2. again ... END vs End....
              3. [] in regex has special meaning... so if you want to search for [] literally, you need to escape them ..
              your regex might be ".*END \[RC=.*\] : .*"

              Please bookmark https://regex101.com/ and use it to test your regexes. It will explain in details, how everything is matched...

              Comment

              • lib95
                Junior Member
                • Feb 2013
                • 21

                #8
                Thank you

                regards

                Comment

                Working...