source: trunk/FACT++/dim/src/util/check_dim_servers.cxx@ 18522

Last change on this file since 18522 was 14698, checked in by tbretz, 12 years ago
Updated to v20r4
File size: 1.9 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 if(srvptr){}
61 // cout << "found " << server << " " << node << endl;
62 index++;
63 }
64 cout << "found " << n << " servers" << endl;
65 N_servers = n;
66 while(1)
67 {
68 int found = 0;
69 sleep(1);
70 for(i = 0; i < N_servers; i++)
71 {
72 if(server_versions[i] == 0)
73 {
74 found = 1;
75 }
76 }
77 if(!found)
78 break;
79 }
80 int max = 0;
81 for(i = 0; i < N_servers; i++)
82 {
83 if(server_versions[i] > max)
84 {
85 max = server_versions[i];
86 }
87 }
88 n = 0;
89 for(i = 0; i < N_servers; i++)
90 {
91 if(server_versions[i] < max)
92 {
93 cout << server_names[i] <<"@" << server_nodes[i] << " version " << server_versions[i] << endl;
94 }
95 else
96 n++;
97 }
98 cout << n << " Servers with version " << max << endl;
99}
Note: See TracBrowser for help on using the repository browser.