Unless I am missing something, pt-kill refuses to run from cron as it
requires STDIN to be available.
This is the command I run: PTDEBUG=1 /usr/local/bin/pt-kill --config /
etc/percona-toolkit/pt-kill-cleaner.conf
The config contains these non-sensitive pieces of information:
daemonize
log=/var/log/pt-kill.log
print
kill
pid=/var/run/pt-kill.pid
match-user=foobar
match-command=Query
busy-time=5
idle-time=30
interval=2
victims=all
wait-after-kill=2
Executed from the shell, the command runs fine and the process
daemonizes as expected.
Executed from crontab, the command runs one iteration and then exits.
Some of the output:
# pt_kill:3810 16106 Reading files -
..
# pt_kill:3810 16106 Checking processlist
# pt_kill:3810 16106 Processlist returned no queries
# pt_kill:3810 16106 Checking processlist
# pt_kill:3810 16106 /usr/local/bin/pt-kill ending
# Daemon:1631 16106 Removed PID file
As STDIN is not available to it the process tries to read STDIN,
fails, then exits.
The same behavior exhibits for both daemonize and without.
Why do you need to do it from cron - pt-kill is like a watchdog
process keeping an eye on processlist. IMHO, its better to keep it
always running instead of running from time to time, the latter can
miss or be delayed in killing a process. Also, if you use daemonize on
cron and pt-kill works as you expected you'll get a number of pt-kill
processes running!
On Jan 25, 2:14 pm, Atle <acv...@gmail.com> wrote:
> Executed from the shell, the command runs fine and the process > daemonizes as expected.
> Executed from crontab, the command runs one iteration and then exits. > Some of the output: > # pt_kill:3810 16106 Reading files - > .. > # pt_kill:3810 16106 Checking processlist > # pt_kill:3810 16106 Processlist returned no queries > # pt_kill:3810 16106 Checking processlist > # pt_kill:3810 16106 /usr/local/bin/pt-kill ending > # Daemon:1631 16106 Removed PID file
> As STDIN is not available to it the process tries to read STDIN, > fails, then exits.
> The same behavior exhibits for both daemonize and without.
> -- > You received this message because you are subscribed to the Google Groups "Percona Discussion" group. > To post to this group, send email to percona-discussion@googlegroups.com. > To unsubscribe from this group, send email to percona-discussion+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/percona-discussion?hl=en.
I am running the latest version of pt-kill (2.0.3) on Solaris 10 and I
have the same issue.
I believe the problem is related to this check:
pt-kill:3546
if ( !-t STDIN ) {
PTDEBUG && _d("STDIN is piped");
@ARGV = ('-');
}
No matter if I specified "--daemonize", STDIN is not /dev/tty then the
code:
pt-kill:3590
if ( @ARGV ) {
PTDEBUG && _d('Getting processlist from files:', @ARGV);
is executed instead of the expected:
pt-kill:3626
else {
PTDEBUG && _d('Getting processlist from MySQL');
I am not a PERL developer but I believe something like this should fix
this issue:
- if ( !-t STDIN ) {
+ if ( !$o->get('daemonize') && !-t STDIN ) {
Cheers
Filippo
On Feb 9, 2:21 am, Daniel Nichter <dan...@percona.com> wrote:
> > Executed from the shell, the command runs fine and the process
> > daemonizes as expected.
> > Executed from crontab, the command runs one iteration and then exits.
> > Some of the output:
> > # pt_kill:3810 16106 Reading files -
> > ..
> > # pt_kill:3810 16106 Checking processlist
> > # pt_kill:3810 16106 Processlist returned no queries
> > # pt_kill:3810 16106 Checking processlist
> > # pt_kill:3810 16106 /usr/local/bin/pt-kill ending
> > # Daemon:1631 16106 Removed PID file
> > As STDIN is not available to it the process tries to read STDIN,
> > fails, then exits.
> > The same behavior exhibits for both daemonize and without.
> > --
> > You received this message because you are subscribed to the Google Groups "Percona Discussion" group.
> > To post to this group, send email to percona-discussion@googlegroups.com.
> > To unsubscribe from this group, send email to percona-discussion+unsubscribe@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/percona-discussion?hl=en.
You are correct. This was fixed in https://code.launchpad.net/~percona-toolkit-dev/percona-toolkit/fix-s... but that branch was not merged, therefore it was not actually in 2.0.3. Sorry for the confusion. I'll merge this branch and it will be released for real in 2.0.4. Until then, I'll reply with a download link for the updated pt-kill once it's merged...
> I am running the latest version of pt-kill (2.0.3) on Solaris 10 and I > have the same issue.
> I believe the problem is related to this check: > pt-kill:3546 > if ( !-t STDIN ) { > PTDEBUG && _d("STDIN is piped"); > @ARGV = ('-'); > }
> No matter if I specified "--daemonize", STDIN is not /dev/tty then the > code: > pt-kill:3590 > if ( @ARGV ) { > PTDEBUG && _d('Getting processlist from files:', @ARGV);
> is executed instead of the expected: > pt-kill:3626 > else { > PTDEBUG && _d('Getting processlist from MySQL');
> I am not a PERL developer but I believe something like this should fix > this issue: > - if ( !-t STDIN ) { > + if ( !$o->get('daemonize') && !-t STDIN ) {
>>> Executed from the shell, the command runs fine and the process >>> daemonizes as expected.
>>> Executed from crontab, the command runs one iteration and then exits. >>> Some of the output: >>> # pt_kill:3810 16106 Reading files - >>> .. >>> # pt_kill:3810 16106 Checking processlist >>> # pt_kill:3810 16106 Processlist returned no queries >>> # pt_kill:3810 16106 Checking processlist >>> # pt_kill:3810 16106 /usr/local/bin/pt-kill ending >>> # Daemon:1631 16106 Removed PID file
>>> As STDIN is not available to it the process tries to read STDIN, >>> fails, then exits.
>>> The same behavior exhibits for both daemonize and without.
>>> -- >>> You received this message because you are subscribed to the Google Groups "Percona Discussion" group. >>> To post to this group, send email to percona-discussion@googlegroups.com. >>> To unsubscribe from this group, send email to percona-discussion+unsubscribe@googlegroups.com. >>> For more options, visit this group athttp://groups.google.com/group/percona-discussion?hl=en.
> -- > You received this message because you are subscribed to the Google Groups "Percona Discussion" group. > To post to this group, send email to percona-discussion@googlegroups.com. > To unsubscribe from this group, send email to percona-discussion+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/percona-discussion?hl=en.
There's a download link on that page. Note that generally we don't suggest downloading directly from trunk because the code is frequently changing, but in this particular case, I don't foresee any serious changes to pt-kill. When this is released in 2.0.4, early next month probably, you should get the official release, too.
-Daniel
Le 10 févr. 2012 à 08:50, Daniel Nichter a écrit :
> You are correct. This was fixed in https://code.launchpad.net/~percona-toolkit-dev/percona-toolkit/fix-s... but that branch was not merged, therefore it was not actually in 2.0.3. Sorry for the confusion. I'll merge this branch and it will be released for real in 2.0.4. Until then, I'll reply with a download link for the updated pt-kill once it's merged...
> -Daniel
> Le 9 févr. 2012 à 21:25, Filippo a écrit :
>> Hi Daniel,
>> I am running the latest version of pt-kill (2.0.3) on Solaris 10 and I >> have the same issue.
>> I believe the problem is related to this check: >> pt-kill:3546 >> if ( !-t STDIN ) { >> PTDEBUG && _d("STDIN is piped"); >> @ARGV = ('-'); >> }
>> No matter if I specified "--daemonize", STDIN is not /dev/tty then the >> code: >> pt-kill:3590 >> if ( @ARGV ) { >> PTDEBUG && _d('Getting processlist from files:', @ARGV);
>> is executed instead of the expected: >> pt-kill:3626 >> else { >> PTDEBUG && _d('Getting processlist from MySQL');
>> I am not a PERL developer but I believe something like this should fix >> this issue: >> - if ( !-t STDIN ) { >> + if ( !$o->get('daemonize') && !-t STDIN ) {
>>>> Executed from the shell, the command runs fine and the process >>>> daemonizes as expected.
>>>> Executed from crontab, the command runs one iteration and then exits. >>>> Some of the output: >>>> # pt_kill:3810 16106 Reading files - >>>> .. >>>> # pt_kill:3810 16106 Checking processlist >>>> # pt_kill:3810 16106 Processlist returned no queries >>>> # pt_kill:3810 16106 Checking processlist >>>> # pt_kill:3810 16106 /usr/local/bin/pt-kill ending >>>> # Daemon:1631 16106 Removed PID file
>>>> As STDIN is not available to it the process tries to read STDIN, >>>> fails, then exits.
>>>> The same behavior exhibits for both daemonize and without.
>>>> -- >>>> You received this message because you are subscribed to the Google Groups "Percona Discussion" group. >>>> To post to this group, send email to percona-discussion@googlegroups.com. >>>> To unsubscribe from this group, send email to percona-discussion+unsubscribe@googlegroups.com. >>>> For more options, visit this group athttp://groups.google.com/group/percona-discussion?hl=en.
>> -- >> You received this message because you are subscribed to the Google Groups "Percona Discussion" group. >> To post to this group, send email to percona-discussion@googlegroups.com. >> To unsubscribe from this group, send email to percona-discussion+unsubscribe@googlegroups.com. >> For more options, visit this group at http://groups.google.com/group/percona-discussion?hl=en.
> -- > You received this message because you are subscribed to the Google Groups "Percona Discussion" group. > To post to this group, send email to percona-discussion@googlegroups.com. > To unsubscribe from this group, send email to percona-discussion+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/percona-discussion?hl=en.