summaryrefslogtreecommitdiffstats
path: root/plugins/check_procs.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_procs.c')
-rw-r--r--plugins/check_procs.c136
1 files changed, 68 insertions, 68 deletions
diff --git a/plugins/check_procs.c b/plugins/check_procs.c
index a8a7d5e..ee168db 100644
--- a/plugins/check_procs.c
+++ b/plugins/check_procs.c
@@ -589,6 +589,71 @@ check_thresholds (int value)
589 589
590 590
591 591
592
593/* convert the elapsed time to seconds */
594int
595convert_to_seconds(char *etime) {
596
597 char *ptr;
598 int total;
599
600 int hyphcnt;
601 int coloncnt;
602 int days;
603 int hours;
604 int minutes;
605 int seconds;
606
607 hyphcnt = 0;
608 coloncnt = 0;
609 days = 0;
610 hours = 0;
611 minutes = 0;
612 seconds = 0;
613
614 for (ptr = etime; *ptr != '\0'; ptr++) {
615
616 if (*ptr == '-') {
617 hyphcnt++;
618 continue;
619 }
620 if (*ptr == ':') {
621 coloncnt++;
622 continue;
623 }
624 }
625
626 if (hyphcnt > 0) {
627 sscanf(etime, "%d-%d:%d:%d",
628 &days, &hours, &minutes, &seconds);
629 /* linux 2.6.5/2.6.6 reporting some processes with infinite
630 * elapsed times for some reason */
631 if (days == 49710) {
632 return 0;
633 }
634 } else {
635 if (coloncnt == 2) {
636 sscanf(etime, "%d:%d:%d",
637 &hours, &minutes, &seconds);
638 } else if (coloncnt == 1) {
639 sscanf(etime, "%d:%d",
640 &minutes, &seconds);
641 }
642 }
643
644 total = (days * 86400) +
645 (hours * 3600) +
646 (minutes * 60) +
647 seconds;
648
649 if (verbose >= 3) {
650 printf("seconds: %d\n", total);
651 }
652 return total;
653}
654
655
656
592void 657void
593print_help (void) 658print_help (void)
594{ 659{
@@ -681,78 +746,13 @@ Examples:\n\
681 printf (_(UT_SUPPORT)); 746 printf (_(UT_SUPPORT));
682} 747}
683 748
684
685
686/* convert the elapsed time to seconds */
687int
688convert_to_seconds(char *etime) {
689
690 char *ptr;
691 int total;
692
693 int hyphcnt;
694 int coloncnt;
695 int days;
696 int hours;
697 int minutes;
698 int seconds;
699
700 hyphcnt = 0;
701 coloncnt = 0;
702 days = 0;
703 hours = 0;
704 minutes = 0;
705 seconds = 0;
706
707 for (ptr = etime; *ptr != '\0'; ptr++) {
708
709 if (*ptr == '-') {
710 hyphcnt++;
711 continue;
712 }
713 if (*ptr == ':') {
714 coloncnt++;
715 continue;
716 }
717 }
718
719 if (hyphcnt > 0) {
720 sscanf(etime, "%d-%d:%d:%d",
721 &days, &hours, &minutes, &seconds);
722 /* linux 2.6.5/2.6.6 reporting some processes with infinite
723 * elapsed times for some reason */
724 if (days == 49710) {
725 return 0;
726 }
727 } else {
728 if (coloncnt == 2) {
729 sscanf(etime, "%d:%d:%d",
730 &hours, &minutes, &seconds);
731 } else if (coloncnt == 1) {
732 sscanf(etime, "%d:%d",
733 &minutes, &seconds);
734 }
735 }
736
737 total = (days * 86400) +
738 (hours * 3600) +
739 (minutes * 60) +
740 seconds;
741
742 if (verbose >= 3) {
743 printf("seconds: %d\n", total);
744 }
745 return total;
746}
747
748void 749void
749print_usage (void) 750print_usage (void)
750{ 751{
751 printf ("\ 752 printf ("\
752Usage: %s -w <range> -c <range> [-m metric] [-s state] [-p ppid]\n\ 753Usage: %s -w <range> -c <range> [-m metric] [-s state] [-p ppid]\n\
753 [-u user] [-r rss] [-z vsz] [-P %%cpu] [-a argument-array]\n\ 754 [-u user] [-r rss] [-z vsz] [-P %%cpu] [-a argument-array]\n\
754 [-C command] [-t timeout] [-v]\n", progname); 755 [-C command] [-t timeout] [-v]\n", progname);
755 printf (_(UT_HLP_VRS), progname, progname); 756
757 printf (UT_HLP_VRS, progname, progname);
756} 758}
757
758