source: trunk/FACT++/dim_v19r20/src/util/check_dim_servers.cxx@ 10773

Last change on this file since 10773 was 10614, checked in by tbretz, 14 years ago
New release V19 r20
File size: 2.0 KB
Line 
1#include <iostream>
2#include <dic.hxx>
3using namespace std;
4
5#define MAX_SERVERS 5000
6char server_names[MAX_SERVERS][256];
7char server_nodes[MAX_SERVERS][256];
8int server_versions[MAX_SERVERS];
9int N_servers = 0;
10
11class DimVersion : public DimInfo
12{
13 int myIndex;
14 void infoHandler()
15 {
16 server_versions[myIndex] = getInt();
17 // cout << server_names[myIndex] << " version " << server_versions[myIndex] << endl;
18 }
19public :
20 DimVersion(char *service, int index) :
21 DimInfo(service,-1), myIndex(index) {};
22};
23
24int main()
25{
26 // int version = 0;
27 int n;
28 char *server, *node;
29 /*
30 DimCurrentInfo dns("DIS_DNS/VERSION_NUMBER",10,-1);
31
32 version = dns.getInt();
33 if(version == -1)
34 cout << "DNS not running" << endl;
35 else
36 cout << "DNS running" << endl;
37 return(0);
38 */
39 DimBrowser br;
40 DimVersion *srvptr;
41 char serviceName[256];
42 int index;
43 int i;
44
45 for(i = 0; i < MAX_SERVERS; i++)
46 {
47 server_names[i][0] = '\0';
48 server_versions[i] = 0;
49 }
50
51 n = br.getServers();
52 index = 0;
53 while(br.getNextServer(server, node))
54 {
55 strcpy(server_names[index],server);
56 strcpy(server_nodes[index],node);
57 strcpy(serviceName,server);
58 strcat(serviceName,"/VERSION_NUMBER");
59 srvptr = new DimVersion(serviceName, index);
60 // cout << "found " << server << " " << node << endl;
61 index++;
62 }
63 cout << "found " << n << " servers" << endl;
64 N_servers = n;
65 while(1)
66 {
67 int found = 0;
68 sleep(1);
69 for(i = 0; i < N_servers; i++)
70 {
71 if(server_versions[i] == 0)
72 {
73 found = 1;
74 }
75 }
76 if(!found)
77 break;
78 }
79 int max = 0;
80 for(i = 0; i < N_servers; i++)
81 {
82 if(server_versions[i] > max)
83 {
84 max = server_versions[i];
85 }
86 }
87 n = 0;
88 for(i = 0; i < N_servers; i++)
89 {
90 if(server_versions[i] < max)
91 {
92 cout << server_names[i] <<"@" << server_nodes[i] << " version " << server_versions[i] << endl;
93 }
94 else
95 n++;
96 }
97 cout << n << " Servers with version " << max << endl;
98}
Note: See TracBrowser for help on using the repository browser.