Switching

Expand all | Collapse all

sh log messages

  • 1.  sh log messages

     
    Posted 03-31-2020 15:38

    Hi all,

     

    There is a syslog conf. on the qfx and its log messages files are:

    > file list /var/log/mes*
    /var/log/messages
    /var/log/messages.0.gz
    /var/log/messages.1.gz
    /var/log/messages.2.gz
    /var/log/messages.3.gz
    /var/log/messages.4.gz
    /var/log/messages.5.gz
    /var/log/messages.6.gz
    /var/log/messages.7.gz
    /var/log/messages.8.gz
    /var/log/messages.9.gz

     

    My question is how can be showed all of numbered log message files on the screen at a time rather than doing >show log messages.X.gz for each log message files?

     

    Thx

    A



  • 2.  RE: sh log messages

     
    Posted 03-31-2020 21:35

    Hi 

     

    I am not sure if we can do this in the cli. 

    However from the shell we should be able to display all the messages:

    >start shell

    %cd /var/log

    %zcat messages*

     

    However this zcat will fail for the first message file which is not zipped (all other archived files are zipped).

     

    Hope this helps



  • 3.  RE: sh log messages

    Posted 03-31-2020 23:32

    Hi Arix, 

     

    Greetings, 

    As per my understanding, there is no CLI command to perform the operation.

    But you can achieve the same from the shell for all files using: 

    > start shell
    % cd /var/log
    % zcat -f messages*

    Please mark "Accept as solution" if this answers your query. 

    Kudos are appreciated too! 

     

    Regards, 
    Sharat Ainapur


    #logmessages
    #shell


  • 4.  RE: sh log messages

     
    Posted 04-01-2020 01:05

    Hello Arix,

     

    The following CLI command will print contents of messages.* files in chronological order:

    start shell command "ls -tr /var/log/messages* | xargs zcat -f"

    Best regards,

    Sergii

    -------------------------------------------------------------------

    Please accept the solution if your problem is resolved Smiley Happy

    -------------------------------------------------------------------



  • 5.  RE: sh log messages

     
    Posted 06-03-2020 17:40

    Hi

    As you know there is a count argument in the Junos CLI... Is there a way to use some thing -count in the shell following command. I tried the following didn't work.

     

    >start shell command "ls -tr /var/log/messages* | xargs zcat -f | grep snmpd | count"

    count: Command not found.
    xargs: zcat: terminated with signal 13; aborting



  • 6.  RE: sh log messages

    Posted 06-03-2020 17:58

    Arix, 

     

    Use the below command to count :

    start shell command "ls -tr /var/log/messages* | xargs zcat -f | grep snmpd | wc -l"

     

     

    Please mark "Accept as solution" if this answers your query. 

     

    Kudos are appreciated too! 

     

    Regards, 

    Sharat Ainapur



  • 7.  RE: sh log messages

    Posted 06-04-2020 00:09

    Hi Arix, 

     

    Thanks for the kudos.

     

    Did you get a chance to verify this on your device ? Just wanted to check if this worked for you.

     

    Are there any other questions pertaining to this topic that you need answers for ?

     

    On the Lab Device, I got the output something like below: 

    root@lab> start shell command "ls -tr /var/log/messages* | xargs zcat -f | grep snmpd | wc -l" 
    124

     

    Also, could you please mark this as "Accepted solution" if this answered your query. 

     

    Regards, 

    Sharat



  • 8.  RE: sh log messages

    Posted 04-06-2020 21:57

    Hi Arix, 

     

    Greetings, 

     

    Request you to mark the solution for the queries you post as accepted if it answered your query/queries.

    This would enable others to find the right solution for the same/similar queries on the forum.

    Mark "Accept as solution" if my post answered your query. 

     

    Regards, 

    Sharat Ainapur