summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTon Voon <tonvoon@users.sourceforge.net>2003-09-16 14:14:53 (GMT)
committerTon Voon <tonvoon@users.sourceforge.net>2003-09-16 14:14:53 (GMT)
commit073e0fa95c6dd06a0a12634fb9e785d3aa2d2fc1 (patch)
treefc9d62cc6e48d1ea360c945714426567576e9159
parente47b74ede50b0f4feabda65f5c33fee6da13c136 (diff)
downloadmonitoring-plugins-073e0fa95c6dd06a0a12634fb9e785d3aa2d2fc1.tar.gz
Support for AIX ps command and cleanup of configure's ps checks
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@731 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r--configure.in70
-rw-r--r--plugins/Makefile.am4
-rw-r--r--plugins/check_procs.c65
3 files changed, 77 insertions, 62 deletions
diff --git a/configure.in b/configure.in
index 37baafa..09e8e35 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
640dnl STAT UCOMM VSZ RSS USER UID PPID COMMAND 640dnl 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
650dnl FreeBSD 650dnl 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
660dnl BSD-like mode in RH 6.1 660dnl 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
670dnl SunOS 4.1.3: 670dnl 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
681dnl Debian Linux / procps v1.2.9: 681dnl 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
694dnl OpenBSD (needs to come early because -exo appears to work, but does not give all procs) 694dnl 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
704dnl AIX 4.3.3 - needs verification. This works for Tru64 - needs %*[ +] in PS_FORMAT 704dnl Tru64 - needs %*[ +] in PS_FORMAT
705elif ps -ao 'stat comm vsz rss user uid ppid args' 2>/dev/null | \ 705elif 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
707then 707then
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
714elif ps -eo 's comm vsz rss user uid ppid args' 2>/dev/null | \ 714elif 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
723dnl AIX 4.3.3 and 5.1 do not have an rss field
724elif 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
726then
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
723elif ps -Ao 's comm vsz rss uid user ppid args' 2>/dev/null | \ 733elif 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
725then 735then
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
732elif ps -Ao 'status comm vsz rss uid user ppid args' 2>/dev/null | \ 742elif 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
741elif ps -Ao 'state comm vsz rss uid user ppid args' 2>/dev/null | \ 751elif 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
750dnl wonder who takes state instead of stat 760dnl 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
760dnl IRIX 53 770dnl 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
769dnl IRIX 63 780dnl 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
778dnl AIX 4.1: 790dnl 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
789dnl AIX? 802dnl 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
798dnl MacOSX / Darwin 812dnl 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
812dnl UnixWare 826dnl 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
827else 836else
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])
829fi 838fi
830 839
831AC_DEFINE_UNQUOTED(PS_VARLIST,$ac_cv_ps_varlist, 840if 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,
833AC_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",
835AC_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"
850fi
837 851
838dnl jm_AFS 852dnl jm_AFS
839jm_LIST_MOUNTED_FILESYSTEMS([list_mounted_fs=yes], [list_mounted_fs=no]) 853jm_LIST_MOUNTED_FILESYSTEMS([list_mounted_fs=yes], [list_mounted_fs=no])
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 683cd51..ac421e5 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -12,7 +12,7 @@ LIBS = @LIBINTL@ @LIBS@
12 12
13libexec_PROGRAMS = check_disk check_dummy check_http check_load \ 13libexec_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
22EXTRA_PROGRAMS = check_mysql check_radius check_pgsql check_snmp check_hpjd \ 22EXTRA_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
26EXTRA_DIST = t utils.c netutils.c popen.c utils.h netutils.h popen.h common.h \ 26EXTRA_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 e0ee524..a868fcf 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\
637RANGEs are specified 'min:max' or 'min:' or ':max' (or 'max'). If\n\ 638RANGEs are specified 'min:max' or 'min:' or ':max' (or 'max'). If\n\