diff options
author | M. Sean Finney <seanius@users.sourceforge.net> | 2005-05-25 00:43:20 (GMT) |
---|---|---|
committer | M. Sean Finney <seanius@users.sourceforge.net> | 2005-05-25 00:43:20 (GMT) |
commit | 4e19425ce697ce17257b0db904a656e3c8557911 (patch) | |
tree | 493a0d1ee9441a1c57a46cde4dab504b295f20e4 | |
parent | 8134ec30d1fdf9b9921885154c900d2a88707676 (diff) | |
download | monitoring-plugins-4e19425ce697ce17257b0db904a656e3c8557911.tar.gz |
fixes for check_procs:
- added support for printing the pid in all the ps outputs
- don't use the proc name to ignore self, use the pid vs getpid().
- initialize procetime to null string otherwise -vvv can have funny results
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1177 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r-- | configure.in | 221 | ||||
-rw-r--r-- | plugins/check_nagios.c | 1 | ||||
-rw-r--r-- | plugins/check_procs.c | 19 |
3 files changed, 128 insertions, 113 deletions
diff --git a/configure.in b/configure.in index 256fb29..df516c5 100644 --- a/configure.in +++ b/configure.in | |||
@@ -593,58 +593,69 @@ dnl #### Process table test | |||
593 | AC_PATH_PROG(PATH_TO_PS,ps) | 593 | AC_PATH_PROG(PATH_TO_PS,ps) |
594 | 594 | ||
595 | AC_MSG_CHECKING(for ps syntax) | 595 | AC_MSG_CHECKING(for ps syntax) |
596 | dnl Some gnu/linux systems (debian for one) don't like -axwo and need axwo. | ||
597 | dnl so test for this first... | ||
598 | if ps axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \ | ||
599 | egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null | ||
600 | then | ||
601 | ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" | ||
602 | ac_cv_ps_command="$PATH_TO_PS axwo 'stat uid pid ppid vsz rss pcpu comm args'" | ||
603 | ac_cv_ps_format="%s %d %d %d %d %d %f %s %n" | ||
604 | ac_cv_ps_cols=9 | ||
605 | AC_MSG_RESULT([$ac_cv_ps_command]) | ||
606 | |||
596 | dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo | 607 | dnl For OpenBSD 3.2 & 3.3. Must come before ps -weo |
597 | dnl Should also work for FreeBSD 5.2.1 and 5.3 | 608 | dnl Should also work for FreeBSD 5.2.1 and 5.3 |
598 | dnl STAT UCOMM VSZ RSS USER PPID COMMAND | 609 | dnl STAT UCOMM VSZ RSS USER PPID COMMAND |
599 | if ps -axwo 'stat comm vsz rss user uid ppid args' 2>/dev/null | \ | 610 | elif ps -axwo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \ |
600 | egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PPID +COMMAND"] > /dev/null | 611 | egrep -i ["^ *STAT +[UCOMAND]+ +VSZ +RSS +USER +UID +PID +PPID +COMMAND"] > /dev/null |
601 | then | 612 | then |
602 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" | 613 | ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" |
603 | ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid ppid vsz rss pcpu comm args'" | 614 | ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu comm args'" |
604 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" | 615 | ac_cv_ps_format="%s %d %d %d %d %d %f %s %n" |
605 | ac_cv_ps_cols=8 | 616 | ac_cv_ps_cols=9 |
606 | AC_MSG_RESULT([$ac_cv_ps_command]) | 617 | AC_MSG_RESULT([$ac_cv_ps_command]) |
607 | 618 | ||
608 | dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4. | 619 | dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4. |
609 | dnl Limitation: Only first 16 chars returned for ucomm field | 620 | dnl Limitation: Only first 16 chars returned for ucomm field |
610 | dnl Must come before ps -weo | 621 | dnl Must come before ps -weo |
611 | elif ps -axwo 'stat uid ppid vsz rss pcpu ucomm command' 2>/dev/null | \ | 622 | elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \ |
612 | egrep -i ["^ *STAT +UID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null | 623 | egrep -i ["^ *STAT +UID +PID +PPID +VSZ +RSS +%CPU +UCOMM +COMMAND"] > /dev/null |
613 | then | 624 | then |
614 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" | 625 | ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" |
615 | ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid ppid vsz rss pcpu ucomm command'" | 626 | ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid pid ppid vsz rss pcpu ucomm command'" |
616 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" | 627 | ac_cv_ps_format="%s %d %d %d %d %d %f %s %n" |
617 | ac_cv_ps_cols=8 | 628 | ac_cv_ps_cols=9 |
618 | AC_MSG_RESULT([$ac_cv_ps_command]) | 629 | AC_MSG_RESULT([$ac_cv_ps_command]) |
619 | 630 | ||
620 | dnl STAT UCOMM VSZ RSS USER UID PPID COMMAND | 631 | dnl STAT UCOMM VSZ RSS USER UID PPID COMMAND |
621 | elif ps -weo 'stat comm vsz rss user uid ppid etime args' 2>/dev/null | \ | 632 | elif ps -weo 'stat comm vsz rss user uid pid ppid etime args' 2>/dev/null | \ |
622 | egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null | 633 | egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[ELAPSD]+ +[RGSCOMDNA]+"] >/dev/null |
623 | then | 634 | then |
624 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]" | 635 | ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procetime,procprog,&pos]" |
625 | ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid ppid vsz rss pcpu etime comm args'" | 636 | ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid pid ppid vsz rss pcpu etime comm args'" |
626 | ac_cv_ps_format="%s %d %d %d %d %f %s %s %n" | 637 | ac_cv_ps_format="%s %d %d %d %d %d %f %s %s %n" |
627 | ac_cv_ps_cols=9 | 638 | ac_cv_ps_cols=10 |
628 | AC_MSG_RESULT([$ac_cv_ps_command]) | 639 | AC_MSG_RESULT([$ac_cv_ps_command]) |
629 | 640 | ||
630 | dnl FreeBSD | 641 | dnl FreeBSD |
631 | elif ps waxco 'state command vsz rss uid user ppid' 2>/dev/null | \ | 642 | elif ps waxco 'state command vsz rss uid user pid ppid' 2>/dev/null | \ |
632 | egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PPID"] >/dev/null | 643 | egrep -i ["^STAT +COMMAND +VSZ +RSS +UID +USER +PID +PPID"] >/dev/null |
633 | then | 644 | then |
634 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" | 645 | ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" |
635 | ac_cv_ps_command="$PATH_TO_PS waxco 'state uid ppid vsz rss pcpu command command'" | 646 | ac_cv_ps_command="$PATH_TO_PS waxco 'state uid pid ppid vsz rss pcpu command command'" |
636 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" | 647 | ac_cv_ps_format="%s %d %d %d %d %d %f %s %n" |
637 | ac_cv_ps_cols=8 | 648 | ac_cv_ps_cols=9 |
638 | AC_MSG_RESULT([$ac_cv_ps_command]) | 649 | AC_MSG_RESULT([$ac_cv_ps_command]) |
639 | 650 | ||
640 | dnl BSD-like mode in RH 6.1 | 651 | dnl BSD-like mode in RH 6.1 |
641 | elif ps waxno 'state comm vsz rss uid user ppid args' 2>/dev/null | \ | 652 | elif ps waxno 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \ |
642 | egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null | 653 | egrep -i ["^S +COMMAND +VSZ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null |
643 | then | 654 | then |
644 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" | 655 | ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" |
645 | ac_cv_ps_command="$PATH_TO_PS waxno 'state uid ppid vsz rss pcpu comm args'" | 656 | ac_cv_ps_command="$PATH_TO_PS waxno 'state uid pid ppid vsz rss pcpu comm args'" |
646 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" | 657 | ac_cv_ps_format="%s %d %d %d %d %d %f %s %n" |
647 | ac_cv_ps_cols=8 | 658 | ac_cv_ps_cols=9 |
648 | AC_MSG_RESULT([$ac_cv_ps_command]) | 659 | AC_MSG_RESULT([$ac_cv_ps_command]) |
649 | 660 | ||
650 | dnl SunOS 4.1.3: | 661 | dnl SunOS 4.1.3: |
@@ -653,10 +664,10 @@ dnl Need the head -1 otherwise test will work because arguments are found | |||
653 | elif ps -laxnwww 2>/dev/null | head -1 | \ | 664 | elif ps -laxnwww 2>/dev/null | head -1 | \ |
654 | egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null | 665 | egrep -i ["^ *F(LAGS)? +UID +PID +PPID +CP +PRI +NI +(SZ)|(VSZ)|(SIZE) +RSS +WCHAN +STAT? +TTY? +TIME +COMMAND"] >/dev/null |
655 | then | 666 | then |
656 | ac_cv_ps_varlist="[&procuid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]" | 667 | ac_cv_ps_varlist="[&procuid,&procpid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]" |
657 | ac_cv_ps_command="$PATH_TO_PS -laxnwww" | 668 | ac_cv_ps_command="$PATH_TO_PS -laxnwww" |
658 | ac_cv_ps_format="%*s %d %*s %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s" | 669 | ac_cv_ps_format="%*s %d %d %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s" |
659 | ac_cv_ps_cols=8 | 670 | ac_cv_ps_cols=9 |
660 | AC_MSG_RESULT([$ac_cv_ps_command]) | 671 | AC_MSG_RESULT([$ac_cv_ps_command]) |
661 | 672 | ||
662 | dnl Debian Linux / procps v1.2.9: | 673 | dnl Debian Linux / procps v1.2.9: |
@@ -666,109 +677,110 @@ dnl | |||
666 | elif ps laxnwww 2>/dev/null | \ | 677 | elif ps laxnwww 2>/dev/null | \ |
667 | egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null | 678 | egrep -i ["^ *F(LAGS)? +UID +PID +PPID +PRI +NI +(VSZ)|(SIZE) +RSS +WCHAN +STAT? TTY +TIME +COMMAND"] >/dev/null |
668 | then | 679 | then |
669 | ac_cv_ps_varlist="[&procuid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]" | 680 | ac_cv_ps_varlist="[&procuid,&procpid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]" |
670 | ac_cv_ps_command="$PATH_TO_PS laxnwww" | 681 | ac_cv_ps_command="$PATH_TO_PS laxnwww" |
671 | ac_cv_ps_format="%*s %d %*s %d %*s %*s %d %d %*s %s %*s %*s %n%s" | 682 | ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s" |
672 | ac_cv_ps_cols=8 | 683 | ac_cv_ps_cols=9 |
673 | AC_MSG_RESULT([$ac_cv_ps_command]) | 684 | AC_MSG_RESULT([$ac_cv_ps_command]) |
674 | 685 | ||
675 | dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs) | 686 | dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs) |
676 | elif ps -axo 'stat comm vsz rss user uid ppid args' 2>/dev/null | \ | 687 | elif ps -axo 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \ |
677 | egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null | 688 | egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null |
678 | then | 689 | then |
679 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" | 690 | ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" |
680 | ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid ppid vsz rss pcpu comm args'" | 691 | ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid pid ppid vsz rss pcpu comm args'" |
681 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" | 692 | ac_cv_ps_format="%s %d %d %d %d %d %f %s %n" |
682 | ac_cv_ps_cols=8 | 693 | ac_cv_ps_cols=9 |
683 | AC_MSG_RESULT([$ac_cv_ps_command]) | 694 | AC_MSG_RESULT([$ac_cv_ps_command]) |
684 | 695 | ||
685 | dnl Tru64 - needs %*[ +] in PS_FORMAT | 696 | dnl Tru64 - needs %*[ +] in PS_FORMAT |
686 | elif ps -ao 'stat comm vsz rss user uid ppid args' 2>/dev/null | \ | 697 | elif ps -ao 'stat comm vsz rss user uid pid ppid args' 2>/dev/null | \ |
687 | egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null | 698 | egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[ID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null |
688 | then | 699 | then |
689 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" | 700 | ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" |
690 | ac_cv_ps_command="$PATH_TO_PS -ao 'stat uid ppid vsz rss pcpu comm args'" | 701 | ac_cv_ps_command="$PATH_TO_PS -ao 'stat uid pid ppid vsz rss pcpu comm args'" |
691 | ac_cv_ps_format=["%s%*[ +] %d %d %d %d %f %s %n"] | 702 | ac_cv_ps_format=["%s%*[ +] %d %d %d %d %d %f %s %n"] |
692 | ac_cv_ps_cols=8 | 703 | ac_cv_ps_cols=9 |
693 | AC_MSG_RESULT([$ac_cv_ps_command]) | 704 | AC_MSG_RESULT([$ac_cv_ps_command]) |
694 | 705 | ||
695 | elif ps -eo 's comm vsz rss user uid ppid args' 2>/dev/null | \ | 706 | XXX |
696 | egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null | 707 | elif ps -eo 's comm vsz rss user uid pid ppid args' 2>/dev/null | \ |
708 | egrep -i ["^S[TAUES]* +C[OMDNA]+ +[VSIZE]+ +U[SER]+ +U[ID]+ +P[PID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null | ||
697 | then | 709 | then |
698 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" | 710 | ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&procvsz,&procrss,&procpcpu,procprog,&pos]" |
699 | ac_cv_ps_command="$PATH_TO_PS -eo 's uid ppid vsz rss pcpu comm args'" | 711 | ac_cv_ps_command="$PATH_TO_PS -eo 's uid pid ppid vsz rss pcpu comm args'" |
700 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" | 712 | ac_cv_ps_format="%s %d %d %d %d %d %f %s %n" |
701 | ac_cv_ps_cols=8 | 713 | ac_cv_ps_cols=9 |
702 | AC_MSG_RESULT([$ac_cv_ps_command]) | 714 | AC_MSG_RESULT([$ac_cv_ps_command]) |
703 | 715 | ||
704 | dnl AIX 4.3.3 and 5.1 do not have an rss field | 716 | dnl AIX 4.3.3 and 5.1 do not have an rss field |
705 | elif ps -eo 'stat uid ppid vsz pcpu comm args' 2>/dev/null | \ | 717 | elif ps -eo 'stat uid pid ppid vsz pcpu comm args' 2>/dev/null | \ |
706 | egrep -i ["^ *S[TAUES]* +UID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null | 718 | egrep -i ["^ *S[TAUES]* +UID +PID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null |
707 | then | 719 | then |
708 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procpcpu,procprog,&pos]" | 720 | ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&procvsz,&procpcpu,procprog,&pos]" |
709 | ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid ppid vsz pcpu comm args'" | 721 | ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid pid ppid vsz pcpu comm args'" |
710 | ac_cv_ps_format="%s %d %d %d %f %s %n" | 722 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" |
711 | ac_cv_ps_cols=7 | 723 | ac_cv_ps_cols=8 |
712 | AC_MSG_RESULT([$ac_cv_ps_command - with no RSS]) | 724 | AC_MSG_RESULT([$ac_cv_ps_command - with no RSS]) |
713 | 725 | ||
714 | dnl Solaris 2.6 | 726 | dnl Solaris 2.6 |
715 | elif ps -Ao 's comm vsz rss uid user ppid args' 2>/dev/null | \ | 727 | elif ps -Ao 's comm vsz rss uid user pid ppid args' 2>/dev/null | \ |
716 | egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null | 728 | egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null |
717 | then | 729 | then |
718 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" | 730 | ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&procvsz,&procrss,&procpcpu,procprog,&pos]" |
719 | ac_cv_ps_command="$PATH_TO_PS -Ao 's uid ppid vsz rss pcpu comm args'" | 731 | ac_cv_ps_command="$PATH_TO_PS -Ao 's uid pid ppid vsz rss pcpu comm args'" |
720 | # There must be no space between the %s and %n due to a wierd problem in sscanf where | 732 | # There must be no space between the %s and %n due to a wierd problem in sscanf where |
721 | # it will return %n as longer than the line length | 733 | # it will return %n as longer than the line length |
722 | ac_cv_ps_format="%s %d %d %d %d %f %s%n" | 734 | ac_cv_ps_format="%s %d %d %d %d %d %f %s%n" |
723 | ac_cv_ps_cols=8 | 735 | ac_cv_ps_cols=9 |
724 | AC_MSG_RESULT([$ac_cv_ps_command]) | 736 | AC_MSG_RESULT([$ac_cv_ps_command]) |
725 | 737 | ||
726 | elif ps -Ao 'status comm vsz rss uid user ppid args' 2>/dev/null | \ | 738 | elif ps -Ao 'status comm vsz rss uid user pid ppid args' 2>/dev/null | \ |
727 | egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null | 739 | egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null |
728 | then | 740 | then |
729 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" | 741 | ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&procvsz,&procrss,&procpcpu,procprog,&pos]" |
730 | ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid ppid vsz rss pcpu comm args'" | 742 | ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid pid ppid vsz rss pcpu comm args'" |
731 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" | 743 | ac_cv_ps_format="%s %d %d %d %d %d %f %s %n" |
732 | ac_cv_ps_cols=8 | 744 | ac_cv_ps_cols=9 |
733 | AC_MSG_RESULT([$ac_cv_ps_command]) | 745 | AC_MSG_RESULT([$ac_cv_ps_command]) |
734 | 746 | ||
735 | elif ps -Ao 'state comm vsz rss uid user ppid args' 2>/dev/null | \ | 747 | elif ps -Ao 'state comm vsz rss uid user pid ppid args' 2>/dev/null | \ |
736 | egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null | 748 | egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null |
737 | then | 749 | then |
738 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" | 750 | ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&procvsz,&procrss,&procpcpu,procprog,&pos]" |
739 | ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid ppid vsz rss pcpu comm args'" | 751 | ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid pid ppid vsz rss pcpu comm args'" |
740 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" | 752 | ac_cv_ps_format="%s %d %d %d %d %d %f %s %n" |
741 | ac_cv_ps_cols=8 | 753 | ac_cv_ps_cols=9 |
742 | AC_MSG_RESULT([$ac_cv_ps_command]) | 754 | AC_MSG_RESULT([$ac_cv_ps_command]) |
743 | 755 | ||
744 | dnl wonder who takes state instead of stat | 756 | dnl wonder who takes state instead of stat |
745 | elif ps -ao 'state command vsz rss user ppid args' 2>/dev/null | \ | 757 | elif ps -ao 'state command vsz rss user pid ppid args' 2>/dev/null | \ |
746 | egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null | 758 | egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PID +PPID +[RGSCOMDNA]+"] >/dev/null |
747 | then | 759 | then |
748 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" | 760 | ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&procvsz,&procrss,&procpcpu,procprog,&pos]" |
749 | ac_cv_ps_command="$PATH_TO_PS -ao 'state uid ppid vsz rss pcpu command args'" | 761 | ac_cv_ps_command="$PATH_TO_PS -ao 'state uid pid ppid vsz rss pcpu command args'" |
750 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" | 762 | ac_cv_ps_format="%s %d %d %d %d %d %f %s %n" |
751 | ac_cv_ps_cols=7 | 763 | ac_cv_ps_cols=8 |
752 | AC_MSG_RESULT([$ac_cv_ps_command]) | 764 | AC_MSG_RESULT([$ac_cv_ps_command]) |
753 | 765 | ||
754 | dnl IRIX 53 | 766 | dnl IRIX 53 |
755 | elif ps -el 2>/dev/null | \ | 767 | elif ps -el 2>/dev/null | \ |
756 | egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null | 768 | egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null |
757 | then | 769 | then |
758 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&pos,procprog]" | 770 | ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&procvsz,&procrss,&pos,procprog]" |
759 | ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)" | 771 | ac_cv_ps_command="$PATH_TO_PS -el (IRIX 53)" |
760 | ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s" | 772 | ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s" |
761 | ac_cv_ps_cols=7 | 773 | ac_cv_ps_cols=8 |
762 | AC_MSG_RESULT([$ac_cv_ps_command]) | 774 | AC_MSG_RESULT([$ac_cv_ps_command]) |
763 | 775 | ||
764 | dnl IRIX 63 | 776 | dnl IRIX 63 |
765 | elif ps -el 2>/dev/null | \ | 777 | elif ps -el 2>/dev/null | \ |
766 | egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null | 778 | egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +P +ADDR +SZ +RSS +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null |
767 | then | 779 | then |
768 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&pos,procprog]" | 780 | ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&pos,procprog]" |
769 | ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)" | 781 | ac_cv_ps_command="$PATH_TO_PS -el (IRIX 63)" |
770 | ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s" | 782 | ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s" |
771 | ac_cv_ps_cols=5 | 783 | ac_cv_ps_cols=6 |
772 | AC_MSG_RESULT([$ac_cv_ps_command]) | 784 | AC_MSG_RESULT([$ac_cv_ps_command]) |
773 | 785 | ||
774 | dnl AIX 4.1: | 786 | dnl AIX 4.1: |
@@ -777,20 +789,20 @@ dnl 303 A 0 0 0 120 16 -- 1c07 20 24 - 0:45 | |||
777 | elif ps -el 2>/dev/null | \ | 789 | elif ps -el 2>/dev/null | \ |
778 | egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null | 790 | egrep -i ["^ *F +S +UID +PID +PPID +C +PRI +NI +ADDR +SZ +WCHAN +TTY +TIME +[RGSCOMDNA]+"] >/dev/null |
779 | then | 791 | then |
780 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&pos,procprog]" | 792 | ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&pos,procprog]" |
781 | ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)" | 793 | ac_cv_ps_command="$PATH_TO_PS -el (AIX 4.1 and HP-UX)" |
782 | ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s" | 794 | ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s" |
783 | ac_cv_ps_cols=5 | 795 | ac_cv_ps_cols=6 |
784 | AC_MSG_RESULT([$ac_cv_ps_command]) | 796 | AC_MSG_RESULT([$ac_cv_ps_command]) |
785 | 797 | ||
786 | dnl AIX? | 798 | dnl AIX? |
787 | elif ps glaxen 2>/dev/null | \ | 799 | elif ps glaxen 2>/dev/null | \ |
788 | egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null | 800 | egrep -i ["^ *F +UID +PID +PPID +PRI +NI +VSZ +RSS +WCHAN +STAT +TTY +TIME +COMMAND"] >/dev/null |
789 | then | 801 | then |
790 | ac_cv_ps_varlist="[&procuid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]" | 802 | ac_cv_ps_varlist="[&procuid,&procpid,&procpid,&procvsz,&procrss,procstat,&pos,procprog]" |
791 | ac_cv_ps_command="$PATH_TO_PS glaxen" | 803 | ac_cv_ps_command="$PATH_TO_PS glaxen" |
792 | ac_cv_ps_format="%*s %d %*s %d %*s %*s %d %d %*s %s %*s %*s %n%s" | 804 | ac_cv_ps_format="%*s %d %d %d %*s %*s %d %d %*s %s %*s %*s %n%s" |
793 | ac_cv_ps_cols=7 | 805 | ac_cv_ps_cols=8 |
794 | AC_MSG_RESULT([$ac_cv_ps_command]) | 806 | AC_MSG_RESULT([$ac_cv_ps_command]) |
795 | 807 | ||
796 | dnl MacOSX / Darwin | 808 | dnl MacOSX / Darwin |
@@ -798,24 +810,25 @@ dnl TODO: MacOSX has commands with spaces which will cause problems to PS_FORMAT | |||
798 | dnl Some truncation will happen in UCOMM column | 810 | dnl Some truncation will happen in UCOMM column |
799 | dnl STAT VSZ RSS UID PPID %CPU UCOMM COMMAND | 811 | dnl STAT VSZ RSS UID PPID %CPU UCOMM COMMAND |
800 | dnl Ss 52756 22496 501 1 6.9 Window Manager /System/Library/CoreServices/WindowServer -daemon | 812 | dnl Ss 52756 22496 501 1 6.9 Window Manager /System/Library/CoreServices/WindowServer -daemon |
801 | elif ps wwaxo 'state vsz rss uid ppid pcpu ucomm command' 2>/dev/null | \ | 813 | elif ps wwaxo 'state vsz rss uid pid ppid pcpu ucomm command' 2>/dev/null | \ |
802 | egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null | 814 | egrep -i ["^STAT +VSZ +RSS +UID +PPID +%CPU +UCOMM +COMMAND"] >/dev/null |
803 | then | 815 | then |
804 | ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid ppid pcpu ucomm command'" | 816 | ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid pid ppid pcpu ucomm command'" |
805 | ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procppid,&procpcpu,procprog,&pos]" | 817 | ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procpid,&procpid,&procpcpu,procprog,&pos]" |
806 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" | 818 | ac_cv_ps_format="%s %d %d %d %d %d %f %s %n" |
807 | ac_cv_ps_cols=7 | 819 | ac_cv_ps_cols=8 |
808 | AC_MSG_RESULT([$ac_cv_ps_command]) | 820 | AC_MSG_RESULT([$ac_cv_ps_command]) |
809 | 821 | ||
810 | dnl UnixWare | 822 | dnl UnixWare |
811 | elif ps -Al 2>/dev/null | \ | 823 | elif ps -Al 2>/dev/null | \ |
812 | egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null | 824 | egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null |
813 | then | 825 | then |
814 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&pos,procprog]" | 826 | ac_cv_ps_varlist="[procstat,&procuid,&procpid,&procpid,&pos,procprog]" |
815 | ac_cv_ps_command="$PATH_TO_PS -Al" | 827 | ac_cv_ps_command="$PATH_TO_PS -Al" |
816 | ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s" | 828 | ac_cv_ps_format="%*s %s %d %d %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s" |
817 | ac_cv_ps_cols=7 | 829 | ac_cv_ps_cols=8 |
818 | AC_MSG_RESULT([$ac_cv_ps_command]) | 830 | AC_MSG_RESULT([$ac_cv_ps_command]) |
831 | XXX | ||
819 | 832 | ||
820 | else | 833 | else |
821 | AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled]) | 834 | AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled]) |
diff --git a/plugins/check_nagios.c b/plugins/check_nagios.c index 0176983..089ff66 100644 --- a/plugins/check_nagios.c +++ b/plugins/check_nagios.c | |||
@@ -49,6 +49,7 @@ main (int argc, char **argv) | |||
49 | char *temp_ptr; | 49 | char *temp_ptr; |
50 | FILE *fp; | 50 | FILE *fp; |
51 | int procuid = 0; | 51 | int procuid = 0; |
52 | int procpid = 0; | ||
52 | int procppid = 0; | 53 | int procppid = 0; |
53 | int procvsz = 0; | 54 | int procvsz = 0; |
54 | int procrss = 0; | 55 | int procrss = 0; |
diff --git a/plugins/check_procs.c b/plugins/check_procs.c index 15ec76f..671190c 100644 --- a/plugins/check_procs.c +++ b/plugins/check_procs.c | |||
@@ -85,7 +85,9 @@ main (int argc, char **argv) | |||
85 | char *input_line; | 85 | char *input_line; |
86 | char *procprog; | 86 | char *procprog; |
87 | 87 | ||
88 | pid_t mypid = 0; | ||
88 | int procuid = 0; | 89 | int procuid = 0; |
90 | int procpid = 0; | ||
89 | int procppid = 0; | 91 | int procppid = 0; |
90 | int procvsz = 0; | 92 | int procvsz = 0; |
91 | int procrss = 0; | 93 | int procrss = 0; |
@@ -106,11 +108,12 @@ main (int argc, char **argv) | |||
106 | int expected_cols = PS_COLS - 1; | 108 | int expected_cols = PS_COLS - 1; |
107 | int warn = 0; /* number of processes in warn state */ | 109 | int warn = 0; /* number of processes in warn state */ |
108 | int crit = 0; /* number of processes in crit state */ | 110 | int crit = 0; /* number of processes in crit state */ |
111 | procetime[0]='\0'; /* keep this clean because -vvv always prints it */ | ||
109 | int i = 0; | 112 | int i = 0; |
110 | 113 | ||
111 | int result = STATE_UNKNOWN; | 114 | int result = STATE_UNKNOWN; |
112 | 115 | ||
113 | setlocale (LC_ALL, ""); | 116 | //setlocale (LC_ALL, ""); |
114 | bindtextdomain (PACKAGE, LOCALEDIR); | 117 | bindtextdomain (PACKAGE, LOCALEDIR); |
115 | textdomain (PACKAGE); | 118 | textdomain (PACKAGE); |
116 | 119 | ||
@@ -123,6 +126,9 @@ main (int argc, char **argv) | |||
123 | if (process_arguments (argc, argv) == ERROR) | 126 | if (process_arguments (argc, argv) == ERROR) |
124 | usage4 (_("Could not parse arguments")); | 127 | usage4 (_("Could not parse arguments")); |
125 | 128 | ||
129 | /* get our pid */ | ||
130 | mypid = getpid(); | ||
131 | |||
126 | /* Set signal handling and alarm timeout */ | 132 | /* Set signal handling and alarm timeout */ |
127 | if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) { | 133 | if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) { |
128 | usage4 (_("Cannot catch SIGALRM")); | 134 | usage4 (_("Cannot catch SIGALRM")); |
@@ -182,15 +188,13 @@ main (int argc, char **argv) | |||
182 | procseconds = convert_to_seconds(procetime); | 188 | procseconds = convert_to_seconds(procetime); |
183 | 189 | ||
184 | if (verbose >= 3) | 190 | if (verbose >= 3) |
185 | printf ("%d %d %d %d %d %.2f %s %s %s %s\n", | 191 | printf ("%d %d %d %d %d %d %.2f %s %s %s %s\n", |
186 | procs, procuid, procvsz, procrss, | 192 | procs, procuid, procvsz, procrss, |
187 | procppid, procpcpu, procstat, | 193 | procpid, procppid, procpcpu, procstat, |
188 | procetime, procprog, procargs); | 194 | procetime, procprog, procargs); |
189 | 195 | ||
190 | /* Ignore self */ | 196 | /* Ignore self */ |
191 | if (strcmp (procprog, progname) == 0) { | 197 | if (mypid == procpid) continue; |
192 | continue; | ||
193 | } | ||
194 | 198 | ||
195 | if ((options & STAT) && (strstr (statopts, procstat))) | 199 | if ((options & STAT) && (strstr (statopts, procstat))) |
196 | resultsum |= STAT; | 200 | resultsum |= STAT; |
@@ -639,9 +643,6 @@ convert_to_seconds(char *etime) { | |||
639 | (minutes * 60) + | 643 | (minutes * 60) + |
640 | seconds; | 644 | seconds; |
641 | 645 | ||
642 | if (verbose >= 3) { | ||
643 | printf("seconds: %d\n", total); | ||
644 | } | ||
645 | return total; | 646 | return total; |
646 | } | 647 | } |
647 | 648 | ||