Sunday, January 6, 2008

mldonkey on FreeBSD 6.2 without gui

There is a problem with mldonkey port on FreeBSD 6.2 (/usr/ports/net-p2p/mldonkey) when You want install this software without gui, only just with web or telnet interface.

1. Fetch the latest ports. I use portsnap so i just type portsnap fetch && portsnap update
2. Go to the mldonkey port directory (/usr/ports/net-p2p/mldonkey) and patch Makefile with this patch.Makefile. Below is the listing:

--- Makefile Sun Jan 6 20:54:45 2008
+++ Makefile.new Sun Jan 6 19:44:18 2008
@@ -31,6 +31,7 @@
CONFIGURE_ARGS+=\
--enable-ocamlver=3 \
--with-libiconv-prefix=${LOCALBASE} \
+ --disable-gui
CONFIGURE_ENV+= \
NEWCXX="${CXX}" \
CPPFLAGS="${CPPFLAGS} -I${LOCALBASE}/include" \
@@ -182,12 +183,12 @@
@${INSTALL_SCRIPT} ${FILESDIR}/kill_mldonkey ${EXAMPLESDIR}
.endif
.ifndef(WITHOUT_GUI)
- @${INSTALL_PROGRAM} ${WRKSRC}/mlgui ${PREFIX}/bin
+# @${INSTALL_PROGRAM} ${WRKSRC}/mlgui ${PREFIX}/bin
.endif
.ifndef(WITHOUT_CORE && WITHOUT_GUI)
@${INSTALL_SCRIPT} ${WRKSRC}/distrib/mldonkey_previewer ${PREFIX}/bin
- @${INSTALL_PROGRAM} ${WRKSRC}/mlguistarter ${PREFIX}/bin
- @${INSTALL_PROGRAM} ${WRKSRC}/mlnet+gui ${PREFIX}/bin
+# @${INSTALL_PROGRAM} ${WRKSRC}/mlguistarter ${PREFIX}/bin
+# @${INSTALL_PROGRAM} ${WRKSRC}/mlnet+gui ${PREFIX}/bin
.endif
.ifndef(NOPORTDOCS)
@${MKDIR} ${DOCSDIR}
To patch file type:
patch Makefile < patch.Makefile


3. make WITHOUT_GUI=yes && make install && make clean

Wednesday, November 14, 2007

jabberd2 components memory load stats using rrdtool

First we need to create rrd database:
jabber-load-create.sh
#!/bin/bash /usr/bin/rrdtool create jabber-load.rrd -s 300 \ DS:smmem:GAUGE:600:U:U \ DS:smhomebsdmem:GAUGE:600:U:U \ DS:c2smem:GAUGE:600:U:U \ DS:routermem:GAUGE:600:U:U \ DS:resolvermem:GAUGE:600:U:U \ DS:s2smem:GAUGE:600:U:U \ RRA:AVERAGE:0.5:1:1200 \ RRA:MIN:0.5:12:2400 \ RRA:MAX:0.5:12:2400 \ RRA:AVERAGE:0.5:12:2400 \ RRA:AVERAGE:0.5:1:1200 \ RRA:MIN:0.5:12:2400 \ RRA:MAX:0.5:12:2400 \ RRA:AVERAGE:0.5:12:2400 \ RRA:AVERAGE:0.5:1:1200 \ RRA:MIN:0.5:12:2400 \ RRA:MAX:0.5:12:2400 \ RRA:AVERAGE:0.5:12:2400 \ RRA:AVERAGE:0.5:1:1200 \ RRA:MIN:0.5:12:2400 \ RRA:MAX:0.5:12:2400 \ RRA:AVERAGE:0.5:12:2400 \ RRA:AVERAGE:0.5:1:1200 \ RRA:MIN:0.5:12:2400 \ RRA:MAX:0.5:12:2400 \ RRA:AVERAGE:0.5:12:2400 \ RRA:AVERAGE:0.5:1:1200 \ RRA:MIN:0.5:12:2400 \ RRA:MAX:0.5:12:2400 \ RRA:AVERAGE:0.5:12:2400


Script to getting statistic from *nix system.
jabber-load.sh
#!/bin/bash

smmem=`ps ux | grep sm | grep -v grep | grep xml |grep -v sm.homebsd.xml | awk '{print $4}'`
smhomebsdmem=`ps ux | grep sm | grep -v grep | grep xml| grep -v sm.xml| awk '{print $4}'`
c2smem=`ps ux | grep c2s | grep -v grep | grep xml| awk '{print $4}'`
routermem=`ps ux | grep router | grep -v grep | grep xml | awk '{print $4}'`
resolvermem=`ps ux | grep resolver | grep -v grep | grep xml | awk '{print $4}'`
s2smem=`ps ux | grep s2s | grep -v grep | grep xml | awk '{print $4}'`


echo "$smmem"
echo "$smhomebsdmem"
echo "$c2smem"
echo "$routermem"
echo "$resolvermem"
echo "$s2smem"

Script to making update to rrd database and creating graphs
jabber-load-update.sh (parametrs)
#!/bin/bash
RRD="/usr/bin/rrdtool"
DT="/root/stats/jabber-memory/jabber-load.sh"
DB="/root/stats/jabber-memory/jabber-load.rrd"
COMMENT="Generated on `date "+%d %m %y %H\:%M %Z"`"
IMAGE="/home/httpd/html/jabber/stats/jabber-memory-load-$1.png"
TITLE="Jabber component memory load - $1"
VALUES=`$DT | while read x; do echo -n ":$x"; done`
$RRD update $DB N$VALUES
$RRD graph $IMAGE -s -1"$1" -e now -a PNG \
-t "$TITLE" \
-v "%" \
DEF:smmem=$DB:smmem:AVERAGE \
DEF:smhomebsdmem=$DB:smhomebsdmem:AVERAGE \
DEF:c2smem=$DB:c2smem:AVERAGE \
DEF:routermem=$DB:routermem:AVERAGE \
DEF:resolvermem=$DB:resolvermem:AVERAGE \
DEF:s2smem=$DB:s2smem:AVERAGE \
COMMENT:" now avg. max. min."\\n \
LINE1:smmem#ff0000:"smmem" \
GPRINT:smmem:LAST:" %5.1lf" \
GPRINT:smmem:AVERAGE:"%5.1lf" \
GPRINT:smmem:MAX:"%5.1lf" \
GPRINT:smmem:MIN:"%5.1lf"\\n \
LINE1:smhomebsdmem#ff00ff:"smhomebsdmem" \
GPRINT:smhomebsdmem:LAST:"%5.1lf" \
GPRINT:smhomebsdmem:AVERAGE:"%5.1lf" \
GPRINT:smhomebsdmem:MAX:"%5.1lf" \
GPRINT:smhomebsdmem:MIN:"%5.1lf"\\n \
LINE1:c2smem#0000ff:"c2smem" \
GPRINT:c2smem:LAST:" %5.1lf" \
GPRINT:c2smem:AVERAGE:"%5.1lf" \
GPRINT:c2smem:MAX:"%5.1lf" \
GPRINT:c2smem:MIN:"%5.1lf"\\n \
LINE1:routermem#00ffff:"routermem" \
GPRINT:routermem:LAST:" %5.1lf" \
GPRINT:routermem:AVERAGE:"%5.1lf" \
GPRINT:routermem:MAX:"%5.1lf" \
GPRINT:routermem:MIN:"%5.1lf"\\n \
LINE1:resolvermem#00ff00:"resolvermem" \
GPRINT:resolvermem:LAST:" %5.1lf" \
GPRINT:resolvermem:AVERAGE:"%5.1lf" \
GPRINT:resolvermem:MAX:"%5.1lf" \
GPRINT:resolvermem:MIN:"%5.1lf"\\n \
LINE1:s2smem#ffff00:"s2smem" \
GPRINT:s2smem:LAST:" %5.1lf" \
GPRINT:s2smem:AVERAGE:"%5.1lf" \
GPRINT:s2smem:MAX:"%5.1lf" \
GPRINT:s2smem:MIN:"%5.1lf"\\n \
COMMENT:"$COMMENT"
using: jabber-load-update.sh (parametrs: hour, day, week, etc - period of time)

And script to creating graphs
jabber-load-graph.sh
#!/bin/bash /root/stats/jabber-memory/jabber-load-update.sh hour > /dev/null 2>&1 /root/stats/jabber-memory/jabber-load-update.sh day > /dev/null 2>&1 /root/stats/jabber-memory/jabber-load-update.sh week > /dev/null 2>&1 /root/stats/jabber-memory/jabber-load-update.sh month > /dev/null 2>&1 /root/stats/jabber-memory/jabber-load-update.sh year > /dev/null 2>&1
Example graphs:


Thursday, June 28, 2007

How to make simple mail notification using jabber (using jabber.class.php and procmail)

jabber.class.php - cjphp.netflint.net/
procmail
jabber server or acount on xmmp server ( i using it on non ssl connection, with ssl jabber.class.php crashed )
php cmd installed

Let's start :

First create files in your home directory like below:
.forward

| /usr/bin/procmail

.procmailrc
:0 c
| $HOME/mail2jabber.sh

mail2jabber.sh
#!/bin/bash
(cat - | formail -X From: -X Subject:
echo .
echo quit
) | /usr/bin/php mail2jabber.php

mail2jabber.php
require("class.jabber.php");
?>
$JABBER = new Jabber;
?>
$JABBER->server = "your server name ( example: chrome.pl)";
$JABBER->port = "5222";
$JABBER->username = "username";
$JABBER->password = "password";
$JABBER->resource = "ClassJabberPHP";
$JABBER->enable_logging = FALSE;
//$JABBER->log_filename = "logfile.txt";
?>
$JABBER->Connect() or die("Couldn't connect!");
$JABBER->SendAuth() or die("Couldn't authenticate!");
$JABBER->SendPresence(NULL, NULL, "online");
$JABBER->SendMessage("where send a message ex. adm@chrome.pl",
"normal",
NULL,
array( // body, thread... whatever
"body" => "You have a new messages on „email account name” ! log in and
check on "mail www interface" or use favourite mail client :) "
)
);
$JABBER->Disconnect();
?>

Then:
copy class.jabber.php
chmod 755 mail2jabber.sh


enjoy

jabberd 2.1.4 on SunOs 5.10 (Solaris) / instalacja jabberd 2.1.4 na SunOs 5.10 (Solaris)

instalacja jabberd 2.1.4 na SunOs 5.10 (Solaris)

./configure “parameters”
comment out in config.h this line "#define HAVE_VSYSLOG"

This is likely due to the fact that Solaris doesn't accept NULL values passed to vsnprintf and related functions. jabberd2 has implemented some workounds specific to vsnprintf, but left out vsyslog, which uses the system vsnprintf under the hood.

cd /sm
edit Makefile
find in /sm/Makefile
sm_LDFLAGS = -Wl,-export-dynamic

and replace with:
sm_LDFLAGS = -Wl -B dynamic

make
make install
without this change sm_LDFLAGS = -Wl -B dynamic
jabberd don't compile , error was in sm without change in config.h c2s just died after the starting jabberd maybe its just a one of lot solution, really i don't know

multiple domain on jabberd2 / wiele domen na jabberd2

if you have properly configured and running server :)

usualy config files are in /etc/jabberd
copy sm.xml to other file example sm.domain2.xml

change:
<>
<>to your second domain example: domain2.com< /id >
optionaly:

<>
<>server< /category > >
<>im< /type >
<>domain2.com server < /name >
< /identity >
change pid file example:
/usr/local/var/jabberd/pid/sm.domain2.pid
add line to jabberd.cfg
sm /usr/local/etc/jabberd/sm.domain2.xml

add line to c2s.xml
< enable="'true'">domain2.com< /id >

to set up multiple domain support you need to run separate sm proceses i will show you a simple way to do it
locate sm executable file, usually it is on /usr/local/bin
cp sm sm.domain2
then

edit jabber run script
locate line:
progs="router resolver sm c2s s2s"

and replace with
progs="router resolver sm sm.domain2 c2s s2s"
in this way you dont need to make a new startup scripts :D

So you need too to setup corectly your jabber SRV record in DNS server for your new/next domain enjoy