| View previous topic :: View next topic |
| Author |
Message |
danswano Voice
Joined: 07 Apr 2011 Posts: 20
|
Posted: Thu Apr 07, 2011 8:03 am Post subject: Monitoring Eggdrop with Monit |
|
|
Hello everyone i would like to know how to monitor eggdrop with monit cause it's deffcult for me to do so, the eggdrop won't run as root and monit run as root by default, i have tried many shell commands to run eggdrop from root as another users but eggdrop won't boot and give error or languages missing.
monit requires some stuff to be able to monitor a script/service:
1. PID file (can be found)
2. Start command
3. Stop command
i was able to get all those stuff but the problem that it won't run as root or as another user from root.
anyone can help me with this?  |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Thu Apr 07, 2011 10:24 am Post subject: |
|
|
You aren't allowed to run eggdrop as root due to security issues.
#1 question: In the configuration file there's:
| Quote: |
# Specify here the filename Eggdrop will save its pid to. If no pidfile is
# specified, pid.(botnet-nick) will be used.
#set pidfile "pid.LamestBot"
|
#2 question:
If your eggdrop has an user file then start it normally with './eggdrop' if not start it 1 time with './eggdrop -m' if the configuration file is eggdrop.conf and with './eggdrop -m name-of-the-file.conf' if it's different (replace 'name-of-the-file.conf' with the actual name).
#3 question:
| Code: |
kill -9 `cat pid.LamestBot`
|
(replace pid.LamestBot with the actual file name) should do what you want  _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
danswano Voice
Joined: 07 Apr 2011 Posts: 20
|
Posted: Thu Apr 07, 2011 10:27 am Post subject: |
|
|
| Thanks buddy, i know how to get the pid/start/stop using kill or killall but my problem is how can i start eggdrop from root shell as another user without errors. |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Thu Apr 07, 2011 10:47 am Post subject: |
|
|
You can switch from root to any user without knowing his/her password via 'su username' and do whatever you wish from there.
Edit: From what I've just read, something like this should do what you want:
| Code: |
check process eggdrop with pidfile /home/user/eggdrop
start = "/root/eggdrop start"
stop = "/root/eggdrop stop"
|
And in '/root/eggdrop' you create a simple start/stop shell-script like here. _________________ Once the game is over, the king and the pawn go back in the same box.
Last edited by caesar on Thu Apr 07, 2011 11:00 am; edited 1 time in total |
|
| Back to top |
|
 |
danswano Voice
Joined: 07 Apr 2011 Posts: 20
|
Posted: Thu Apr 07, 2011 11:00 am Post subject: |
|
|
Great but how i will make as one command to put it in start command for monit ?
this works:
su username
./eggdrop
but tried:
su username ./eggdrop
it said
can't execute binary file
i want it as one line so i can put it in monit configuration file. |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Thu Apr 07, 2011 11:56 am Post subject: |
|
|
Here's a bash script that I did for you.
| Code: |
#!/bin/bash
# set the user
user="username"
# and the path to eggdrop dir
path="/home/$user/eggdrop"
function getPid {
pid=0
file=`/bin/ls $path | grep pid`
if [ -n "$file" ]; then
pid=`cat $path/$file`
fi
}
function getStatus {
status=0
if pidof eggdrop | grep [0-9] > /dev/null; then
status=1
fi
}
function status {
getStatus
case "$status" in
0)
echo -e "offline"
;;
1)
echo -e "online"
;;
esac
}
function start {
getStatus
if [ "$status" -eq "0" ]; then
su $user
cd $path
rm -fr *.pid
./eggdrop
fi
}
function stop {
getStatus
if [ "$status" -eq "1" ]; then
getPid
kill -9 $pid
rm -fr $path/*.pid
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status
;;
*)
echo "Usage: $0 {start|stop|status}"
esac
|
Haven't tested if it really starts/stops the bot, but it should work just fine.  _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
danswano Voice
Joined: 07 Apr 2011 Posts: 20
|
Posted: Thu Apr 07, 2011 12:06 pm Post subject: |
|
|
Hello dear, thanks for all replies, i've managed to run this command
su user -c /home/user/eggdrop/./eggdrop-1.6.20
and it working perfectly but monit requires a full path of the command and it means it wants it like this
/bin/su user -c /home/user/eggdrop/./eggdrop-1.6.20
but i'm getting this error after executing it.
[18:56:16] LANG: No lang files found for section core.
Eggdrop v1.6.20 (C) 1997 Robey Pointer (C) 2010 Eggheads
[18:56:16] --- Loading eggdrop v1.6.20 (Thu Apr 7 2011)
[18:56:16] * MSG534
any idea how can i bypass this ?  |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Fri Apr 08, 2011 2:48 am Post subject: |
|
|
Have you bothered to check out the script i did? _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
danswano Voice
Joined: 07 Apr 2011 Posts: 20
|
Posted: Fri Apr 08, 2011 10:49 am Post subject: |
|
|
Hello again,
thanks buddy for the awesome script, it worked flawlessly for me but there is an issue still:
when i run the sh file as the following from root it runs fine and execute the bot but it give this error
| Code: | root@server [/home/eggdrop]# /bin/su eggdrop /home/eggdrop/autobot/./autobot.sh start
/home/eggdrop/eggdrop/./eggdrop.sh: line 39: /bin/su: Permission denied
Eggdrop v1.6.20 (C) 1997 Robey Pointer (C) 2010 Eggheads
[17:38:06] --- Loading eggdrop v1.6.20 (Fri Apr 8 2011)
[14:38:06] Listening at telnet port 8362 (all).
[14:38:06] Module loaded: channels
[14:38:06] Module loaded: dns
[14:38:06] Module loaded: transfer (with lang support)
[14:38:06] Module loaded: share
[14:38:06] Module loaded: server
[14:38:06] Module loaded: ctcp
[14:38:06] Module loaded: irc
[14:38:06] Module loaded: notes (with lang support)
[14:38:06] Module loaded: console (with lang support)
[14:38:06] Module loaded: blowfish
[14:38:06] Module loaded: uptime
[14:38:06] RSS Syndication Script v0.5b1 (2007-12-17): Loaded.
[14:38:06] NickPlus : Loaded
[14:38:06] Writing channel file...
[14:38:06] Userfile loaded, unpacking...
[14:38:06] === eggdrop: 1 channels, 1 users.
Launched into the background (pid: 4986)
|
/home/eggdrop/eggdrop/./eggdrop.sh: line 39: /bin/su: Permission denied
on line 39 there is
Thanks for help, appreciate it  |
|
| Back to top |
|
 |
|