Zimbra Sessions/Accounts

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Zimbra Sessions/Accounts

    Hi,

    I've created a quick&dirty script/template to monitor the current number of logged in users/sessions. Values are directly read via soap-request, but performance is quite bad, because 5 requests are done. I don't want to write the values into a text file because of preventing errors.

    Perl-Script:
    Code:
    #!/usr/bin/perl
    # /opt/zabbix/scripts/zimbraUsers.pl
    # Collect number of current users/sessions
    
    use XML::Simple;
    use Data::Dumper;
    
    $parm = $ARGV[0];
    
    $xml = new XML::Simple;
    
    # get data via soap-request
    $xmldata = `/bin/su -c 'zmsoap -z -t admin DumpSessionsRequest' - zimbra`;
    
    $data = $xml->XMLin($xmldata);
    
    if ($parm eq "Sessions") {
            print $data->{activeSessions};
    }
    
    if ($parm eq "soapAccounts") {
            print $data->{soap}{activeSessions};
    }
    
    if ($parm eq "soapSessions") {
            print $data->{soap}{activeSessions};
    }
    
    if ($parm eq "imapAccounts") {
            print $data->{imap}{activeAccounts};
    }
    
    if ($parm eq "imapSessions") {
            print $data->{imap}{activeSessions};
    }
    UserParameter:
    Code:
    UserParameter=zimbra.users[*],/usr/bin/sudo /opt/zabbix/scripts/zimbraUsers.pl $1
    sudoers-File:
    Code:
    #Zabbix
    zabbix  ALL=(ALL) NOPASSWD:/opt/zabbix/scripts/zimbraUsers.pl
    Items:
    zimbra.users[Sessions]
    zimbra.users[imapAccounts]
    zimbra.users[soapAccounts]
    zimbra.users[imapSessions]
    zimbra.users[soapSessions]

    Admin-Sessions and Accounts would also be possible, but I don't need it.

    There are more values I will try later: [1].
    Any comments are welcome.

    Regards,
    Stefan

    [0]: http://wiki.zimbra.com/wiki/Zmsoap#A...essionsRequest
    [1]: http://wiki.zimbra.com/wiki/Zmsoap#Collect_server_stats

    #2
    Hi,

    I did an update, because the soap-request doesn't show a value for zero connections. And there was an error in the if-statement:

    Code:
    #!/usr/bin/perl
    # Collect number of current users/sessions
    
    use XML::Simple;
    use Data::Dumper;
    
    $parm = $ARGV[0];
    
    $xml = new XML::Simple;
    
    # get data via soap-request
    $xmldata = `/bin/su -c 'zmsoap -z -t admin DumpSessionsRequest' - zimbra`;
    
    $data = $xml->XMLin($xmldata);
    
    if ($parm eq "Sessions") {
            if($data->{activeSessions} eq ""){
                    print "0";
            } else {
                    print $data->{activeSessions};
            }
    }
    
    if ($parm eq "soapAccounts") {
            if($data->{soap}{activeAccounts} eq ""){
                    print "0";
            } else {
                    print $data->{soap}{activeAccounts};
            }
    }
    
    if ($parm eq "soapSessions") {
            if($data->{soap}{activeSessions} eq ""){
                    print "0";
            } else {
                    print $data->{soap}{activeSessions};
            }
    }
    
    if ($parm eq "imapAccounts") {
            if($data->{imap}{activeAccounts} eq ""){
                    print "0";
            } else {
                    print $data->{imap}{activeAccounts};
            }
    }
    
    if ($parm eq "imapSessions") {
            if($data->{imap}{activeSessions} eq ""){
                    print "0";
            } else {
                    print $data->{imap}{activeSessions};
            }
    }
    Stefan

    Comment

    Announcement

    Collapse
    No announcement yet.
    Working...
    X