|
|
@ -988,3 +988,49 @@ void raptor_sm_terminate_server(char* username) {
|
|
|
|
free(command_string);
|
|
|
|
free(command_string);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void raptor_sm_stats_report_server_start(char* hostname) {
|
|
|
|
|
|
|
|
MYSQL_RES *res;
|
|
|
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
|
|
|
char* query;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MYSQL *conn = connect_if_needed();
|
|
|
|
|
|
|
|
if (!conn) {
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Insert information into the statistics database
|
|
|
|
|
|
|
|
char* safe_servername = get_mysql_escaped_string(conn, hostname);
|
|
|
|
|
|
|
|
long long timestamp = time(NULL);
|
|
|
|
|
|
|
|
asprintf(&query, "INSERT INTO statistics (timestamp, eventtypeid, servername, display, typeid) VALUES ('%lld', '%d', '%s', '%d', '%d')", timestamp, STATISTICS_SERVER_START_EVENT, safe_servername, -1, -1);
|
|
|
|
|
|
|
|
free(safe_servername);
|
|
|
|
|
|
|
|
if (mysql_query_internal(conn, query)) {
|
|
|
|
|
|
|
|
// Server error
|
|
|
|
|
|
|
|
dprint("Unable to insert data into statistics database! [%s]\n\r", mysql_error(conn));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
free(query);
|
|
|
|
|
|
|
|
mysql_close(conn);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void raptor_sm_stats_report_server_stop(char* hostname) {
|
|
|
|
|
|
|
|
MYSQL_RES *res;
|
|
|
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
|
|
|
char* query;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MYSQL *conn = connect_if_needed();
|
|
|
|
|
|
|
|
if (!conn) {
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Insert information into the statistics database
|
|
|
|
|
|
|
|
char* safe_servername = get_mysql_escaped_string(conn, hostname);
|
|
|
|
|
|
|
|
long long timestamp = time(NULL);
|
|
|
|
|
|
|
|
asprintf(&query, "INSERT INTO statistics (timestamp, eventtypeid, servername, display, typeid) VALUES ('%lld', '%d', '%s', '%d', '%d')", timestamp, STATISTICS_SERVER_STOP_EVENT, safe_servername, -1, -1);
|
|
|
|
|
|
|
|
free(safe_servername);
|
|
|
|
|
|
|
|
if (mysql_query_internal(conn, query)) {
|
|
|
|
|
|
|
|
// Server error
|
|
|
|
|
|
|
|
dprint("Unable to insert data into statistics database! [%s]\n\r", mysql_error(conn));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
free(query);
|
|
|
|
|
|
|
|
mysql_close(conn);
|
|
|
|
|
|
|
|
}
|