00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <VDirSurrogate.H>
00026 #include <perfDebugControl.H>
00027
00028 extern "C" {
00029 #include <getopt.h>
00030 }
00031
00032 using std::cout;
00033 using std::cerr;
00034 using std::endl;
00035
00036 Text program_name;
00037
00038 void usage()
00039 {
00040 cerr << "Usage: " << program_name << endl <<
00041 " [-n|-N] [-l|-L]" << endl <<
00042 " [-R repos]" << endl << endl;
00043 exit(1);
00044 }
00045
00046 int
00047 main(int argc, char* argv[])
00048 {
00049
00050 program_name = Text(argv[0]);
00051
00052
00053
00054 Basics::uint64 settings = 0;
00055
00056 try
00057 {
00058
00059 Text repos;
00060 bool default_repos = true;
00061 Text host(VDirSurrogate::defaultHost());
00062 Text port(VDirSurrogate::defaultPort());
00063
00064 opterr = 0;
00065 for (;;)
00066 {
00067 int c = getopt(argc, argv, "nNlLR:");
00068 if (c == EOF) break;
00069 switch (c)
00070 {
00071 case 'n':
00072 settings |= PerfDebug::nfsCallTiming;
00073 break;
00074 case 'N':
00075 settings &= ~((Basics::uint64) PerfDebug::nfsCallTiming);
00076 break;
00077 case 'l':
00078 settings |= PerfDebug::centralLockTiming;
00079 break;
00080 case 'L':
00081 settings &= ~((Basics::uint64) PerfDebug::centralLockTiming);
00082 break;
00083 case 'R':
00084 repos = optarg;
00085 default_repos = false;
00086 break;
00087 case '?':
00088 default:
00089 usage();
00090 }
00091 }
00092
00093
00094 if (argc != optind)
00095 {
00096 usage();
00097 }
00098
00099
00100 if (!default_repos)
00101 {
00102 int colon = repos.FindCharR(':');
00103 if (colon == -1)
00104 {
00105 host = repos;
00106 repos = repos + ":" + port;
00107 }
00108 else
00109 {
00110 host = repos.Sub(0, colon);
00111 port = repos.Sub(colon+1);
00112 }
00113 }
00114
00115
00116
00117 Basics::uint64 result = PerfDebug::Set(settings, host, port);
00118
00119
00120
00121 if(result & PerfDebug::nfsCallTiming)
00122 {
00123 cout << "Enabdled fine-graned NFS call timing" << endl;
00124 }
00125 else
00126 {
00127 cout << "Disabdled fine-graned NFS call timing" << endl;
00128 }
00129 if(result & PerfDebug::centralLockTiming)
00130 {
00131 cout << "Enabdled central lock timing" << endl;
00132 }
00133 else
00134 {
00135 cout << "Disabdled central lock timing" << endl;
00136 }
00137
00138
00139
00140 if((result == 0) && (settings != 0))
00141 {
00142 cout << "(Maybe this repository doesn't have performance debugging?)"
00143 << endl;
00144 }
00145 }
00146 catch (VestaConfig::failure f)
00147 {
00148 cerr << program_name << ": " << f.msg << endl;
00149 exit(2);
00150 }
00151 catch (SRPC::failure f)
00152 {
00153 cerr << program_name
00154 << ": SRPC failure; " << f.msg << " (" << f.r << ")" << endl;
00155 exit(2);
00156 }
00157 }