ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Get Active User Login Count from Dovecot

    IT Discussion
    imap imap4 pop3 pop email linux dovecot fedora centos rhel
    2
    3
    1.3k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • scottalanmillerS
      scottalanmiller
      last edited by

      Tested on CentOS 7.

      To get active IMAP logins...

      cat /var/log/maillog | grep imap-login:\ Login | sed -e 's/.*Login: user=<\(.*\)>, method=.*/\1/g' | sort | uniq | wc -l
      

      To get active POP3 logins...

      cat /var/log/maillog | grep pop3-login:\ Login | sed -e 's/.*Login: user=<\(.*\)>, method=.*/\1/g' | sort | uniq | wc -l
      

      Log location based on CentOS default. If using Ubuntu, you will need to adjust the log name slightly. Keep in mind that this count is only for the length of the maillog retention. Want longer, use more archived maillogs in the cat command (cat combines files, remember?)

      If you want all logins, you need to grep for both imap and pop3 at the same time, or else you will count duplicates.

      1 Reply Last reply Reply Quote 0
      • scottalanmillerS
        scottalanmiller
        last edited by

        @scottalanmiller said in Get Active User Login Count from Dovecot:

        cat /var/log/maillog | grep pop3-login:\ Login | sed -e 's/.Login: user=<(.)>, method=.*/\1/g' | sort | uniq | wc -l

        This tiny variation will get you all logins from all logs that you have stored.

        cat /var/log/maillog* | grep pop3-login:\ Login | sed -e 's/.*Login: user=<\(.*\)>, method=.*/\1/g' | sort | uniq | wc -l
        
        1 Reply Last reply Reply Quote 1
        • N
          non_j
          last edited by

          Variation for Debian 10 + Dovecot 2.3.4.1:

          cat /var/log/dovecot/dovecot.log | grep imap-login:\ Info:\ Login | sed -e 's/.*Login: user=<\(.*\)>, m
          ethod=.*/\1/g' | sort | uniq | wc -l
          
          1 Reply Last reply Reply Quote 2
          • 1 / 1
          • First post
            Last post