2 # Estelle Deville 14 sept 2001
3 # Utilities to complete the Ressource Catalog with a new computer ressource
5 print "What is the Ressource Catalog name (absolute path)? ";
6 chomp($catalog=<STDIN>);
7 print "What is the computer name? ";
8 chomp($computer=<STDIN>);
10 printf "Will C++ container Type be able on %s [y/n]? ", $computer;
11 chomp($response=<STDIN>);
14 push(@container,"C++");
16 printf "Will python container Type be able on %s [y/n]? ", $computer;
17 chomp($response=<STDIN>);
20 push(@container,"python");
22 printf "Will NP container Type be able on %s [y/n]? ", $computer;
23 chomp($response=<STDIN>);
26 push(@container,"NP");
29 chomp($working_computer=`hostname`);
31 if($working_computer eq $computer)
34 if(-r $catalog && -w $catalog)
35 { #file exist and can bi read and write
37 chomp($OS_version=`uname -r`);
39 $proc="/proc/cpuinfo";
42 #information file of processor is accessible
49 if($temp eq "processor")
52 push(@proc_number,$_);
54 if($temp eq "model name")
59 if($temp eq "cpu MHz")
64 if($temp eq "cache size")
74 #Information Verification
75 for ($i=0; $i<=$#proc_number; $i++)
78 printf "number %s \n", $proc_number[$i];
79 printf "model name %s \n", $model_name[$i];
80 printf "cpu %s \n", $cpu[$i];
81 printf "cache %s \n", $cache[$i];
83 print "OS information\n";
84 printf "OS %s \n", $OS;
85 printf "OS_version %s \n",$OS_version;
86 print "CONTAINER TYPE LIST\n";
87 for ($i=0; $i<=$#container; $i++)
89 printf "container type %s \n", $container[$i];
92 #Write catalog content
93 open(CATALOG_IN,$catalog);
94 $catalog_temp=$catalog."_temp";
95 open(CATALOG,">$catalog_temp");
100 if($_ eq "<Ressources-list>\n")
106 print CATALOG "\t<computer>\n";
107 printf CATALOG "\t\t<name>%s</name>\n", $computer;
108 printf CATALOG "\t\t<OS>%s</OS>\n", $OS;
109 printf CATALOG "\t\t<OS-version>%s</OS-version>\n", $OS_version;
110 print CATALOG "\t\t<proc-list>\n";
112 for ($i=0; $i<=$#proc_number; $i++)
114 printf CATALOG "\t\t\t<proc>\n";
115 printf CATALOG "\t\t\t\t<number>%s</number>\n", $proc_number[$i];
116 printf CATALOG "\t\t\t\t<model>%s</model>\n", $model_name[$i];
117 printf CATALOG "\t\t\t\t<CPU-MHz>%s</CPU-MHz>\n", $cpu[$i];
118 printf CATALOG "\t\t\t\t<cache>%s</cache>\n", $cache[$i];
119 printf CATALOG "\t\t\t</proc>\n";
121 print CATALOG "\t\t</proc-list>\n";
123 print CATALOG "\t\t<containertype-list>\n";
124 for ($i=0; $i<=$#container; $i++)
126 printf CATALOG "\t\t\t\t<containertype>%s</containertype>\n", $container[$i];
128 print CATALOG "\t\t</containertype-list>\n";
129 print CATALOG "\t</computer>\n";
135 rename($catalog_temp,$catalog) || die "can't rename :$!";
139 printf "Error, the Ressource catalog %s isn't accessible\n", $catalog;
145 printf "Error, you should run the script on computer %s \n", $computer;