ispCP - Board - Support
[MUNIN Plugin] Mailadresses on Server - Printable Version

+- ispCP - Board - Support (http://www.isp-control.net/forum)
+-- Forum: ispCP Omega Contributions Area (/forum-40.html)
+--- Forum: Snippets (/forum-42.html)
+--- Thread: [MUNIN Plugin] Mailadresses on Server (/thread-5252.html)

Pages: 1 2 3


[MUNIN Plugin] Mailadresses on Server - Knut - 12-26-2008 05:35 PM

Moin,

ich persönlich schaue mir gerne die Entwicklung meines Servers via Munin grafisch an. Ob das nun die Anzahl der angelegten Sites oder Mailkonten ist.
Für letzteres möchte ich hier gerne das entsprechende Plugin zur Verfügung stellen. Vielleicht setzt jemand ebenfalls Munin ein und kann es gebrauchen.

Ich gehe dabei von einem fertig konfigurierten ispCP und Munin(-Node) aus. Mein verwendetes System ist ein Debian Etch.

1. Folgenden Code in /usr/share/munin/plugins/ispcp_mailuser speichern.

Code:
#!/bin/sh
#
# Autor : Knut Herter
# Datum : 26.12.2008
# Mail  : herter@systemtechnics.de
# Web   : www.systemtechnics.de
#
# Dies Plugin zeigt die Anzahl der angelegten Mailadresen in IspCP/vhcs2 an.
# Es wird dabei nicht zwischen einem Mailkonto oder Weiterleitung unterschieden!
#
# Wer mag kann dieses Plugin gerne lizenzfrei verwenden oder unveraendert weiter geben.
#
# Magic markers (optional - only used by munin-config and some
# installation scripts):
#
#%# family=auto
#%# capabilities=autoconf



# If run with the "autoconf"-parameter, give our opinion on wether we
# should be run on this system or not. This is optinal, and only used by
# munin-config. In the case of this plugin, we should most probably
# always be included.

if [ "$1" = "autoconf" ]; then
        echo yes
        exit 0
fi

if [ "$1" = "config" ]; then

        echo 'graph_title Mailaddresses on Server'
        echo 'graph_args --upper-limit 1000 -l 0'
        echo 'graph_vlabel Mailaddresses on Server'
        echo 'graph_category postfix'
        echo 'mailbox.label Mailaddresses'
        exit 0
fi

# Verzeichnis der Mailkonten
VMAIL=/var/mail/virtual

# Zum testen. 1 = an , 0 = aus
DEBUG=0

#Domainliste
DOMAINLIST=`ls $VMAIL`

#Anzahl der Mailkonten zuruecksetzen
MAILANZ=0

for DOMAIN in $DOMAINLIST
do
    T=`ls $VMAIL/$DOMAIN |wc -l`
        if [ $DEBUG = "1" ]; then  
        echo $DOMAIN = $T Mailkonten
    fi
    MAILANZ=`expr $MAILANZ + $T`    
done

echo "mailbox.value $MAILANZ"

2. Ausführbar machen.
Code:
chmod +x /usr/share/munin/plugins/ispcp_mailuser

3. Logischen Link setzen.
Code:
cd /etc/munin/plugins
ln -s /usr/share/munin/plugins/ispcp_mailuser

4. Die Konfiguration des Nodes editieren.
Code:
pico /etc/munin/plugin-conf.d/ munin-node
Folgendes einfügen:
Code:
[ispcp_mailuser]
user vmail

5. Munin-Node über das neue Plugin informieren. (Meine Erfahrung hat gezeigt, dass es nicht ausreicht das/die Node neu zu starten.
Code:
dpkg-reconfigure munin-node

Fertig.

Du findest die Grafik des Plugin unter dem Abschnitt Postfix. Anfangs wird sicherlich nicht viel zu sehen sein, über das Jahr gesehen erhoffe ich mir interessantere Grafiken :-)

Achja: Wem die Skalierung mit 1K (1000 Mailkonten) zu hoch ist braucht im Plugin einfach die Variable graph_args --upper-limit 1000 -l 0 ändern.

Download-Link vom Script : http://addons.isp-control.net/unofficial/ispcp_mailuser_www.isp-control.net.tar.gz


RE: [MUNIN Plugin] Mailadresses on Server - BeNe - 12-30-2008 10:19 PM

Danke für deine Arbeit! Hab es nach SNIPPETS verschoben!
Thanks for your work. Moved it to SNIPPETS!

Greez BeNe


RE: [MUNIN Plugin] Mailadresses on Server - DiXeoN - 12-31-2008 01:20 AM

Shouldn't this be in english? Smile

Just a though i got..


RE: [MUNIN Plugin] Mailadresses on Server - BeNe - 12-31-2008 10:19 PM

Of course it should be in English. But it was posted in the German Thread and i moved it to here. Maybe someone could translate if for all ?

So many infos and small functions are in the (big) German Corner. And all get´s more and more lost for the rest of the Community here because they are all in german and not english Shy

Greez BeNe


RE: [MUNIN Plugin] Mailadresses on Server - ancdix - 12-31-2008 11:21 PM

little translation Big Grin
(12-26-2008 05:35 PM)Knut Wrote:  Hi,

i like using munin to monitor my server. munin should show me the amount of websites and emailadresses.
if someone else want to use munin to monitor his server here is the plugin.

The system requiers a complete installation of ispCP and Munin(-Node).
This plugin runs on Debian Etch.

1. Save this code over here -> /usr/share/munin/plugins/ispcp_mailuser

Code:
#!/bin/sh
#
# Autor : Knut Herter
# Datum : 26.12.2008
# Mail  : herter@systemtechnics.de
# Web   : www.systemtechnics.de
#
# Dies Plugin zeigt die Anzahl der angelegten Mailadresen in IspCP/vhcs2 an.
# Es wird dabei nicht zwischen einem Mailkonto oder Weiterleitung unterschieden!
#
# Wer mag kann dieses Plugin gerne lizenzfrei verwenden oder unveraendert weiter geben.
#
# Magic markers (optional - only used by munin-config and some
# installation scripts):
#
#%# family=auto
#%# capabilities=autoconf



# If run with the "autoconf"-parameter, give our opinion on wether we
# should be run on this system or not. This is optinal, and only used by
# munin-config. In the case of this plugin, we should most probably
# always be included.

if [ "$1" = "autoconf" ]; then
        echo yes
        exit 0
fi

if [ "$1" = "config" ]; then

        echo 'graph_title Mailaddresses on Server'
        echo 'graph_args --upper-limit 1000 -l 0'
        echo 'graph_vlabel Mailaddresses on Server'
        echo 'graph_category postfix'
        echo 'mailbox.label Mailaddresses'
        exit 0
fi

# Verzeichnis der Mailkonten
VMAIL=/var/mail/virtual

# Zum testen. 1 = an , 0 = aus
DEBUG=0

#Domainliste
DOMAINLIST=`ls $VMAIL`

#Anzahl der Mailkonten zuruecksetzen
MAILANZ=0

for DOMAIN in $DOMAINLIST
do
    T=`ls $VMAIL/$DOMAIN |wc -l`
        if [ $DEBUG = "1" ]; then  
        echo $DOMAIN = $T Mailkonten
    fi
    MAILANZ=`expr $MAILANZ + $T`    
done

echo "mailbox.value $MAILANZ"

2. make it executable.
Code:
chmod +x /usr/share/munin/plugins/ispcp_mailuser

3. Create the login link
Code:
cd /etc/munin/plugins
ln -s /usr/share/munin/plugins/ispcp_mailuser

4. Edit the nodes config file.
Code:
pico /etc/munin/plugin-conf.d/ munin-node
Insert this:
Code:
[ispcp_mailuser]
user vmail

5. Reinitialise munin-non.
Code:
dpkg-reconfigure munin-node

Done

You'll find a graphic below the postfix stats.

PS: if the skale of the stats is to high (1000 Mailacounts) just change the Plugin variable graph_args --upper-limit 1000 -l 0


the translation is not perfect i know, but i think it's possible to understand Wink


RE: [MUNIN Plugin] Mailadresses on Server - BeNe - 12-31-2008 11:52 PM

Fine! Thanks man.

Greez BeNe


RE: [MUNIN Plugin] Mailadresses on Server - DaSilva - 02-16-2009 04:13 AM

Thanks for the handy plugins!
Can you make them dynamic like other plugins?
So that the graph always fits to the highest number?
Thanks.

And how can I add graphs for a month/year? Currently I can only see daily and weekly graphs...


RE: [MUNIN Plugin] Mailadresses on Server - Knut - 02-16-2009 04:33 AM

(02-16-2009 04:13 AM)DaSilva Wrote:  Can you make them dynamic like other plugins?
So that the graph always fits to the highest number?
Thanks.

Remove this line
Code:
echo 'graph_args --upper-limit 1000 -l 0'
then
Code:
dpkg-reconfigure munin-node
wait a few minutes ...

(02-16-2009 04:13 AM)DaSilva Wrote:  And how can I add graphs for a month/year? Currently I can only see daily and weekly graphs...

Hmm... klick at the images ?

EDIT: I think for monthly images wait a week, for yearly images wait a month.


Knut


RE: [MUNIN Plugin] Mailadresses on Server - DaSilva - 02-16-2009 05:14 AM

Thanks Smile


RE: [MUNIN Plugin] Mailadresses on Server - Knut - 05-20-2009 01:56 AM

Download Link for the Script : http://addons.isp-control.net/unofficial/ispcp_mailuser_www.isp-control.net.tar.gz