diff options
-rw-r--r-- | configure.in | 70 | ||||
-rw-r--r-- | plugins/Makefile.am | 4 | ||||
-rw-r--r-- | plugins/check_procs.c | 65 |
3 files changed, 77 insertions, 62 deletions
diff --git a/configure.in b/configure.in index 37baafa8..09e8e350 100644 --- a/configure.in +++ b/configure.in | |||
@@ -634,7 +634,7 @@ then | |||
634 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" | 634 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" |
635 | ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid ppid vsz rss pcpu comm args'" | 635 | ac_cv_ps_command="$PATH_TO_PS -axwo 'stat uid ppid vsz rss pcpu comm args'" |
636 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" | 636 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" |
637 | EXTRAS="$EXTRAS check_nagios" | 637 | ac_cv_ps_cols=8 |
638 | AC_MSG_RESULT([$ac_cv_ps_command]) | 638 | AC_MSG_RESULT([$ac_cv_ps_command]) |
639 | 639 | ||
640 | dnl STAT UCOMM VSZ RSS USER UID PPID COMMAND | 640 | dnl STAT UCOMM VSZ RSS USER UID PPID COMMAND |
@@ -644,7 +644,7 @@ then | |||
644 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" | 644 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" |
645 | ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid ppid vsz rss pcpu comm args'" | 645 | ac_cv_ps_command="$PATH_TO_PS -weo 'stat uid ppid vsz rss pcpu comm args'" |
646 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" | 646 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" |
647 | EXTRAS="$EXTRAS check_nagios" | 647 | ac_cv_ps_cols=8 |
648 | AC_MSG_RESULT([$ac_cv_ps_command]) | 648 | AC_MSG_RESULT([$ac_cv_ps_command]) |
649 | 649 | ||
650 | dnl FreeBSD | 650 | dnl FreeBSD |
@@ -654,7 +654,7 @@ then | |||
654 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" | 654 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" |
655 | ac_cv_ps_command="$PATH_TO_PS waxco 'state uid ppid vsz rss pcpu command command'" | 655 | ac_cv_ps_command="$PATH_TO_PS waxco 'state uid ppid vsz rss pcpu command command'" |
656 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" | 656 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" |
657 | EXTRAS="$EXTRAS check_nagios" | 657 | ac_cv_ps_cols=8 |
658 | AC_MSG_RESULT([$ac_cv_ps_command]) | 658 | AC_MSG_RESULT([$ac_cv_ps_command]) |
659 | 659 | ||
660 | dnl BSD-like mode in RH 6.1 | 660 | dnl BSD-like mode in RH 6.1 |
@@ -664,7 +664,7 @@ then | |||
664 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" | 664 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" |
665 | ac_cv_ps_command="$PATH_TO_PS waxno 'state uid ppid vsz rss pcpu comm args'" | 665 | ac_cv_ps_command="$PATH_TO_PS waxno 'state uid ppid vsz rss pcpu comm args'" |
666 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" | 666 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" |
667 | EXTRAS="$EXTRAS check_nagios" | 667 | ac_cv_ps_cols=8 |
668 | AC_MSG_RESULT([$ac_cv_ps_command]) | 668 | AC_MSG_RESULT([$ac_cv_ps_command]) |
669 | 669 | ||
670 | dnl SunOS 4.1.3: | 670 | dnl SunOS 4.1.3: |
@@ -675,7 +675,7 @@ then | |||
675 | ac_cv_ps_varlist="[&procuid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]" | 675 | ac_cv_ps_varlist="[&procuid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]" |
676 | ac_cv_ps_command="$PATH_TO_PS -laxnwww" | 676 | ac_cv_ps_command="$PATH_TO_PS -laxnwww" |
677 | ac_cv_ps_format="%*s %d %*s %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s" | 677 | ac_cv_ps_format="%*s %d %*s %d %*s %*s %*s %d %d %*s %s %*s %*s %n%s" |
678 | EXTRAS="$EXTRAS check_nagios" | 678 | ac_cv_ps_cols=8 |
679 | AC_MSG_RESULT([$ac_cv_ps_command]) | 679 | AC_MSG_RESULT([$ac_cv_ps_command]) |
680 | 680 | ||
681 | dnl Debian Linux / procps v1.2.9: | 681 | dnl Debian Linux / procps v1.2.9: |
@@ -688,7 +688,7 @@ then | |||
688 | ac_cv_ps_varlist="[&procuid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]" | 688 | ac_cv_ps_varlist="[&procuid,&procppid,procstat,&procvsz,&procrss,&pos,procprog]" |
689 | ac_cv_ps_command="$PATH_TO_PS laxnwww" | 689 | ac_cv_ps_command="$PATH_TO_PS laxnwww" |
690 | ac_cv_ps_format="%*s %d %*s %d %*s %*s %d %d %*s %s %*s %*s %n%s" | 690 | ac_cv_ps_format="%*s %d %*s %d %*s %*s %d %d %*s %s %*s %*s %n%s" |
691 | EXTRAS="$EXTRAS check_nagios" | 691 | ac_cv_ps_cols=8 |
692 | AC_MSG_RESULT([$ac_cv_ps_command]) | 692 | AC_MSG_RESULT([$ac_cv_ps_command]) |
693 | 693 | ||
694 | dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs) | 694 | dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs) |
@@ -698,17 +698,17 @@ then | |||
698 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" | 698 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" |
699 | ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid ppid vsz rss pcpu comm args'" | 699 | ac_cv_ps_command="$PATH_TO_PS -axo 'stat uid ppid vsz rss pcpu comm args'" |
700 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" | 700 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" |
701 | EXTRAS="$EXTRAS check_nagios" | 701 | ac_cv_ps_cols=8 |
702 | AC_MSG_RESULT([$ac_cv_ps_command]) | 702 | AC_MSG_RESULT([$ac_cv_ps_command]) |
703 | 703 | ||
704 | dnl AIX 4.3.3 - needs verification. This works for Tru64 - needs %*[ +] in PS_FORMAT | 704 | dnl Tru64 - needs %*[ +] in PS_FORMAT |
705 | elif ps -ao 'stat comm vsz rss user uid ppid args' 2>/dev/null | \ | 705 | elif ps -ao 'stat comm vsz rss user uid ppid args' 2>/dev/null | \ |
706 | egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null | 706 | egrep -i ["^ *S[TAUES]* +[UCOMDNA]+ +[VSIZE]+ +R[S]+ +U[SER]+ +U[ID]+ +P[PID]+ +[RGSCOMDNA]+"] >/dev/null |
707 | then | 707 | then |
708 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" | 708 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" |
709 | ac_cv_ps_command="$PATH_TO_PS -ao 'stat uid ppid vsz rss pcpu comm args'" | 709 | ac_cv_ps_command="$PATH_TO_PS -ao 'stat uid ppid vsz rss pcpu comm args'" |
710 | ac_cv_ps_format=["%s%*[ +] %d %d %d %d %f %s %n"] | 710 | ac_cv_ps_format=["%s%*[ +] %d %d %d %d %f %s %n"] |
711 | EXTRAS="$EXTRAS check_nagios" | 711 | ac_cv_ps_cols=8 |
712 | AC_MSG_RESULT([$ac_cv_ps_command]) | 712 | AC_MSG_RESULT([$ac_cv_ps_command]) |
713 | 713 | ||
714 | elif ps -eo 's comm vsz rss user uid ppid args' 2>/dev/null | \ | 714 | elif ps -eo 's comm vsz rss user uid ppid args' 2>/dev/null | \ |
@@ -717,16 +717,26 @@ then | |||
717 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" | 717 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" |
718 | ac_cv_ps_command="$PATH_TO_PS -eo 's uid ppid vsz rss pcpu comm args'" | 718 | ac_cv_ps_command="$PATH_TO_PS -eo 's uid ppid vsz rss pcpu comm args'" |
719 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" | 719 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" |
720 | EXTRAS="$EXTRAS check_nagios" | 720 | ac_cv_ps_cols=8 |
721 | AC_MSG_RESULT([$ac_cv_ps_command]) | 721 | AC_MSG_RESULT([$ac_cv_ps_command]) |
722 | 722 | ||
723 | dnl AIX 4.3.3 and 5.1 do not have an rss field | ||
724 | elif ps -eo 'stat uid ppid vsz pcpu comm args' 2>/dev/null | \ | ||
725 | egrep -i ["^ *S[TAUES]* +UID +PPID +VSZ +%CPU +COMMAND +COMMAND"] >/dev/null | ||
726 | then | ||
727 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procpcpu,procprog,&pos]" | ||
728 | ac_cv_ps_command="$PATH_TO_PS -eo 'stat uid ppid vsz pcpu comm args'" | ||
729 | ac_cv_ps_format="%s %d %d %d %f %s %n" | ||
730 | ac_cv_ps_cols=7 | ||
731 | AC_MSG_RESULT([$ac_cv_ps_command - with no RSS]) | ||
732 | |||
723 | elif ps -Ao 's comm vsz rss uid user ppid args' 2>/dev/null | \ | 733 | elif ps -Ao 's comm vsz rss uid user ppid args' 2>/dev/null | \ |
724 | egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null | 734 | egrep -i ["^S[TAUES]* +C[OMDNA]+ +V[SIZE]+ +RSS +UID +USER +PPID +[RGSCOMDNA]+"] >/dev/null |
725 | then | 735 | then |
726 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" | 736 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" |
727 | ac_cv_ps_command="$PATH_TO_PS -Ao 's uid ppid vsz rss pcpu comm args'" | 737 | ac_cv_ps_command="$PATH_TO_PS -Ao 's uid ppid vsz rss pcpu comm args'" |
728 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" | 738 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" |
729 | EXTRAS="$EXTRAS check_nagios" | 739 | ac_cv_ps_cols=8 |
730 | AC_MSG_RESULT([$ac_cv_ps_command]) | 740 | AC_MSG_RESULT([$ac_cv_ps_command]) |
731 | 741 | ||
732 | elif ps -Ao 'status comm vsz rss uid user ppid args' 2>/dev/null | \ | 742 | elif ps -Ao 'status comm vsz rss uid user ppid args' 2>/dev/null | \ |
@@ -735,7 +745,7 @@ then | |||
735 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" | 745 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" |
736 | ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid ppid vsz rss pcpu comm args'" | 746 | ac_cv_ps_command="$PATH_TO_PS -Ao 'status uid ppid vsz rss pcpu comm args'" |
737 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" | 747 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" |
738 | EXTRAS="$EXTRAS check_nagios" | 748 | ac_cv_ps_cols=8 |
739 | AC_MSG_RESULT([$ac_cv_ps_command]) | 749 | AC_MSG_RESULT([$ac_cv_ps_command]) |
740 | 750 | ||
741 | elif ps -Ao 'state comm vsz rss uid user ppid args' 2>/dev/null | \ | 751 | elif ps -Ao 'state comm vsz rss uid user ppid args' 2>/dev/null | \ |
@@ -744,7 +754,7 @@ then | |||
744 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" | 754 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" |
745 | ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid ppid vsz rss pcpu comm args'" | 755 | ac_cv_ps_command="$PATH_TO_PS -Ao 'state uid ppid vsz rss pcpu comm args'" |
746 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" | 756 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" |
747 | EXTRAS="$EXTRAS check_nagios" | 757 | ac_cv_ps_cols=8 |
748 | AC_MSG_RESULT([$ac_cv_ps_command]) | 758 | AC_MSG_RESULT([$ac_cv_ps_command]) |
749 | 759 | ||
750 | dnl wonder who takes state instead of stat | 760 | dnl wonder who takes state instead of stat |
@@ -754,7 +764,7 @@ then | |||
754 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" | 764 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&procpcpu,procprog,&pos]" |
755 | ac_cv_ps_command="$PATH_TO_PS -ao 'state uid ppid vsz rss pcpu command args'" | 765 | ac_cv_ps_command="$PATH_TO_PS -ao 'state uid ppid vsz rss pcpu command args'" |
756 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" | 766 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" |
757 | EXTRAS="$EXTRAS check_nagios" | 767 | ac_cv_ps_cols=7 |
758 | AC_MSG_RESULT([$ac_cv_ps_command]) | 768 | AC_MSG_RESULT([$ac_cv_ps_command]) |
759 | 769 | ||
760 | dnl IRIX 53 | 770 | dnl IRIX 53 |
@@ -764,6 +774,7 @@ then | |||
764 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&pos,procprog]" | 774 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&procvsz,&procrss,&pos,procprog]" |
765 | ac_cv_ps_command="$PATH_TO_PS -el" | 775 | ac_cv_ps_command="$PATH_TO_PS -el" |
766 | ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s" | 776 | ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %d %d %*s %*s %*s %n%s" |
777 | ac_cv_ps_cols=7 | ||
767 | AC_MSG_RESULT([$ac_cv_ps_command]) | 778 | AC_MSG_RESULT([$ac_cv_ps_command]) |
768 | 779 | ||
769 | dnl IRIX 63 | 780 | dnl IRIX 63 |
@@ -773,6 +784,7 @@ then | |||
773 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&pos,procprog]" | 784 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&pos,procprog]" |
774 | ac_cv_ps_command="$PATH_TO_PS -el" | 785 | ac_cv_ps_command="$PATH_TO_PS -el" |
775 | ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s" | 786 | ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s" |
787 | ac_cv_ps_cols=5 | ||
776 | AC_MSG_RESULT([$ac_cv_ps_command]) | 788 | AC_MSG_RESULT([$ac_cv_ps_command]) |
777 | 789 | ||
778 | dnl AIX 4.1: | 790 | dnl AIX 4.1: |
@@ -784,6 +796,7 @@ then | |||
784 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&pos,procprog]" | 796 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&pos,procprog]" |
785 | ac_cv_ps_command="$PATH_TO_PS -el" | 797 | ac_cv_ps_command="$PATH_TO_PS -el" |
786 | ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s" | 798 | ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %*s %*s %*s %*s %n%s" |
799 | ac_cv_ps_cols=7 | ||
787 | AC_MSG_RESULT([$ac_cv_ps_command]) | 800 | AC_MSG_RESULT([$ac_cv_ps_command]) |
788 | 801 | ||
789 | dnl AIX? | 802 | dnl AIX? |
@@ -793,6 +806,7 @@ then | |||
793 | ac_cv_ps_varlist="[&procuid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]" | 806 | ac_cv_ps_varlist="[&procuid,&procppid,&procvsz,&procrss,procstat,&pos,procprog]" |
794 | ac_cv_ps_command="$PATH_TO_PS glaxen" | 807 | ac_cv_ps_command="$PATH_TO_PS glaxen" |
795 | ac_cv_ps_format="%*s %d %*s %d %*s %*s %d %d %*s %s %*s %*s %n%s" | 808 | ac_cv_ps_format="%*s %d %*s %d %*s %*s %d %d %*s %s %*s %*s %n%s" |
809 | ac_cv_ps_cols=7 | ||
796 | AC_MSG_RESULT([$ac_cv_ps_command]) | 810 | AC_MSG_RESULT([$ac_cv_ps_command]) |
797 | 811 | ||
798 | dnl MacOSX / Darwin | 812 | dnl MacOSX / Darwin |
@@ -806,7 +820,7 @@ then | |||
806 | ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid ppid pcpu ucomm command'" | 820 | ac_cv_ps_command="$PATH_TO_PS wwaxo 'state vsz rss uid ppid pcpu ucomm command'" |
807 | ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procppid,&procpcpu,procprog,&pos]" | 821 | ac_cv_ps_varlist="[procstat,&procvsz,&procrss,&procuid,&procppid,&procpcpu,procprog,&pos]" |
808 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" | 822 | ac_cv_ps_format="%s %d %d %d %d %f %s %n" |
809 | EXTRAS="$EXTRAS check_nagios" | 823 | ac_cv_ps_cols=7 |
810 | AC_MSG_RESULT([$ac_cv_ps_command]) | 824 | AC_MSG_RESULT([$ac_cv_ps_command]) |
811 | 825 | ||
812 | dnl UnixWare | 826 | dnl UnixWare |
@@ -816,24 +830,24 @@ then | |||
816 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&pos,procprog]" | 830 | ac_cv_ps_varlist="[procstat,&procuid,&procppid,&pos,procprog]" |
817 | ac_cv_ps_command="$PATH_TO_PS -Al" | 831 | ac_cv_ps_command="$PATH_TO_PS -Al" |
818 | ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s" | 832 | ac_cv_ps_format="%*s %s %d %*s %d %*s %*s %*s %*s %*s %*s %*s %*s %*s %n%s" |
819 | #if ps -Ao 'vsz comm' 2>/dev/null | \ | 833 | ac_cv_ps_cols=7 |
820 | # egrep -i ["^ *VSZ +COMMAND"] >/dev/null | ||
821 | #then | ||
822 | # ac_cv_vsz_command="$PATH_TO_PS -Ao 'vsz comm'" | ||
823 | # ac_cv_vsz_format="%*s %d" | ||
824 | #fi | ||
825 | AC_MSG_RESULT([$ac_cv_ps_command]) | 834 | AC_MSG_RESULT([$ac_cv_ps_command]) |
826 | 835 | ||
827 | else | 836 | else |
828 | AC_MSG_WARN([unable to find usable ps syntax]) | 837 | AC_MSG_WARN([unable to find usable ps syntax - check_procs and check_nagios will not be compiled]) |
829 | fi | 838 | fi |
830 | 839 | ||
831 | AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist, | 840 | if test -n $ac_cv_ps_varlist ; then |
832 | [Variable list for sscanf of 'ps' output]) | 841 | AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist, |
833 | AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command", | 842 | [Variable list for sscanf of 'ps' output]) |
834 | [Verbatim command to execute for ps in check_procs]) | 843 | AC_DEFINE_UNQUOTED(PS_COMMAND,"$ac_cv_ps_command", |
835 | AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format", | 844 | [Verbatim command to execute for ps in check_procs]) |
836 | [Format string for scanning ps output in check_procs]) | 845 | AC_DEFINE_UNQUOTED(PS_FORMAT,"$ac_cv_ps_format", |
846 | [Format string for scanning ps output in check_procs]) | ||
847 | AC_DEFINE_UNQUOTED(PS_COLS,$ac_cv_ps_cols, | ||
848 | [Number of columns in ps command]) | ||
849 | EXTRAS="$EXTRAS check_procs check_nagios" | ||
850 | fi | ||
837 | 851 | ||
838 | dnl jm_AFS | 852 | dnl jm_AFS |
839 | jm_LIST_MOUNTED_FILESYSTEMS([list_mounted_fs=yes], [list_mounted_fs=no]) | 853 | jm_LIST_MOUNTED_FILESYSTEMS([list_mounted_fs=yes], [list_mounted_fs=no]) |
diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 683cd51b..ac421e5f 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am | |||
@@ -12,7 +12,7 @@ LIBS = @LIBINTL@ @LIBS@ | |||
12 | 12 | ||
13 | libexec_PROGRAMS = check_disk check_dummy check_http check_load \ | 13 | libexec_PROGRAMS = check_disk check_dummy check_http check_load \ |
14 | check_mrtg check_mrtgtraf check_nwstat check_overcr check_ping \ | 14 | check_mrtg check_mrtgtraf check_nwstat check_overcr check_ping \ |
15 | check_procs check_real check_smtp check_ssh check_tcp check_time \ | 15 | check_real check_smtp check_ssh check_tcp check_time \ |
16 | check_udp check_ups check_users negate urlize \ | 16 | check_udp check_ups check_users negate urlize \ |
17 | @EXTRAS@ | 17 | @EXTRAS@ |
18 | 18 | ||
@@ -21,7 +21,7 @@ check_tcp_programs = check_ftp check_imap check_nntp check_pop check_udp2 \ | |||
21 | 21 | ||
22 | EXTRA_PROGRAMS = check_mysql check_radius check_pgsql check_snmp check_hpjd \ | 22 | EXTRA_PROGRAMS = check_mysql check_radius check_pgsql check_snmp check_hpjd \ |
23 | check_swap check_fping check_ldap check_game check_dig \ | 23 | check_swap check_fping check_ldap check_game check_dig \ |
24 | check_nagios check_by_ssh check_dns check_nt check_ide-smart | 24 | check_nagios check_by_ssh check_dns check_nt check_ide-smart check_procs |
25 | 25 | ||
26 | EXTRA_DIST = t utils.c netutils.c popen.c utils.h netutils.h popen.h common.h \ | 26 | EXTRA_DIST = t utils.c netutils.c popen.c utils.h netutils.h popen.h common.h \ |
27 | getaddrinfo.c getaddrinfo.h gethostbyname.c gethostbyname.h | 27 | getaddrinfo.c getaddrinfo.h gethostbyname.c gethostbyname.h |
diff --git a/plugins/check_procs.c b/plugins/check_procs.c index e0ee524c..a868fcf9 100644 --- a/plugins/check_procs.c +++ b/plugins/check_procs.c | |||
@@ -89,6 +89,7 @@ main (int argc, char **argv) | |||
89 | char procstat[8]; | 89 | char procstat[8]; |
90 | char procprog[MAX_INPUT_BUFFER]; | 90 | char procprog[MAX_INPUT_BUFFER]; |
91 | char *procargs; | 91 | char *procargs; |
92 | char *temp_string; | ||
92 | 93 | ||
93 | const char *zombie = "Z"; | 94 | const char *zombie = "Z"; |
94 | 95 | ||
@@ -97,6 +98,7 @@ main (int argc, char **argv) | |||
97 | int procs = 0; /* counter for number of processes meeting filter criteria */ | 98 | int procs = 0; /* counter for number of processes meeting filter criteria */ |
98 | int pos; /* number of spaces before 'args' in `ps` output */ | 99 | int pos; /* number of spaces before 'args' in `ps` output */ |
99 | int cols; /* number of columns in ps output */ | 100 | int cols; /* number of columns in ps output */ |
101 | int expected_cols = PS_COLS - 1; | ||
100 | int warn = 0; /* number of processes in warn state */ | 102 | int warn = 0; /* number of processes in warn state */ |
101 | int crit = 0; /* number of processes in crit state */ | 103 | int crit = 0; /* number of processes in crit state */ |
102 | int i = 0; | 104 | int i = 0; |
@@ -135,18 +137,35 @@ main (int argc, char **argv) | |||
135 | cols = sscanf (input_buffer, PS_FORMAT, PS_VARLIST); | 137 | cols = sscanf (input_buffer, PS_FORMAT, PS_VARLIST); |
136 | 138 | ||
137 | /* Zombie processes do not give a procprog command */ | 139 | /* Zombie processes do not give a procprog command */ |
138 | if ( cols == 6 && strstr(procstat, zombie) ) { | 140 | if ( cols == (expected_cols - 1) && strstr(procstat, zombie) ) { |
139 | cols = 7; | 141 | cols = expected_cols; |
140 | /* Set some value for procargs for the strip command further below | 142 | /* Set some value for procargs for the strip command further below |
141 | Seen to be a problem on some Solaris 7 and 8 systems */ | 143 | Seen to be a problem on some Solaris 7 and 8 systems */ |
142 | input_buffer[pos] = '\n'; | 144 | input_buffer[pos] = '\n'; |
143 | input_buffer[pos+1] = 0x0; | 145 | input_buffer[pos+1] = 0x0; |
144 | } | 146 | } |
145 | if ( cols >= 7 ) { | 147 | if ( cols >= expected_cols ) { |
146 | resultsum = 0; | 148 | resultsum = 0; |
147 | asprintf (&procargs, "%s", input_buffer + pos); | 149 | asprintf (&procargs, "%s", input_buffer + pos); |
148 | strip (procargs); | 150 | strip (procargs); |
149 | 151 | ||
152 | /* Some ps return full pathname for command. This removes path */ | ||
153 | temp_string = strtok ((char *)procprog, "/"); | ||
154 | while (temp_string) { | ||
155 | strcpy(procprog, temp_string); | ||
156 | temp_string = strtok (NULL, "/"); | ||
157 | } | ||
158 | |||
159 | if (verbose >= 3) | ||
160 | printf ("%d %d %d %d %d %.2f %s %s %s\n", | ||
161 | procs, procuid, procvsz, procrss, | ||
162 | procppid, procpcpu, procstat, procprog, procargs); | ||
163 | |||
164 | /* Ignore self */ | ||
165 | if (strcmp (procprog, progname) == 0) { | ||
166 | continue; | ||
167 | } | ||
168 | |||
150 | if ((options & STAT) && (strstr (statopts, procstat))) | 169 | if ((options & STAT) && (strstr (statopts, procstat))) |
151 | resultsum |= STAT; | 170 | resultsum |= STAT; |
152 | if ((options & ARGS) && procargs && (strstr (procargs, args) != NULL)) | 171 | if ((options & ARGS) && procargs && (strstr (procargs, args) != NULL)) |
@@ -164,15 +183,6 @@ main (int argc, char **argv) | |||
164 | if ((options & PCPU) && (procpcpu >= pcpu)) | 183 | if ((options & PCPU) && (procpcpu >= pcpu)) |
165 | resultsum |= PCPU; | 184 | resultsum |= PCPU; |
166 | 185 | ||
167 | if (verbose >= 3) | ||
168 | printf ("%d %d %d %d %d %.2f %s %s %s\n", | ||
169 | procs, procuid, procvsz, procrss, | ||
170 | procppid, procpcpu, procstat, procprog, procargs); | ||
171 | |||
172 | /* Ignore self */ | ||
173 | if (strcmp (procprog, progname) == 0) | ||
174 | continue; | ||
175 | |||
176 | found++; | 186 | found++; |
177 | 187 | ||
178 | /* Next line if filters not matched */ | 188 | /* Next line if filters not matched */ |
@@ -192,12 +202,11 @@ main (int argc, char **argv) | |||
192 | if (metric != METRIC_PROCS) { | 202 | if (metric != METRIC_PROCS) { |
193 | if (i == STATE_WARNING) { | 203 | if (i == STATE_WARNING) { |
194 | warn++; | 204 | warn++; |
195 | asprintf (&fails, "%s%s%s", fails, (fails == "" ? "" : ", "), procprog); | ||
196 | } | 205 | } |
197 | if (i == STATE_CRITICAL) { | 206 | if (i == STATE_CRITICAL) { |
198 | crit++; | 207 | crit++; |
199 | asprintf (&fails, "%s%s%s", fails, (fails == "" ? "" : ", "), procprog); | ||
200 | } | 208 | } |
209 | asprintf (&fails, "%s%s%s", fails, (strcmp(fails,"") ? ", " : ""), procprog); | ||
201 | result = max_state (result, i); | 210 | result = max_state (result, i); |
202 | } | 211 | } |
203 | } | 212 | } |
@@ -237,33 +246,25 @@ main (int argc, char **argv) | |||
237 | } | 246 | } |
238 | 247 | ||
239 | if ( result == STATE_OK ) { | 248 | if ( result == STATE_OK ) { |
240 | printf (_("%s OK: %d process%s"), | 249 | printf ("%s %s: ", metric_name, _("OK")); |
241 | metric_name, procs, ( procs != 1 ? "es" : "") ); | ||
242 | } else if (result == STATE_WARNING) { | 250 | } else if (result == STATE_WARNING) { |
243 | if ( metric == METRIC_PROCS ) { | 251 | printf ("%s %s: ", metric_name, _("WARNING")); |
244 | printf (_("PROCS WARNING: %d process%s"), procs, | 252 | if ( metric != METRIC_PROCS ) { |
245 | ( procs != 1 ? "es" : "")); | 253 | printf (_("%d warn out of "), warn); |
246 | } else { | ||
247 | printf (_("%s WARNING: %d warn out of %d process%s"), | ||
248 | metric_name, warn, procs, | ||
249 | ( procs != 1 ? "es" : "")); | ||
250 | } | 254 | } |
251 | } else if (result == STATE_CRITICAL) { | 255 | } else if (result == STATE_CRITICAL) { |
252 | if (metric == METRIC_PROCS) { | 256 | printf ("%s %s: ", metric_name, _("CRITICAL")); |
253 | printf (_("PROCS CRITICAL: %d process%s"), procs, | 257 | if (metric != METRIC_PROCS) { |
254 | ( procs != 1 ? "es" : "")); | 258 | printf (_("%d crit, %d warn out of "), crit, warn); |
255 | } else { | ||
256 | printf (_("%s CRITICAL: %d crit, %d warn out of %d process%s"), | ||
257 | metric_name, crit, warn, procs, | ||
258 | ( procs != 1 ? "es" : "")); | ||
259 | } | 259 | } |
260 | } | 260 | } |
261 | printf (ngettext ("%d process", "%d processes", procs), procs); | ||
261 | 262 | ||
262 | if (strcmp(fmt,"") != 0) { | 263 | if (strcmp(fmt,"") != 0) { |
263 | printf (_(" with %s"), fmt); | 264 | printf (_(" with %s"), fmt); |
264 | } | 265 | } |
265 | 266 | ||
266 | if ( verbose >= 1 && fails != "" ) | 267 | if ( verbose >= 1 && strcmp(fails,"") ) |
267 | printf (" [%s]", fails); | 268 | printf (" [%s]", fails); |
268 | 269 | ||
269 | printf ("\n"); | 270 | printf ("\n"); |
@@ -631,7 +632,7 @@ Optional Filters:\n\ | |||
631 | -a, --argument-array=STRING\n\ | 632 | -a, --argument-array=STRING\n\ |
632 | Only scan for processes with args that contain STRING.\n\ | 633 | Only scan for processes with args that contain STRING.\n\ |
633 | -C, --command=COMMAND\n\ | 634 | -C, --command=COMMAND\n\ |
634 | Only scan for exact matches to the named COMMAND.\n")); | 635 | Only scan for exact matches of COMMAND (without path).\n")); |
635 | 636 | ||
636 | printf(_("\n\ | 637 | printf(_("\n\ |
637 | RANGEs are specified 'min:max' or 'min:' or ':max' (or 'max'). If\n\ | 638 | RANGEs are specified 'min:max' or 'min:' or ':max' (or 'max'). If\n\ |