include monit in standard install (daemon monitor)

intersol

Joined
Oct 19, 2007
Messages
6
Likes
0
Points
0
#1
I think it would a very good ideea to include in the standard install the "monit" application.
http://tildeslash.com/monit/ or "yum install monit"


This daemon is monitoring the other daemons (services) and restarts them if neccesary (crash, not responding,...).

It's very easy to install and customize.

I've installed it manually on elastix for restarting asterisk daemon when it does crash.<br><br>Post edited by: intersol, at: 2008/01/10 21:56
 

ramoncio

Joined
May 12, 2010
Messages
1,663
Likes
0
Points
0
#2
Re:include monit in standard install (daemon monit

This looks very nice!!!
I'm compiling it now!!

wget http://tildeslash.com/monit/dist/monit-4.10.1.tar.gz
tar xfvz monit-4.10.1.tar.gz
cd monit-4.10.1
./configure
make && make install
I haven't found it in the default yum repositories.
Now i've found the rpm here:
http://dag.wieers.com/rpm/packages/moni ... f.i386.rpm

I have installed it from source though.

Where do I put the monitrc control file?
Which config did you use for asterisk??
 

ramoncio

Joined
May 12, 2010
Messages
1,663
Likes
0
Points
0
#3
Re:include monit in standard install (daemon monit

I finally removed the source version and installed the rpm one.
Now it is working finally.
Great program! Really nice!
Thanks a lot!!

Most of the examples are for Debian machines. I have modified them to work with Elastix.
Here I post my config files. Put them in /etc http://forum.elastix.org/old_files/monit.gz
 

ramoncio

Joined
May 12, 2010
Messages
1,663
Likes
0
Points
0
#4

ramoncio

Joined
May 12, 2010
Messages
1,663
Likes
0
Points
0
#5
Re:include monit in standard install (daemon monit

I really love monit!!
It restarts all hanged processes.
Even has a nice web inteface!!
Thanks again for the info!!
 

Telco

Joined
Oct 4, 2007
Messages
275
Likes
0
Points
0
#6
Re:include monit in standard install (daemon monit

I tried the step by step instructions:

cd /usr/src

wget http://dag.wieers.com/rpm/packages/moni ... f.i386.rpm

rpm -ivh monit-4.9-1.el5.rf.i386.rpm

cd /etc

wget http://www.elastix.org/components/com_j ... s/monit.gz

tar xfvz monit.gz

mv monit.gz /usr/src/monit-4.9-1.el5.rf.i386-configfiles.gz

chkconfig monit on

service monit restart

I recieved this error.

Shutting down Process Monitor (monit): [FAILED]
Starting Process Monitor (monit): /etc/monit.d/samba:5: Error: the executable does not exist '/etc/init.d/smb'
/etc/monit.d/samba:6: Error: the executable does not exist '/etc/init.d/smb'
[FAILED]


any ideas?
 

ramoncio

Joined
May 12, 2010
Messages
1,663
Likes
0
Points
0
#7
Re:include monit in standard install (daemon monit

This is because you don't have samba installed.
I installed it and configure monit to work with it.
You can either istall samba (yum -y install samba) or you can remove samba from monit config file (rm -rf /etc/monit.d/samba).
The restart monit and it should work.
 

ramoncio

Joined
May 12, 2010
Messages
1,663
Likes
0
Points
0
#8
Re:include monit in standard install (daemon monit

You can access the web interface in http://yourserver:2812 with username admin and password monit (you can change it in /etc/monit.conf)
 

Telco

Joined
Oct 4, 2007
Messages
275
Likes
0
Points
0
#9
Re:include monit in standard install (daemon monit

Fantastic... What a great addon. Thanks. After installing samba it worked like a champ.<br><br>Post edited by: Telco, at: 2008/01/17 00:27
 

ramoncio

Joined
May 12, 2010
Messages
1,663
Likes
0
Points
0
#10
Re:include monit in standard install (daemon monit

You must remember you are using monit!!
A couple of days ago I was testing faxing and I had some trouble as monit was waking up hylafax every 120 seconds (while I wanted it stopped).
killall monit solved it
 

ramoncio

Joined
May 12, 2010
Messages
1,663
Likes
0
Points
0
#11

ramoncio

Joined
May 12, 2010
Messages
1,663
Likes
0
Points
0
#12

ramoncio

Joined
May 12, 2010
Messages
1,663
Likes
0
Points
0
#13
Re:include monit in standard install (daemon monit

Here is my latest script to install monit:

cd /usr/src
wget http://dag.wieers.com/rpm/packages/moni ... f.i386.rpm
rpm -ivh monit-4.9-1.el5.rf.i386.rpm
cd /etc
wget http://www.elastix.org/components/com_j ... nit_cvs.gz
tar xfzv monit_cvs.gz
mv monit_cvs.gz /usr/src/monit-cvs.el5.rf.i386-configfiles.gz
chkconfig monit on
cd /usr/src
yum -y install cvs
cvs -z3 -d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/monit co monit
cd monit
./autogen.sh
make all install
cp --reply=yes /usr/bin/monit /usr/bin/monit.old
rm -rf /usr/bin/monit
ln -s /usr/local/bin/monit /usr/bin/monit
cp /etc/monit.conf /etc/monitrc
service monit restart
# Add Elastix menuitem
last_resource=`sqlite3 /var/www/db/acl.db "select * from acl_resource;" | awk -F "|" '1 { print $1 }' | tail -1`
resource_to_use=`expr $last_resource + 1`
last_permission=`sqlite3 /var/www/db/acl.db "select * from acl_group_permission;" | awk -F "|" '1 { print $1 }' | tail -1`
group_permission_to_use=`expr $last_permission + 1`
sqlite3 /var/www/db/menu.db "insert into menu (id,IdPArent,Link,Name,Type) values ('Monit','system','http://`ifconfig | grep 'inet addr:' | grep -v 127.0.0.1 | cut -f2 -d: | awk '{print $1":2812"}'`','Monit','framed');"
sqlite3 /var/www/db/acl.db "insert into acl_resource (id,name,description) values ('$resource_to_use','Monit','Monit');"
sqlite3 /var/www/db/acl.db "insert into acl_group_permission (id,id_action,id_group,id_resource) values ('$group_permission_to_use',1,1,'$resource_to_use');"
# Add translations to all lang files
for i in `ls -1 /var/www/html/lang/`; do
mv /var/www/html/lang/$i /var/www/html/lang/$i.backup
sed '/^\$arrLang=array/a \"Monit\" => \"Monit\",' /var/www/html/lang/$i.backup > /var/www/html/lang/$i
done;
rm -rf /var/www/html/lang/*.backup
Remove from /etc/monit.d/ all the services you are not using, and then

service monit restart

cvs version can monitor sip requests too. Have a look at /etc/monit.d/asterisk and configure it to suit your needs.
At the moment, monitoring sip hasn't worked for me.

You can find more info here:
http://www.0xdecafbad.com/index.php/200 ... ip-flavour

NOTE:
You should change in /etc/monit.conf the email notify address, as I'm receiving in my email monit messages of some of your servers:
Host: elastix.abudine.it
Host: Genesis-ES.com<br><br>Post edited by: ramoncio, at: 2008/02/06 18:27
 

aliarjmandi

Joined
Aug 20, 2008
Messages
11
Likes
0
Points
0
#14
Re:include monit in standard install (daemon monit

Hi
I have same error .
Please help me.
 

Chilling_Silence

Joined
Sep 23, 2008
Messages
488
Likes
0
Points
0
#15
Re:include monit in standard install (daemon monit

Take out the samba parts from the sample config.

Ive used it a few times on Trixbox machines, mostly to restart HUDlite-server when it died (regularly).

I had it restarting apache when it used over 95MB memory also, as well as checking asterisk & restarting amportal.

Basically asterisk never died, and while it could be cool for helping with the memory leak bug Ive had with OpenFire, every time monit reboots it, that would kick all clients.

Ive got monit on a VPS now, I have all my client boxes establish a VPN connection to it (I do "managed" solutions for my clients so this allows NAT / Firewall traversal) and then monit on my VPS pings the clients to make sure they're alive and email alert me if they're not.

Not *really* as useful on a client box as I would have thought :-/

What was useful is trunk monitoring. I have a perl script (Not related to monit at all) which checks every 2 minutes if a SIP / IAX trunk is connected. If it is, then thats brilliant, but if its not then it emails my iPhone and alerts me that something needs fixing!

Post if there's any interest in this script
 

ramoncio

Joined
May 12, 2010
Messages
1,663
Likes
0
Points
0
#16
Re:include monit in standard install (daemon monit

Hi Chilling_Silence,
Can you post this script here?
I am interested indeed.


Have you tried Nagios?
This is also a really good monitoring tool, but I'm still learning how to use it.
You can install it following the fedora instructions at nagios website.
It looks a lot nicer and more powerfull than monit.
But I'm not sure if it can restart the dead processes.
 

onsite

Joined
Sep 10, 2007
Messages
35
Likes
0
Points
0
#17
Second the interest for the script (it sounds lovely!B) )
 

ramoncio

Joined
May 12, 2010
Messages
1,663
Likes
0
Points
0
#18
This is my last script to install monit:

Code:
cd /usr/src
wget http://mmonit.com/monit/dist/beta/monit-5.0_beta6.tar.gz
tar xfvz monit-5.0_beta6.tar.gz
cd monit-5.0_beta6
./configure --prefix=/usr
make && make install
cd /etc/
wget http://www.lolacolay.com/ramon/monitconfig.tgz
tar xfvz monitconfig.tgz
mv monit /etc/init.d/
chmod +x /etc/init.d/monit
mv monitconfig.tgz /usr/src/monit-5.0_beta6/
chmod 700 /etc/monit.conf
rm -rf /etc/monit.d/webmin
rm -rf /etc/monit.d/samba
a=`ifconfig | grep 'inet addr:' | grep -v 127.0.0.1 | cut -f2 -d: | awk '{print $1}'`
perl -pi -e 's/192.168.160.1/'$a'/g' /etc/monit.d/asterisk
perl -pi -e 's/192.168.160.222/'$a'/g' /etc/monit.d/httpd
/etc/init.d/monit restart
# Add Elastix menuitem
last_resource=`sqlite3 /var/www/db/acl.db "select * from acl_resource;" | awk -F "|" '1 { print  $1 }' | tail -1` 
resource_to_use=`expr $last_resource + 1` 
last_permission=`sqlite3 /var/www/db/acl.db "select * from acl_group_permission;" | awk -F "|" '1 { print  $1 }' | tail -1` 
group_permission_to_use=`expr $last_permission + 1` 
sqlite3 /var/www/db/menu.db  "insert into menu (id,IdPArent,Link,Name,Type) values ('Monit','system','http://`ifconfig | grep 'inet addr:' | grep -v 127.0.0.1 | cut -f2 -d: | awk '{print $1":2812"}'`','Monit','framed');" 
sqlite3 /var/www/db/acl.db  "insert into acl_resource (id,name,description) values ('$resource_to_use','Monit','Monit');" 
sqlite3 /var/www/db/acl.db  "insert into acl_group_permission (id,id_action,id_group,id_resource) values ('$group_permission_to_use',1,1,'$resource_to_use');" 
# Add translations to all lang files
for i in `ls -1 /var/www/html/lang/`; do 
mv /var/www/html/lang/$i /var/www/html/lang/$i.backup
sed '/^\$arrLang=array/a \"Nagios\" => \"Nagios\",' /var/www/html/lang/$i.backup > /var/www/html/lang/$i
done;
rm -rf /var/www/html/lang/*.backup
To enter the web interface go to the System tab in Elastix's menu and you should have a new entry Monit.
User: admin
Pass: monit
Or you can go to http://yourserverip:2812
 

ramoncio

Joined
May 12, 2010
Messages
1,663
Likes
0
Points
0
#19
And this is my latest script to install Nagios. :)

Code:
yum install -y gcc glibc glibc-common gd gd-devel
/usr/sbin/useradd -m nagios
echo "nagios:123456" | chpasswd
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd asterisk
cd /usr/src/
mkdir nagios
cd nagios
wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.6.tar.gz
wget http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz
tar xfvz nagios-3.0.6.tar.gz
cd nagios-3.0.6
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
htpasswd -cb /usr/local/nagios/etc/htpasswd.users nagiosadmin 123456
service httpd restart
cd ..
tar xfvz nagios-plugins-1.4.13.tar.gz
cd nagios-plugins-1.4.13
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make && make install
chkconfig --add nagios
chkconfig nagios on
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
service nagios start
touch /usr/local/nagios/var/nagios.log
chown nagios /usr/local/nagios/var/nagios.log
# Add Elastix menuitem
last_resource=`sqlite3 /var/www/db/acl.db "select * from acl_resource;" | awk -F "|" '1 { print  $1 }' | tail -1` 
resource_to_use=`expr $last_resource + 1` 
last_permission=`sqlite3 /var/www/db/acl.db "select * from acl_group_permission;" | awk -F "|" '1 { print  $1 }' | tail -1` 
group_permission_to_use=`expr $last_permission + 1` 
sqlite3 /var/www/db/menu.db  "insert into menu (id,IdPArent,Link,Name,Type) values ('Nagios','system','nagios/','Nagios','framed');" 
sqlite3 /var/www/db/acl.db  "insert into acl_resource (id,name,description) values ('$resource_to_use','Nagios','Nagios');" 
sqlite3 /var/www/db/acl.db  "insert into acl_group_permission (id,id_action,id_group,id_resource) values ('$group_permission_to_use',1,1,'$resource_to_use');" 
# Add translations to all lang files
for i in `ls -1 /var/www/html/lang/`; do 
mv /var/www/html/lang/$i /var/www/html/lang/$i.backup
sed '/^\$arrLang=array/a \"Nagios\" => \"Nagios\",' /var/www/html/lang/$i.backup > /var/www/html/lang/$i
done;
rm -rf /var/www/html/lang/*.backup
To enter the web interface go to the System tab in Elastix's menu and you should have a new entry Nagios.
User: nagiosadmin
pass: 123456
 

onsite

Joined
Sep 10, 2007
Messages
35
Likes
0
Points
0
#20
Brilliant and useful scripts!

Just a question please:
Code:
perl -pi -e 's/192.168.160.1/'$a'/g' /etc/monit.d/asterisk
Code:
perl -pi -e 's/192.168.160.222/'$a'/g' /etc/monit.d/httpd
What the above lines do?

Maybe some more comments would be really helpful.

Thanks man!
 

Members online

No members online now.

Latest posts

Forum statistics

Threads
30,900
Messages
130,884
Members
17,561
Latest member
marouen
Top