Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logwatcher #34

Open
andreapernici opened this issue Jan 13, 2014 · 9 comments
Open

Logwatcher #34

andreapernici opened this issue Jan 13, 2014 · 9 comments

Comments

@andreapernici
Copy link

Is possible to run the logwatcher as a daemon or to make it run continuosly?

How the logwatcher graph should be read?
You show the occurence on a per minute base?

@MarynaIS
Copy link

Yep, I've written simple init.d, and take it on /etc/init.d:

#!/bin/bash

DAEMON_PATH="YOUR/PATH/TO/newrelic_logwatcher_agent.rb"
DAEMON=newrelic_logwatcher_agent.rb
NAME=newrelic_logwatcher_agent
PIDFILE=/var/run/$NAME.pid

case "$1" in
start)
printf "%-50s" "Starting $NAME..."
cd $DAEMON_PATH
PID=/bin/ps -fu $USER| grep "logwatcher" | grep -v "grep" | awk '{print $2}'
if [ -z $PID ]; then
printf "%s\n" "Fail"
else
echo $PID > $PIDFILE
printf "%s\n" "Ok"
fi
;;
status)
printf "%-50s" "Checking $NAME..."
if [ -f $PIDFILE ]; then
PID=cat $PIDFILE
if [ -z "ps axf | grep ${PID} | grep -v grep" ]; then
printf "%s\n" "Process dead but pidfile exists"
else
echo "Running"
fi
else
printf "%s\n" "Service not running"
fi
;;
stop)
printf "%-50s" "Stopping $NAME"
PID=cat $PIDFILE
if [ -f $PIDFILE ]; then
kill -HUP $PID
printf "%s\n" "Ok"
rm -f $PIDFILE
else
printf "%s\n" "pidfile not found"
fi
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {status|start|stop|restart}"
exit 1
esac

P.S.Don't forget make it executable(chmod 775 [this_file_name])

@andreapernici
Copy link
Author

I get this error
./newrelic-logwatcher.sh: line 13: -fu: command not found

Il 13/05/2014 09:03, MarynaIS ha scritto:

Yep, I've written simple init.d, and take it on /etc/init.d:

#!/bin/bash

description: newrelic logwatcher daemon

processname: newrelic logwatcher

DAEMON_PATH="YOUR/PATH/TO/newrelic_logwatcher_agent.rb"
DAEMON=newrelic_logwatcher_agent.rb
NAME=newrelic_logwatcher_agent
PIDFILE=/var/run/$NAME.pid

case "$1" in
start)
printf "%-50s" "Starting $NAME..."
cd $DAEMON_PATH
PID=|/bin/ps -fu $USER| grep "logwatcher" | grep -v "grep" | awk
'{print $2}'|
if [ -z $PID ]; then
printf "%s\n" "Fail"
else
echo $PID > $PIDFILE
printf "%s\n" "Ok"
fi
;;
status)
printf "%-50s" "Checking $NAME..."
if [ -f $PIDFILE ]; then
PID=|cat $PIDFILE|
if [ -z "|ps axf | grep ${PID} | grep -v grep|" ]; then
printf "%s\n" "Process dead but pidfile exists"
else
echo "Running"
fi
else
printf "%s\n" "Service not running"
fi
;;
stop)
printf "%-50s" "Stopping $NAME"
PID=|cat $PIDFILE|
if [ -f $PIDFILE ]; then
kill -HUP $PID
printf "%s\n" "Ok"
rm -f $PIDFILE
else
printf "%s\n" "pidfile not found"
fi
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {status|start|stop|restart}"
exit 1
esac

P.S.Don't forget make it executable(chmod 775 [this_file_name])


Reply to this email directly or view it on GitHub
#34 (comment).

--
Z-Light e Z-Pro: servizi zimbra per caselle con dominio email.it, per tutti i dettagli
Clicca qui http://posta.email.it/caselle-di-posta-email-it/?utm_campaign=email_Zlight_Pro&utm_source=footer/f

Sponsor:
Registra i domini che desideri ed inizia a creare il tuo sito web
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=13323&d=15-5

@andreapernici
Copy link
Author

Solved doing this

PID=/bin/ps -fu $USER| grep "logwatcher" | grep -v "grep" | awk '{print $2}'
if [[ -z $PID ]]; then

Il 13/05/2014 09:03, MarynaIS ha scritto:

Yep, I've written simple init.d, and take it on /etc/init.d:

#!/bin/bash

description: newrelic logwatcher daemon

processname: newrelic logwatcher

DAEMON_PATH="YOUR/PATH/TO/newrelic_logwatcher_agent.rb"
DAEMON=newrelic_logwatcher_agent.rb
NAME=newrelic_logwatcher_agent
PIDFILE=/var/run/$NAME.pid

case "$1" in
start)
printf "%-50s" "Starting $NAME..."
cd $DAEMON_PATH
PID=|/bin/ps -fu $USER| grep "logwatcher" | grep -v "grep" | awk
'{print $2}'|
if [ -z $PID ]; then
printf "%s\n" "Fail"
else
echo $PID > $PIDFILE
printf "%s\n" "Ok"
fi
;;
status)
printf "%-50s" "Checking $NAME..."
if [ -f $PIDFILE ]; then
PID=|cat $PIDFILE|
if [ -z "|ps axf | grep ${PID} | grep -v grep|" ]; then
printf "%s\n" "Process dead but pidfile exists"
else
echo "Running"
fi
else
printf "%s\n" "Service not running"
fi
;;
stop)
printf "%-50s" "Stopping $NAME"
PID=|cat $PIDFILE|
if [ -f $PIDFILE ]; then
kill -HUP $PID
printf "%s\n" "Ok"
rm -f $PIDFILE
else
printf "%s\n" "pidfile not found"
fi
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {status|start|stop|restart}"
exit 1
esac

P.S.Don't forget make it executable(chmod 775 [this_file_name])


Reply to this email directly or view it on GitHub
#34 (comment).

--
Z-Light e Z-Pro: servizi zimbra per caselle con dominio email.it, per tutti i dettagli
Clicca qui http://posta.email.it/caselle-di-posta-email-it/?utm_campaign=email_Zlight_Pro&utm_source=footer/f

Sponsor:
Scopri il nuovo HTC One M8, progettato per eccellere sotto ogni punto di vista
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=13321&d=15-5

@andreapernici
Copy link
Author

But unfortunatly now I get

/./newrelic-logwatcher.sh: line 34:
/var/run/newrelic_logwatcher_agent.pid: Permission denied

when doing logwatcher stop

/Il 13/05/2014 09:03, MarynaIS ha scritto:

Yep, I've written simple init.d, and take it on /etc/init.d:

#!/bin/bash

description: newrelic logwatcher daemon

processname: newrelic logwatcher

DAEMON_PATH="YOUR/PATH/TO/newrelic_logwatcher_agent.rb"
DAEMON=newrelic_logwatcher_agent.rb
NAME=newrelic_logwatcher_agent
PIDFILE=/var/run/$NAME.pid

case "$1" in
start)
printf "%-50s" "Starting $NAME..."
cd $DAEMON_PATH
PID=|/bin/ps -fu $USER| grep "logwatcher" | grep -v "grep" | awk
'{print $2}'|
if [ -z $PID ]; then
printf "%s\n" "Fail"
else
echo $PID > $PIDFILE
printf "%s\n" "Ok"
fi
;;
status)
printf "%-50s" "Checking $NAME..."
if [ -f $PIDFILE ]; then
PID=|cat $PIDFILE|
if [ -z "|ps axf | grep ${PID} | grep -v grep|" ]; then
printf "%s\n" "Process dead but pidfile exists"
else
echo "Running"
fi
else
printf "%s\n" "Service not running"
fi
;;
stop)
printf "%-50s" "Stopping $NAME"
PID=|cat $PIDFILE|
if [ -f $PIDFILE ]; then
kill -HUP $PID
printf "%s\n" "Ok"
rm -f $PIDFILE
else
printf "%s\n" "pidfile not found"
fi
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {status|start|stop|restart}"
exit 1
esac

P.S.Don't forget make it executable(chmod 775 [this_file_name])


Reply to this email directly or view it on GitHub
#34 (comment).

--
Z-Light e Z-Pro: servizi zimbra per caselle con dominio email.it, per tutti i dettagli
Clicca qui http://posta.email.it/caselle-di-posta-email-it/?utm_campaign=email_Zlight_Pro&utm_source=footer/f

Sponsor:
Pasticceri in poche mosse e' possibile con la splendida biscottiera elettrica, scoprila
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=13300&d=15-5

@MarynaIS
Copy link

check owner of file /var/run/newrelic_logwatcher_agent.pid (chown [user]:[user] var/run/newrelic_logwatcher_agent.pid) or change mod (chmod +755 var/run/newrelic_logwatcher_agent.pid)

or run /etc/init.d/newrelic_logwatcher as root(with sudo)

@andreapernici
Copy link
Author

When chmod 755 I get
Stopping newrelic_logwatcher_agent
/var/run/newrelic_logwatcher_agent.pid: line 1: 16350: command not found
and when I start /etc/init.d with root privileges leaving 644 I get
Stopping newrelic_logwatcher_agent /etc/init.d/newrelic-logwatcher: line
34: /var/run/newrelic_logwatcher_agent.pid: Permission denied

In any case nothing came up in the NewRelic dashboard.

Il 15/05/2014 12:43, MarynaIS ha scritto:

check owner of file /var/run/newrelic_logwatcher_agent.pid (chown
[user]:[user] var/run/newrelic_logwatcher_agent.pid) or change mod
(chmod +755 var/run/newrelic_logwatcher_agent.pid)


Reply to this email directly or view it on GitHub
#34 (comment).

--
Z-Light e Z-Pro: servizi zimbra per caselle con dominio email.it, per tutti i dettagli
Clicca qui http://posta.email.it/caselle-di-posta-email-it/?utm_campaign=email_Zlight_Pro&utm_source=footer/f

Sponsor:
Scegli il programma Partner di Email.it e offri ai tuoi clienti una valida alternativa a Office 365 incrementando i tuoi margini
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=13189&d=15-5

@MarynaIS
Copy link

Just in case, have you installed logwatcher?
and could you make
ls -la /var/run | grep "newrelic_logwatcher_agent.pid"

@andreapernici
Copy link
Author

Il 15/05/2014 15:54, MarynaIS ha scritto:

Just in case, have you installed logwatcher?
and could you make
ls -la /var/run | grep "newrelic_logwatcher_agent.pid"


Reply to this email directly or view it on GitHub
#34 (comment).

Yes is installed.

--
Z-Light e Z-Pro: servizi zimbra per caselle con dominio email.it, per tutti i dettagli
Clicca qui http://posta.email.it/caselle-di-posta-email-it/?utm_campaign=email_Zlight_Pro&utm_source=footer/f

Sponsor:
OFFERTA 3x2 Blu-Ray, tantissimi film e serie tv. Scopri tutto
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=13322&d=15-5

@esobczak1970
Copy link

Any plans to make this an npi compatible plugin?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants