Changeset 874
- Timestamp:
- 05/16/13 21:47:03 (11 years ago)
- Location:
- branches/1.0/web/addons/job_monarch
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.0/web/addons/job_monarch/libtoga.php
r865 r874 598 598 } 599 599 600 function getUsingFQDN()601 {602 $handler = $this->xmlhandler;603 return $handler->getUsingFQDN();604 }605 606 600 function getMetrics() 607 601 { … … 649 643 $handler = $this->xmlhandler; 650 644 return $handler->isJobmonRunning(); 645 } 646 647 function makeHostname( $ahost, $adomain ) 648 { 649 $handler = $this->xmlhandler; 650 return $handler->makeHostname( $ahost, $adomain ); 651 651 } 652 652 } … … 658 658 function TorqueXMLHandler( $clustername ) 659 659 { 660 $this->jobs = array();661 $this->clusters = array();660 $this->jobs = array(); 661 $this->clusters = array(); 662 662 $this->nodes = array(); 663 $this->metrics = array();663 $this->metrics = array(); 664 664 $this->heartbeat = array(); 665 665 $this->down_nodes = array(); 666 $this->offline_nodes 667 $this->clustername 668 $this->proc_cluster = null;666 $this->offline_nodes = array(); 667 $this->clustername = $clustername; 668 $this->proc_cluster = null; 669 669 $this->proc_hostname = null; 670 $this->fqdn = 1; 671 } 672 673 function getUsingFQDN() 674 { 675 return $this->fqdn; 670 $this->fqdn = array(); 676 671 } 677 672 … … 705 700 } 706 701 707 function makeHostname( $thostname, $tdomain=null ) 708 { 709 if( $this->fqdn && isset( $tdomain ) ) 702 function isFqdn( $somehost ) 703 { 704 $chr_count = count_chars( $somehost ); 705 $dot_count = $chr_count[ ord('.') ]; 706 707 if( $dot_count > 1 ) 708 { 709 return true; 710 } 711 return false; 712 } 713 714 function makeHostname( $thostname, $tdomain ) 715 { 716 $mhost = $thostname; 717 718 if( ( $this->fqdn[ $thostname ] === true ) && isset( $tdomain ) && ( $tdomain !== '' ) ) 710 719 { 711 720 if( strpos( $thostname, $tdomain ) === false ) … … 713 722 $mhost = $thostname . '.' . $tdomain; 714 723 } 715 else716 {717 $mhost = $thostname;718 }719 }720 else721 {722 $mhost = $thostname;723 724 } 724 725 … … 761 762 $hostname = $attrs['NAME']; 762 763 $this->proc_hostname = $hostname; 764 765 if( $this->isFqdn( $hostname ) === true ) 766 { 767 $host_fields = explode( '.', $hostname ); 768 $shorthost = $host_fields[0]; 769 770 $this->fqdn[ $shorthost ] = true; 771 } 772 else 773 { 774 $this->fqdn[ $hostname ] = false; 775 } 763 776 764 777 # Pseudo metrics - add useful HOST attributes like gmond_started & last_reported to the metrics list: … … 804 817 { 805 818 $this->heartbeat['time'] = $attrs['VAL']; 806 return ;819 return null; 807 820 } 808 821 else if( strpos( $attrs['NAME'], 'zplugin_monarch_down' ) !== false ) … … 811 824 812 825 $nodes_down = array(); 813 $down_domain 826 $down_domain = null; 814 827 815 828 foreach( $fields as $f ) 816 829 { 817 $togavalues 830 $togavalues = explode( '=', $f ); 818 831 819 832 $toganame = $togavalues[0]; 820 $togavalue 833 $togavalue = $togavalues[1]; 821 834 822 835 if( $toganame == 'nodes' ) … … 837 850 if( !isset( $this->down_nodes['heartbeat'] ) ) 838 851 { 839 $this->down_nodes[$togavalue] 852 $this->down_nodes[$togavalue] = array( $nodes_down, $down_domain ); 840 853 } 841 854 } … … 845 858 else if( strpos( $attrs['NAME'], 'zplugin_monarch_offline' ) !== false ) 846 859 { 847 $fields = explode( ' ', $attrs['VAL'] );848 849 $nodes_offline 850 $offline_domain 860 $fields = explode( ' ', $attrs['VAL'] ); 861 862 $nodes_offline = array(); 863 $offline_domain = null; 851 864 852 865 foreach( $fields as $f ) 853 866 { 854 $togavalues 855 856 $toganame 857 $togavalue 867 $togavalues = explode( '=', $f ); 868 869 $toganame = $togavalues[0]; 870 $togavalue = $togavalues[1]; 858 871 859 872 if( $toganame == 'nodes' ) … … 895 908 $togavalues = explode( '=', $f ); 896 909 897 $toganame = $togavalues[0];898 $togavalue = $togavalues[1];910 $toganame = $togavalues[0]; 911 $togavalue = $togavalues[1]; 899 912 900 913 if( $toganame == 'nodes' ) … … 929 942 } 930 943 931 if( isset( $this->jobs[$jobid]['nodes'] ) ) 932 { 933 $nr_nodes = count( $this->jobs[$jobid]['nodes'] ); 944 } 945 return; 946 } 947 } 948 949 function finishUp( ) 950 { 951 $nodes = $this->nodes; 952 953 foreach( $this->jobs as $jobid => &$jobattrs ) 954 { 955 if( isset( $this->jobs[$jobid]['nodes'] ) ) 956 { 957 $nr_nodes = count( $this->jobs[$jobid]['nodes'] ); 934 958 935 if( $this->jobs[$jobid]['status'] == 'R' ) 959 if( $this->jobs[$jobid]['status'] == 'R' ) 960 { 961 foreach( $this->jobs[$jobid]['nodes'] as $node ) 936 962 { 937 938 if( isset( $this->jobs[$jobid]['domain'] ) ) 963 $domain = $this->jobs[$jobid]['domain']; 964 $host = $this->makeHostname( $node, $domain ); 965 966 if( !isset( $nodes[$host] ) ) 939 967 { 940 $domain = $this->jobs[$jobid]['domain']; 941 $domain_len = 0 - strlen( $domain ); 942 943 $first_host = key( array_slice($this->nodes, 0, 1, true) ); 944 945 // Let's see if Ganglia use's FQDN or short hostnames 946 // 947 if( strpos( $first_host, $domain ) === false ) 948 { 949 $this->fqdn = 0; 950 } 968 $my_node = new NodeImage( $this->proc_cluster, $host ); 951 969 } 952 970 else 953 971 { 954 $ this->fqdn = 0;972 $my_node = $nodes[$host]; 955 973 } 956 974 957 foreach( $this->jobs[$jobid]['nodes'] as $node)975 if( !$my_node->hasJob( $jobid ) ) 958 976 { 959 960 // Only add domain name to the hostname if Ganglia is doing that too 961 // 962 if( $this->fqdn && isset( $this->jobs[$jobid]['domain'] ) ) 977 if( isset( $this->jobs[$jobid]['ppn'] ) ) 963 978 { 964 if( strpos( $node, $domain ) === false ) 965 { 966 $host = $node. '.'.$domain; 967 } 968 else 969 { 970 $host = $node; 971 } 979 $my_node->addJob( $jobid, ((int) $this->jobs[$jobid]['ppn']) ); 972 980 } 973 981 else 974 982 { 975 $ host = $node;983 $my_node->addJob( $jobid, 1 ); 976 984 } 977 978 if( !isset( $this->nodes[$host] ) )979 {980 $my_node = new NodeImage( $this->proc_cluster, $host );981 }982 else983 {984 $my_node = $this->nodes[$host];985 }986 987 if( !$my_node->hasJob( $jobid ) )988 {989 if( isset( $jobs[$jobid]['ppn'] ) )990 {991 $my_node->addJob( $jobid, ((int) $jobs[$jobid]['ppn']) );992 }993 else994 {995 $my_node->addJob( $jobid, 1 );996 }997 }998 999 $this->nodes[$host] = $my_node;1000 985 } 986 987 $nodes[$host] = $my_node; 1001 988 } 1002 989 } 1003 990 } 1004 return; 1005 } 1006 } 1007 1008 function finishUp( ) 1009 { 1010 $nodes = $this->nodes; 991 } 1011 992 1012 993 if( sizeof( $this->down_nodes ) > 0 ) … … 1490 1471 function getNodes() 1491 1472 { 1492 if( $this->nodes == null )1473 if( $this->nodes === null ) 1493 1474 { 1494 1475 $this->checkParse(); -
branches/1.0/web/addons/job_monarch/overview.php
r836 r874 55 55 $gnodes = $data_gatherer->getNodes(); 56 56 $cpus = $data_gatherer->getCpus(); 57 $use_fqdn = $data_gatherer->getUsingFQDN();58 57 59 58 //print_r( $gnodes ); … … 467 466 $running_name_nodes[] = $tempnode; 468 467 468 $hostnode = $data_gatherer->makeHostname( $tempnode, $jobs[$jobid]['domain'] ); 469 469 470 if( isset( $hostname ) && $hostname != '' ) 470 471 { 471 $domain_len = 0 - strlen( $jobs[$jobid]['domain'] );472 $hostnode = $tempnode;473 474 if( $use_fqdn == 1)475 {476 if( substr( $hostnode, $domain_len ) != $jobs[$jobid]['domain'] )477 {478 $hostnode = $hostnode. '.'. $jobs[$jobid]['domain'];479 }480 }481 482 472 if( $hostname == $hostnode ) 483 473 { … … 648 638 foreach( $jobs[$jobid]['nodes'] as $shortnode ) 649 639 { 650 if( $use_fqdn == 1) 651 { 652 $mynode = $shortnode.".".$jobs[$jobid]['domain']; 653 } 640 $domain = $jobs[$jobid]['domain']; 641 $mynode = $data_gatherer->makeHostname( $shortnode, $domain ); 654 642 $myhost_href = "./?c=".$clustername."&h=".$mynode; 655 643 $mynodehosts[] = "<A HREF=\"".$myhost_href."\">".$shortnode."</A>"; … … 837 825 foreach ( $hosts_up as $host ) 838 826 { 839 $domain_len = 0 - strlen( $domain ); 840 841 if( $use_fqdn ) 842 { 843 if( substr( $host, $domain_len ) != $domain ) 844 { 845 $host = $host . '.' . $domain; 846 } 847 } 827 $host = $data_gatherer->makeHostname( $host, $domain ); 828 848 829 $cpus = 0; 849 830
Note: See TracChangeset
for help on using the changeset viewer.