diff options
Diffstat (limited to 'src/ldapinfo.c')
| -rw-r--r-- | src/ldapinfo.c | 126 |
1 files changed, 63 insertions, 63 deletions
diff --git a/src/ldapinfo.c b/src/ldapinfo.c index 0f68404..3eba31c 100644 --- a/src/ldapinfo.c +++ b/src/ldapinfo.c | |||
| @@ -642,15 +642,16 @@ int my_monitor_database(MyConfig * cnf, const char * base) | |||
| 642 | } | 642 | } |
| 643 | 643 | ||
| 644 | 644 | ||
| 645 | int my_monitor_operations(MyConfig * cnf, const char * base) | 645 | int my_monitor_listeners(MyConfig * cnf, const char * base) |
| 646 | { | 646 | { |
| 647 | int rc; | 647 | int rc; |
| 648 | int err; | 648 | int err; |
| 649 | int msgid; | 649 | int msgid; |
| 650 | int count; | 650 | int count; |
| 651 | char ** cn; | 651 | char * uri; |
| 652 | char ** initiated; | 652 | char ** uris; |
| 653 | char ** completed; | 653 | char * addr; |
| 654 | char ** addrs; | ||
| 654 | char dn[256]; | 655 | char dn[256]; |
| 655 | char buff[256]; | 656 | char buff[256]; |
| 656 | LDAP * ld; | 657 | LDAP * ld; |
| @@ -663,7 +664,7 @@ int my_monitor_operations(MyConfig * cnf, const char * base) | |||
| 663 | // searches for cn=Connections,<monitor> | 664 | // searches for cn=Connections,<monitor> |
| 664 | timeout.tv_sec = 5; | 665 | timeout.tv_sec = 5; |
| 665 | timeout.tv_usec = 0; | 666 | timeout.tv_usec = 0; |
| 666 | strncpy(dn, "cn=Operations,", sizeof(dn)); | 667 | strncpy(dn, "cn=Listeners,", sizeof(dn)); |
| 667 | strncat(dn, base, (sizeof(dn)-strlen(dn)-1)); | 668 | strncat(dn, base, (sizeof(dn)-strlen(dn)-1)); |
| 668 | if ((err = ldap_search_ext(ld, dn, LDAP_SCOPE_ONE, "(objectclass=*)", cnf->lud->attrs, 0, NULL, NULL, &timeout, -1, &msgid)) != LDAP_SUCCESS) | 669 | if ((err = ldap_search_ext(ld, dn, LDAP_SCOPE_ONE, "(objectclass=*)", cnf->lud->attrs, 0, NULL, NULL, &timeout, -1, &msgid)) != LDAP_SUCCESS) |
| 669 | return(-1); | 670 | return(-1); |
| @@ -683,58 +684,56 @@ int my_monitor_operations(MyConfig * cnf, const char * base) | |||
| 683 | msg = ldap_first_entry(ld, res); | 684 | msg = ldap_first_entry(ld, res); |
| 684 | while ((msg)) | 685 | while ((msg)) |
| 685 | { | 686 | { |
| 686 | if ((cn = ldap_get_values(ld, msg, "cn")) == NULL) | 687 | if ((uris = ldap_get_values(ld, msg, "labeledURI")) == NULL) |
| 687 | { | 688 | { |
| 688 | msg = ldap_next_entry(ld, msg); | 689 | msg = ldap_next_entry(ld, msg); |
| 689 | continue; | 690 | continue; |
| 690 | }; | 691 | }; |
| 691 | if (!(cn[0][0])) | 692 | if (!(uris[0][0])) |
| 692 | { | 693 | { |
| 693 | ldap_value_free(cn); | 694 | ldap_value_free(uris); |
| 694 | msg = ldap_next_entry(ld, msg); | 695 | msg = ldap_next_entry(ld, msg); |
| 695 | continue; | 696 | continue; |
| 696 | }; | 697 | }; |
| 697 | 698 | ||
| 698 | if ((initiated = ldap_get_values(ld, msg, "monitorOpInitiated")) == NULL) | 699 | if ((addrs = ldap_get_values(ld, msg, "monitorConnectionLocalAddress")) == NULL) |
| 699 | { | 700 | { |
| 700 | ldap_value_free(cn); | 701 | ldap_value_free(uris); |
| 701 | msg = ldap_next_entry(ld, msg); | 702 | msg = ldap_next_entry(ld, msg); |
| 702 | continue; | 703 | continue; |
| 703 | }; | 704 | }; |
| 704 | if (!(initiated[0][0])) | 705 | if (!(addrs[0][0])) |
| 705 | { | 706 | { |
| 706 | ldap_value_free(cn); | 707 | ldap_value_free(addrs); |
| 707 | ldap_value_free(initiated); | 708 | ldap_value_free(uris); |
| 708 | msg = ldap_next_entry(ld, msg); | 709 | msg = ldap_next_entry(ld, msg); |
| 709 | continue; | 710 | continue; |
| 710 | }; | 711 | }; |
| 711 | 712 | ||
| 712 | if ((completed = ldap_get_values(ld, msg, "monitorOpCompleted")) == NULL) | 713 | if ((addr = rindex(addrs[0], '=')) == NULL) |
| 713 | { | 714 | { |
| 714 | ldap_value_free(cn); | 715 | ldap_value_free(addrs); |
| 715 | ldap_value_free(initiated); | 716 | ldap_value_free(uris); |
| 716 | msg = ldap_next_entry(ld, msg); | 717 | msg = ldap_next_entry(ld, msg); |
| 717 | continue; | 718 | continue; |
| 718 | }; | 719 | }; |
| 719 | if (!(completed[0][0])) | 720 | addr++; |
| 721 | uri = index(uris[0], '/'); | ||
| 722 | if ((uri != NULL)) | ||
| 723 | uri = &uri[2]; | ||
| 724 | if ((uri)) | ||
| 720 | { | 725 | { |
| 721 | ldap_value_free(cn); | 726 | uri[0] = '\0'; |
| 722 | ldap_value_free(completed); | 727 | snprintf(buff, sizeof(buff), "%s%s", uris[0], addr); |
| 723 | ldap_value_free(initiated); | 728 | if (!(count)) |
| 724 | msg = ldap_next_entry(ld, msg); | 729 | my_field("Listeners:", buff, 0); |
| 725 | continue; | 730 | else |
| 731 | my_field(NULL, buff, 0); | ||
| 732 | count++; | ||
| 726 | }; | 733 | }; |
| 727 | 734 | ||
| 728 | snprintf(buff, sizeof(buff), "%s initiated: %s; completed %s", cn[0], initiated[0], completed[0]); | 735 | ldap_value_free(addrs); |
| 729 | if (!(count)) | 736 | ldap_value_free(uris); |
| 730 | my_field("Operations:", buff, 0); | ||
| 731 | else | ||
| 732 | my_field(NULL, buff, 0); | ||
| 733 | count++; | ||
| 734 | |||
| 735 | ldap_value_free(cn); | ||
| 736 | ldap_value_free(initiated); | ||
| 737 | ldap_value_free(completed); | ||
| 738 | 737 | ||
| 739 | // retrieves next entry | 738 | // retrieves next entry |
| 740 | msg = ldap_next_entry(ld, msg); | 739 | msg = ldap_next_entry(ld, msg); |
| @@ -746,16 +745,15 @@ int my_monitor_operations(MyConfig * cnf, const char * base) | |||
| 746 | } | 745 | } |
| 747 | 746 | ||
| 748 | 747 | ||
| 749 | int my_monitor_listeners(MyConfig * cnf, const char * base) | 748 | int my_monitor_operations(MyConfig * cnf, const char * base) |
| 750 | { | 749 | { |
| 751 | int rc; | 750 | int rc; |
| 752 | int err; | 751 | int err; |
| 753 | int msgid; | 752 | int msgid; |
| 754 | int count; | 753 | int count; |
| 755 | char * uri; | 754 | char ** cn; |
| 756 | char ** uris; | 755 | char ** initiated; |
| 757 | char * addr; | 756 | char ** completed; |
| 758 | char ** addrs; | ||
| 759 | char dn[256]; | 757 | char dn[256]; |
| 760 | char buff[256]; | 758 | char buff[256]; |
| 761 | LDAP * ld; | 759 | LDAP * ld; |
| @@ -768,7 +766,7 @@ int my_monitor_listeners(MyConfig * cnf, const char * base) | |||
| 768 | // searches for cn=Connections,<monitor> | 766 | // searches for cn=Connections,<monitor> |
| 769 | timeout.tv_sec = 5; | 767 | timeout.tv_sec = 5; |
| 770 | timeout.tv_usec = 0; | 768 | timeout.tv_usec = 0; |
| 771 | strncpy(dn, "cn=Listeners,", sizeof(dn)); | 769 | strncpy(dn, "cn=Operations,", sizeof(dn)); |
| 772 | strncat(dn, base, (sizeof(dn)-strlen(dn)-1)); | 770 | strncat(dn, base, (sizeof(dn)-strlen(dn)-1)); |
| 773 | if ((err = ldap_search_ext(ld, dn, LDAP_SCOPE_ONE, "(objectclass=*)", cnf->lud->attrs, 0, NULL, NULL, &timeout, -1, &msgid)) != LDAP_SUCCESS) | 771 | if ((err = ldap_search_ext(ld, dn, LDAP_SCOPE_ONE, "(objectclass=*)", cnf->lud->attrs, 0, NULL, NULL, &timeout, -1, &msgid)) != LDAP_SUCCESS) |
| 774 | return(-1); | 772 | return(-1); |
| @@ -788,56 +786,58 @@ int my_monitor_listeners(MyConfig * cnf, const char * base) | |||
| 788 | msg = ldap_first_entry(ld, res); | 786 | msg = ldap_first_entry(ld, res); |
| 789 | while ((msg)) | 787 | while ((msg)) |
| 790 | { | 788 | { |
| 791 | if ((uris = ldap_get_values(ld, msg, "labeledURI")) == NULL) | 789 | if ((cn = ldap_get_values(ld, msg, "cn")) == NULL) |
| 792 | { | 790 | { |
| 793 | msg = ldap_next_entry(ld, msg); | 791 | msg = ldap_next_entry(ld, msg); |
| 794 | continue; | 792 | continue; |
| 795 | }; | 793 | }; |
| 796 | if (!(uris[0][0])) | 794 | if (!(cn[0][0])) |
| 797 | { | 795 | { |
| 798 | ldap_value_free(uris); | 796 | ldap_value_free(cn); |
| 799 | msg = ldap_next_entry(ld, msg); | 797 | msg = ldap_next_entry(ld, msg); |
| 800 | continue; | 798 | continue; |
| 801 | }; | 799 | }; |
| 802 | 800 | ||
| 803 | if ((addrs = ldap_get_values(ld, msg, "monitorConnectionLocalAddress")) == NULL) | 801 | if ((initiated = ldap_get_values(ld, msg, "monitorOpInitiated")) == NULL) |
| 804 | { | 802 | { |
| 805 | ldap_value_free(uris); | 803 | ldap_value_free(cn); |
| 806 | msg = ldap_next_entry(ld, msg); | 804 | msg = ldap_next_entry(ld, msg); |
| 807 | continue; | 805 | continue; |
| 808 | }; | 806 | }; |
| 809 | if (!(addrs[0][0])) | 807 | if (!(initiated[0][0])) |
| 810 | { | 808 | { |
| 811 | ldap_value_free(addrs); | 809 | ldap_value_free(cn); |
| 812 | ldap_value_free(uris); | 810 | ldap_value_free(initiated); |
| 813 | msg = ldap_next_entry(ld, msg); | 811 | msg = ldap_next_entry(ld, msg); |
| 814 | continue; | 812 | continue; |
| 815 | }; | 813 | }; |
| 816 | 814 | ||
| 817 | if ((addr = rindex(addrs[0], '=')) == NULL) | 815 | if ((completed = ldap_get_values(ld, msg, "monitorOpCompleted")) == NULL) |
| 818 | { | 816 | { |
| 819 | ldap_value_free(addrs); | 817 | ldap_value_free(cn); |
| 820 | ldap_value_free(uris); | 818 | ldap_value_free(initiated); |
| 821 | msg = ldap_next_entry(ld, msg); | 819 | msg = ldap_next_entry(ld, msg); |
| 822 | continue; | 820 | continue; |
| 823 | }; | 821 | }; |
| 824 | addr++; | 822 | if (!(completed[0][0])) |
| 825 | uri = index(uris[0], '/'); | ||
| 826 | if ((uri != NULL)) | ||
| 827 | uri = &uri[2]; | ||
| 828 | if ((uri)) | ||
| 829 | { | 823 | { |
| 830 | uri[0] = '\0'; | 824 | ldap_value_free(cn); |
| 831 | snprintf(buff, sizeof(buff), "%s%s", uris[0], addr); | 825 | ldap_value_free(completed); |
| 832 | if (!(count)) | 826 | ldap_value_free(initiated); |
| 833 | my_field("Listeners:", buff, 0); | 827 | msg = ldap_next_entry(ld, msg); |
| 834 | else | 828 | continue; |
| 835 | my_field(NULL, buff, 0); | ||
| 836 | count++; | ||
| 837 | }; | 829 | }; |
| 838 | 830 | ||
| 839 | ldap_value_free(addrs); | 831 | snprintf(buff, sizeof(buff), "%s initiated: %s; completed %s", cn[0], initiated[0], completed[0]); |
| 840 | ldap_value_free(uris); | 832 | if (!(count)) |
| 833 | my_field("Operations:", buff, 0); | ||
| 834 | else | ||
| 835 | my_field(NULL, buff, 0); | ||
| 836 | count++; | ||
| 837 | |||
| 838 | ldap_value_free(cn); | ||
| 839 | ldap_value_free(initiated); | ||
| 840 | ldap_value_free(completed); | ||
| 841 | 841 | ||
| 842 | // retrieves next entry | 842 | // retrieves next entry |
| 843 | msg = ldap_next_entry(ld, msg); | 843 | msg = ldap_next_entry(ld, msg); |
