Changeset 749 for branches/0.4/web/addons/job_monarch/libtoga.php
- Timestamp:
- 03/25/13 18:49:23 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/0.4/web/addons/job_monarch/libtoga.php
r748 r749 609 609 $this->offline_nodes = array(); 610 610 $this->clustername = $clustername; 611 $this->proc_cluster = null; 611 612 $this->fqdn = 1; 612 613 } … … 694 695 function startElement( $parser, $name, $attrs ) 695 696 { 696 $jobs = $this->jobs;697 $nodes = $this->nodes;698 697 699 698 if( isset( $attrs['TN'] ) ) … … 704 703 if ( $attrs['TN'] > $attrs['TMAX'] * 4 ) 705 704 { 706 return ;705 return null; 707 706 } 708 707 } … … 714 713 { 715 714 $this->proc_cluster = $attrs['NAME']; 716 } 717 else if( $name == 'HOST' and $this->proc_cluster == $this->clustername) 715 //printf("set proc cluster to %s\n", $attrs['NAME'] ); 716 return null; 717 } 718 if( $this->proc_cluster != $this->clustername ) 719 { 720 //printf("cluster does not match: %s\n", $this->clustername ); 721 return null; 722 } 723 724 if( $name == 'HOST' ) 718 725 { 719 726 $hostname = $attrs['NAME']; 720 727 721 $location = $attrs['LOCATION']; 722 723 if( !isset( $nodes[$hostname] ) ) 724 { 725 $nodes[$hostname] = new NodeImage( $this->proc_cluster, $hostname ); 726 } 727 } 728 else if( $name == 'METRIC' and ( strpos( $attrs['NAME'], 'zplugin_monarch' ) !== false ) and $this->proc_cluster == $this->clustername ) 728 //printf( "host %s\n", $hostname ); 729 //$location = $attrs['LOCATION']; 730 731 if( !isset( $this->nodes[$hostname] ) ) 732 { 733 $this->nodes[$hostname] = new NodeImage( $this->proc_cluster, $hostname ); 734 } 735 return null; 736 } 737 if( $name == 'METRIC' and ( strpos( $attrs['NAME'], 'zplugin_monarch' ) !== false ) ) 729 738 { 730 739 if( strpos( $attrs['NAME'], 'zplugin_monarch_heartbeat' ) !== false ) 731 740 { 732 741 $this->heartbeat['time'] = $attrs['VAL']; 742 return; 733 743 } 734 744 else if( strpos( $attrs['NAME'], 'zplugin_monarch_down' ) !== false ) … … 767 777 } 768 778 } 779 return; 769 780 } 770 781 else if( strpos( $attrs['NAME'], 'zplugin_monarch_offline' ) !== false ) … … 803 814 } 804 815 } 816 return; 805 817 } 806 818 else if( strpos( $attrs['NAME'], 'zplugin_monarch_job' ) !== false ) … … 808 820 sscanf( $attrs['NAME'], 'zplugin_monarch_job_%d_%s$', $monincr, $jobid ); 809 821 810 if( !isset( $ jobs[$jobid] ) )811 { 812 $ jobs[$jobid] = array();822 if( !isset( $this->jobs[$jobid] ) ) 823 { 824 $this->jobs[$jobid] = array(); 813 825 } 814 826 … … 824 836 if( $toganame == 'nodes' ) 825 837 { 826 if( $ jobs[$jobid]['status'] == 'R' )838 if( $this->jobs[$jobid]['status'] == 'R' ) 827 839 { 828 if( !isset( $ jobs[$jobid][$toganame] ) )840 if( !isset( $this->jobs[$jobid][$toganame] ) ) 829 841 { 830 $ jobs[$jobid][$toganame] = array();842 $this->jobs[$jobid][$toganame] = array(); 831 843 } 832 844 … … 835 847 foreach( $mynodes as $node ) 836 848 { 837 if( !in_array( $node, $ jobs[$jobid][$toganame] ) )849 if( !in_array( $node, $this->jobs[$jobid][$toganame] ) ) 838 850 { 839 array_push( $ jobs[$jobid][$toganame], $node );851 array_push( $this->jobs[$jobid][$toganame], $node ); 840 852 } 841 853 } 842 854 843 855 } 844 else if( $ jobs[$jobid]['status'] == 'Q' )856 else if( $this->jobs[$jobid]['status'] == 'Q' ) 845 857 { 846 $ jobs[$jobid][$toganame] = $togavalue;858 $this->jobs[$jobid][$toganame] = $togavalue; 847 859 } 848 860 } 849 861 else 850 862 { 851 $ jobs[$jobid][$toganame] = $togavalue;863 $this->jobs[$jobid][$toganame] = $togavalue; 852 864 } 853 865 } 854 866 855 if( isset( $ jobs[$jobid]['nodes'] ) )856 { 857 $nr_nodes = count( $ jobs[$jobid]['nodes'] );867 if( isset( $this->jobs[$jobid]['nodes'] ) ) 868 { 869 $nr_nodes = count( $this->jobs[$jobid]['nodes'] ); 858 870 859 if( $ jobs[$jobid]['status'] == 'R' )871 if( $this->jobs[$jobid]['status'] == 'R' ) 860 872 { 861 873 862 if( isset( $ jobs[$jobid]['domain'] ) )874 if( isset( $this->jobs[$jobid]['domain'] ) ) 863 875 { 864 $domain = $ jobs[$jobid]['domain'];876 $domain = $this->jobs[$jobid]['domain']; 865 877 $domain_len = 0 - strlen( $domain ); 866 878 867 $nodekeys = array_keys( $ nodes );879 $nodekeys = array_keys( $this->nodes ); 868 880 869 881 $first_host = $nodekeys[0]; … … 880 892 } 881 893 882 foreach( $ jobs[$jobid]['nodes'] as $node )894 foreach( $this->jobs[$jobid]['nodes'] as $node ) 883 895 { 884 896 885 897 // Only add domain name to the hostname if Ganglia is doing that too 886 898 // 887 if( $this->fqdn && isset( $ jobs[$jobid]['domain'] ) )899 if( $this->fqdn && isset( $this->jobs[$jobid]['domain'] ) ) 888 900 { 889 901 if( strpos( $node, $domain ) === false ) … … 900 912 } 901 913 902 if( !isset( $ nodes[$host] ) )914 if( !isset( $this->nodes[$host] ) ) 903 915 { 904 916 $my_node = new NodeImage( $this->proc_cluster, $host ); … … 906 918 else 907 919 { 908 $my_node = $ nodes[$host];920 $my_node = $this->nodes[$host]; 909 921 } 910 922 … … 921 933 } 922 934 923 $ nodes[$host] = $my_node;935 $this->nodes[$host] = $my_node; 924 936 } 925 937 } 926 938 } 927 939 } 928 } 929 $this->jobs = $jobs; 930 $this->nodes = $nodes; 940 return; 941 } 931 942 } 932 943
Note: See TracChangeset
for help on using the changeset viewer.