Ad Widget

Collapse

Mail Transaction Monitoring

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kamanita
    Junior Member
    • Nov 2006
    • 1

    #1

    Mail Transaction Monitoring

    Hi,

    is it possible to monitor a mail transaction with zabbix? that means:
    i want to send an mail over some relay hosts to an exchange server. on the exchange server the mail will be send backwards to my zabbix server. if the mail does not come back after some minutes i will send an alert mail!

    thanks

    kamanita
  • Calimero
    Senior Member
    • Nov 2006
    • 481

    #2
    Write a script that does all the stuff (send mail, check if reply has arrived).
    Use zabbix_sender to send your Zabbix Server if things are OK or not:

    1/ Create a new item for your host (here: mymailhost) in Zabbix
    - Description: whatever...
    - Type: Zabbix agent (active)
    - Key: mailcheck
    - Type of info: numeric

    2/ Send Zabbix info with zabbix_sender:

    zabbix_sender zabbix.server.com 10051 mymailhost mailcheck 1
    if things are OK, or:
    zabbix_sender zabbix.server.com 10051 mymailhost mailcheck 0
    if anything went wrong.

    You can then create triggers on you new item, whether current value is 1 or 0. You could nodata() to make sure you check script is still working...

    Comment

    • marcelein
      Junior Member
      • Apr 2008
      • 21

      #3
      im working on a solution this is my current status:

      i wrote two small scripts that check/send imap/pop3 mails
      the first script (sendmail.php) sends a mail to an autoresponder (which should not have to save those recieved mails. my adivse is to host this autoresponder on the zabbix server or on a freemailer with this feature)
      the second script checks if the mail from the autresponder has arrived in the mailbox and deletes it
      sendmail.php
      Code:
      <?php 
      //open POP3 or IMAP Server  
      $mbox = imap_open("{localhost:143}INBOX", "[email protected]", "password") or die("-1"); 
      $send = imap_mail("[email protected]","subject","message","From: [email protected]\n");
      echo $send;
      imap_expunge($mbox); 
      imap_close($mbox); 
      ?>
      chkmail.php
      Code:
      <?php 
      //open POP3 or IMAP Server  
      $mbox = imap_open("{localhost:143}INBOX", "[email protected]", "password") or die("-1"); 
      //calculate number of messages  
      $mbox_state=imap_check($mbox); 
      if($mbox_state) { 
                      //output number of messages
      		echo $mbox_state->Nmsgs;
      		//process messages one by one  
      		for($msgnum=1;$msgnum<=$mbox_state->Nmsgs;$msgnum++)	{ 
      			//delete this message from server 
      			imap_delete($mbox, $msgnum);  
      		} 
      } 
      imap_expunge($mbox); 
      imap_close($mbox); 
      ?>
      i added two UserParameters to my zabbix_agentd.conf
      Code:
      UserParameter=sendmail,php /home/zabbix/sendmail.php
      UserParameter=chkmail,php /home/zabbix/chkmail.php
      now i integrated those Parameters to my Host Items
      first for chkmail.php:
      description: Checkmail Script
      type: zabbix agent
      key: chkmail
      Update interval (in sec): 30

      second for sendmail.php:
      description: Sendmail Script
      type: zabbix agent
      key: sendmail
      Update interval (in sec): 300


      the scripts will send you data like:
      sendmail.php
      1 - Email has been send
      0 - Email has not been send
      -1 - Connection Error (this happens if your login data is wrong,the mailserver is down or something like that)

      chkmail.php
      n - Numbers of Mails in your Mailbox
      0 - No Mails in your Mailbox
      -1 - Connection Error (same as sendmail.php)

      actually im not sure how to setup a trigger for that maybe someone got some useful inspiration
      Last edited by marcelein; 10-04-2008, 14:29.

      Comment

      • miky84
        Junior Member
        • Jun 2021
        • 11

        #4
        Goodmorning,
        does anyone use this scripts?
        I'm trying on the zabbix version 5.4.2, but it give me an error "not supported".
        Last edited by miky84; 23-07-2021, 11:20.

        Comment

        Working...