|
|
|
|
@ -63,108 +63,6 @@ class MySrvC;
|
|
|
|
|
class MySrvList;
|
|
|
|
|
class MyHGC;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
class HGM_query_errors_stats {
|
|
|
|
|
public:
|
|
|
|
|
int hid;
|
|
|
|
|
char *hostname;
|
|
|
|
|
int port;
|
|
|
|
|
char *username;
|
|
|
|
|
char *schemaname;
|
|
|
|
|
int error_no;
|
|
|
|
|
unsigned int count_star;
|
|
|
|
|
time_t first_seen;
|
|
|
|
|
time_t last_seen;
|
|
|
|
|
char *last_error;
|
|
|
|
|
HGM_query_errors_stats(int _h, char *_hn, int _p, char *u, char *s, int e, char *le) {
|
|
|
|
|
hid=_h;
|
|
|
|
|
hostname=strdup(_hn);
|
|
|
|
|
port=_p;
|
|
|
|
|
username=strdup(u);
|
|
|
|
|
schemaname=strdup(s);
|
|
|
|
|
error_no=e;
|
|
|
|
|
last_error=strdup(le);
|
|
|
|
|
count_star=0;
|
|
|
|
|
first_seen=0;
|
|
|
|
|
last_seen=0;
|
|
|
|
|
}
|
|
|
|
|
void add_time(unsigned long long n, char *le) {
|
|
|
|
|
count_star++;
|
|
|
|
|
if (first_seen==0) {
|
|
|
|
|
first_seen=n;
|
|
|
|
|
}
|
|
|
|
|
last_seen=n;
|
|
|
|
|
if (strcmp(last_error,le)){
|
|
|
|
|
free(last_error);
|
|
|
|
|
last_error=strdup(le);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
~HGM_query_errors_stats() {
|
|
|
|
|
if (hostname) {
|
|
|
|
|
free(hostname);
|
|
|
|
|
hostname=NULL;
|
|
|
|
|
}
|
|
|
|
|
if (username) {
|
|
|
|
|
free(username);
|
|
|
|
|
username=NULL;
|
|
|
|
|
}
|
|
|
|
|
if (schemaname) {
|
|
|
|
|
free(schemaname);
|
|
|
|
|
schemaname=NULL;
|
|
|
|
|
}
|
|
|
|
|
if (last_error) {
|
|
|
|
|
free(last_error);
|
|
|
|
|
last_error=NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
char **get_row() {
|
|
|
|
|
char buf[128];
|
|
|
|
|
char **pta=(char **)malloc(sizeof(char *)*10);
|
|
|
|
|
sprintf(buf,"%d",hid);
|
|
|
|
|
pta[0]=strdup(buf);
|
|
|
|
|
assert(hostname);
|
|
|
|
|
pta[1]=strdup(hostname);
|
|
|
|
|
sprintf(buf,"%d",port);
|
|
|
|
|
pta[2]=strdup(buf);
|
|
|
|
|
assert(username);
|
|
|
|
|
pta[3]=strdup(username);
|
|
|
|
|
assert(schemaname);
|
|
|
|
|
pta[4]=strdup(schemaname);
|
|
|
|
|
sprintf(buf,"%d",error_no);
|
|
|
|
|
pta[5]=strdup(buf);
|
|
|
|
|
|
|
|
|
|
sprintf(buf,"%u",count_star);
|
|
|
|
|
pta[6]=strdup(buf);
|
|
|
|
|
|
|
|
|
|
time_t __now;
|
|
|
|
|
time(&__now);
|
|
|
|
|
unsigned long long curtime=monotonic_time();
|
|
|
|
|
time_t seen_time;
|
|
|
|
|
|
|
|
|
|
seen_time= __now - curtime/1000000 + first_seen/1000000;
|
|
|
|
|
sprintf(buf,"%ld", seen_time);
|
|
|
|
|
pta[7]=strdup(buf);
|
|
|
|
|
|
|
|
|
|
seen_time= __now - curtime/1000000 + last_seen/1000000;
|
|
|
|
|
sprintf(buf,"%ld", seen_time);
|
|
|
|
|
pta[8]=strdup(buf);
|
|
|
|
|
|
|
|
|
|
assert(last_error);
|
|
|
|
|
pta[9]=strdup(last_error);
|
|
|
|
|
return pta;
|
|
|
|
|
}
|
|
|
|
|
void free_row(char **pta) {
|
|
|
|
|
int i;
|
|
|
|
|
for (i=0;i<10;i++) {
|
|
|
|
|
assert(pta[i]);
|
|
|
|
|
free(pta[i]);
|
|
|
|
|
}
|
|
|
|
|
free(pta);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
//static struct ev_async * gtid_ev_async;
|
|
|
|
|
|
|
|
|
|
static pthread_mutex_t ev_loop_mutex;
|
|
|
|
|
@ -1910,53 +1808,6 @@ bool MySQL_HostGroups_Manager::commit(
|
|
|
|
|
SpookyHash myhash;
|
|
|
|
|
char buf[80];
|
|
|
|
|
bool init = false;
|
|
|
|
|
/* removing all this code, because we need them ordered
|
|
|
|
|
MySrvC *mysrvc=NULL;
|
|
|
|
|
for (unsigned int i=0; i<MyHostGroups->len; i++) {
|
|
|
|
|
MyHGC *myhgc=(MyHGC *)MyHostGroups->index(i);
|
|
|
|
|
for (unsigned int j=0; j<myhgc->mysrvs->servers->len; j++) {
|
|
|
|
|
if (init == false) {
|
|
|
|
|
init = true;
|
|
|
|
|
myhash.Init(19,3);
|
|
|
|
|
}
|
|
|
|
|
mysrvc=myhgc->mysrvs->idx(j);
|
|
|
|
|
// hostgroup
|
|
|
|
|
sprintf(buf,"%u",mysrvc->myhgc->hid);
|
|
|
|
|
myhash.Update(buf,strlen(buf));
|
|
|
|
|
// hoatname
|
|
|
|
|
if (mysrvc->address) {
|
|
|
|
|
myhash.Update(mysrvc->address,strlen(mysrvc->address));
|
|
|
|
|
} else { myhash.Update("",0); }
|
|
|
|
|
// port
|
|
|
|
|
sprintf(buf,"%u",mysrvc->port);
|
|
|
|
|
myhash.Update(buf,strlen(buf));
|
|
|
|
|
// status
|
|
|
|
|
sprintf(buf,"%u",mysrvc->status);
|
|
|
|
|
myhash.Update(buf,strlen(buf));
|
|
|
|
|
// weight
|
|
|
|
|
sprintf(buf,"%u",mysrvc->weight);
|
|
|
|
|
myhash.Update(buf,strlen(buf));
|
|
|
|
|
// compression
|
|
|
|
|
sprintf(buf,"%u",mysrvc->compression);
|
|
|
|
|
myhash.Update(buf,strlen(buf));
|
|
|
|
|
// max_connections
|
|
|
|
|
sprintf(buf,"%u",mysrvc->max_connections);
|
|
|
|
|
myhash.Update(buf,strlen(buf));
|
|
|
|
|
// max_replication_lag
|
|
|
|
|
sprintf(buf,"%u",mysrvc->max_replication_lag);
|
|
|
|
|
myhash.Update(buf,strlen(buf));
|
|
|
|
|
// use_ssl
|
|
|
|
|
sprintf(buf,"%u",mysrvc->use_ssl);
|
|
|
|
|
myhash.Update(buf,strlen(buf));
|
|
|
|
|
// max_latency_ms
|
|
|
|
|
sprintf(buf,"%u",mysrvc->max_latency_us);
|
|
|
|
|
myhash.Update(buf,strlen(buf));
|
|
|
|
|
if (mysrvc->comment) {
|
|
|
|
|
myhash.Update(mysrvc->comment,strlen(mysrvc->comment));
|
|
|
|
|
} else { myhash.Update("",0); }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
{
|
|
|
|
|
mydb->execute("DELETE FROM mysql_servers");
|
|
|
|
|
generate_mysql_servers_table();
|
|
|
|
|
|