Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
	char *conf_filename;
	char file_id[128];
	int result;
	FDFSFileInfo file_info;
	
	if (argc < 3)
	{
		printf("Usage: %s <config_file> <file_id>\n", argv[0]);
		return 1;
	}

	log_init();
	g_log_context.log_level = LOG_ERR;
	ignore_signal_pipe();

	conf_filename = argv[1];
	if ((result=fdfs_client_init(conf_filename)) != 0)
	{
		return result;
	}

	snprintf(file_id, sizeof(file_id), "%s", argv[2]);
	memset(&file_info, 0, sizeof(file_info));
	result = fdfs_get_file_info_ex1(file_id, true, &file_info);
	if (result != 0)
	{
		printf("query file info fail, " \
			"error no: %d, error info: %s\n", \
			result, STRERROR(result));
	}
	else
	{
		char szDatetime[32];

		printf("source storage id: %d\n", file_info.source_id);
		printf("source ip address: %s\n", file_info.source_ip_addr);
		printf("file create timestamp: %s\n", formatDatetime(
			file_info.create_timestamp, "%Y-%m-%d %H:%M:%S", \
			szDatetime, sizeof(szDatetime)));
		printf("file size: %"PRId64"\n", \
			file_info.file_size);
		printf("file crc32: %u (0x%08X)\n", \
			file_info.crc32, file_info.crc32);
	}

	tracker_close_all_connections();
	fdfs_client_destroy();

	return 0;
}
Ejemplo n.º 2
0
int fdfs_dump_storage_global_vars_to_file(const char *filename)
{
	char buff[4 * 1024];
	char szCurrentTime[32];
	int len;
	int result;
	int fd;

	fd = open(filename, O_WRONLY | O_CREAT | O_APPEND, 0644);
	if (fd < 0)
	{
		logError("file: "__FILE__", line: %d, "
			"open file %s fail, errno: %d, error info: %s",
			__LINE__, filename, errno, STRERROR(errno));
		return errno;
	}

	do
	{
		result = 0;
		formatDatetime(g_current_time, "%Y-%m-%d %H:%M:%S", 
				szCurrentTime, sizeof(szCurrentTime));

		len = sprintf(buff, "\n====time: %s  DUMP START====\n", 
				szCurrentTime);
		WRITE_TO_FILE(fd, buff, len)

		len = fdfs_dump_global_vars(buff, sizeof(buff));
		WRITE_TO_FILE(fd, buff, len)

		len = fdfs_dump_tracker_servers(buff, sizeof(buff));
		WRITE_TO_FILE(fd, buff, len)

		len = fdfs_dump_storage_stat(buff, sizeof(buff));
		WRITE_TO_FILE(fd, buff, len)

		len = fdfs_dump_storage_servers(buff, sizeof(buff));
		WRITE_TO_FILE(fd, buff, len)

		len = sprintf(buff, "\n====time: %s  DUMP END====\n\n", 
				szCurrentTime);
		WRITE_TO_FILE(fd, buff, len)
	} while(0);

	close(fd);

	return result;
}
Ejemplo n.º 3
0
static int fdht_write_to_db_recovery_mark_file(const time_t timestamp, \
		const int binlog_index, const int64_t binlog_offset, \
		const int written_pages, const int time_used_ms)
{
	char buff[256];
	char date_buff[32];
	int len;

	len = sprintf(buff, \
		"%s=%d\n"  \
		"%s=%"PRId64"\n"  \
		"%s=%d\n"  \
		"%s=%s\n"  \
		"%s=%d ms\n",  \
		MARK_ITEM_BINLOG_FILE_INDEX, binlog_index, \
		MARK_ITEM_BINLOG_FILE_OFFSET, binlog_offset, \
		MARK_ITEM_WRITTEN_PAGES, written_pages, \
		MARK_ITEM_START_TIME, formatDatetime(timestamp, \
			"%Y-%m-%d %H:%M:%S", date_buff, sizeof(date_buff)), \
		MARK_ITEM_SYNC_TIME_USED, time_used_ms);

	return fdht_write_to_fd(fdht_db_recovery_mark_fd, \
			fdht_get_db_recovery_mark_filename, NULL, buff, len);
}
Ejemplo n.º 4
0
static int fdfs_dump_storage_servers(char *buff, const int buffSize)
{
	int total_len;
	char szLastSyncSrcTimestamp[32];
	FDFSStorageServer *pServer;
	FDFSStorageServer *pServerEnd;
	FDFSStorageServer **ppServer;
	FDFSStorageServer **ppServerEnd;

	total_len = snprintf(buff, buffSize,
			"\ng_storage_count=%d\n", g_storage_count);
	pServerEnd = g_storage_servers + g_storage_count;
	for (pServer=g_storage_servers; pServer<pServerEnd; pServer++)
	{
		total_len += snprintf(buff + total_len, buffSize - total_len,
			"\t%d. server: %s, status: %d, sync timestamp: %s\n", 
			(int)(pServer - g_storage_servers) + 1, 
			pServer->server.ip_addr, pServer->server.status,
			formatDatetime(pServer->last_sync_src_timestamp, 
				"%Y-%m-%d %H:%M:%S", szLastSyncSrcTimestamp, 
				sizeof(szLastSyncSrcTimestamp)));
	}

	total_len += snprintf(buff + total_len, buffSize - total_len,
			"sorted storage servers:\n");
	ppServerEnd = g_sorted_storages + g_storage_count;
	for (ppServer=g_sorted_storages; ppServer<ppServerEnd; ppServer++)
	{
		total_len += snprintf(buff + total_len, buffSize - total_len,
			"\t%d. server: %s\n", 
			(int)(ppServer - g_sorted_storages) + 1, 
			(*ppServer)->server.ip_addr);
	}

	return total_len;
}
Ejemplo n.º 5
0
static int list_storages(FDFSGroupStat *pGroupStat)
{
	int result;
	int storage_count;
	FDFSStorageInfo storage_infos[FDFS_MAX_SERVERS_EACH_GROUP];
	FDFSStorageInfo *p;
	FDFSStorageInfo *pStorage;
	FDFSStorageInfo *pStorageEnd;
	FDFSStorageStat *pStorageStat;
	char szJoinTime[32];
	char szUpTime[32];
	char szLastHeartBeatTime[32];
	char szSrcUpdTime[32];
	char szSyncUpdTime[32];
	char szSyncedTimestamp[32];
	char szSyncedDelaySeconds[128];
	char szHostname[128];
	char szHostnamePrompt[128+8];
	int k;
	int max_last_source_update;

	printf( "group name = %s\n" \
		"disk total space = %"PRId64" MB\n" \
		"disk free space = %"PRId64" MB\n" \
		"trunk free space = %"PRId64" MB\n" \
		"storage server count = %d\n" \
		"active server count = %d\n" \
		"storage server port = %d\n" \
		"storage HTTP port = %d\n" \
		"store path count = %d\n" \
		"subdir count per path = %d\n" \
		"current write server index = %d\n" \
		"current trunk file id = %d\n\n", \
		pGroupStat->group_name, \
		pGroupStat->total_mb, \
		pGroupStat->free_mb, \
		pGroupStat->trunk_free_mb, \
		pGroupStat->count, \
		pGroupStat->active_count, \
		pGroupStat->storage_port, \
		pGroupStat->storage_http_port, \
		pGroupStat->store_path_count, \
		pGroupStat->subdir_count_per_path, \
		pGroupStat->current_write_server, \
		pGroupStat->current_trunk_file_id
	);

	result = tracker_list_servers(pTrackerServer, \
		pGroupStat->group_name, NULL, \
		storage_infos, FDFS_MAX_SERVERS_EACH_GROUP, \
		&storage_count);
	if (result != 0)
	{
		return result;
	}

	k = 0;
	pStorageEnd = storage_infos + storage_count;
	for (pStorage=storage_infos; pStorage<pStorageEnd; \
		pStorage++)
	{
		max_last_source_update = 0;
		for (p=storage_infos; p<pStorageEnd; p++)
		{
			if (p != pStorage && p->stat.last_source_update
				> max_last_source_update)
			{
				max_last_source_update = \
					p->stat.last_source_update;
			}
		}

		pStorageStat = &(pStorage->stat);
		if (max_last_source_update == 0)
		{
			*szSyncedDelaySeconds = '\0';
		}
		else
		{
			if (pStorageStat->last_synced_timestamp == 0)
			{
				strcpy(szSyncedDelaySeconds, "(never synced)");
			}
			else
			{
			int delay_seconds;
			int remain_seconds;
			int day;
			int hour;
			int minute;
			int second;
			char szDelayTime[64];
			
			delay_seconds = (int)(max_last_source_update - \
				pStorageStat->last_synced_timestamp);
			day = delay_seconds / (24 * 3600);
			remain_seconds = delay_seconds % (24 * 3600);
			hour = remain_seconds / 3600;
			remain_seconds %= 3600;
			minute = remain_seconds / 60;
			second = remain_seconds % 60;

			if (day != 0)
			{
				sprintf(szDelayTime, "%d days " \
					"%02dh:%02dm:%02ds", \
					day, hour, minute, second);
			}
			else if (hour != 0)
			{
				sprintf(szDelayTime, "%02dh:%02dm:%02ds", \
					hour, minute, second);
			}
			else if (minute != 0)
			{
				sprintf(szDelayTime, "%02dm:%02ds", minute, second);
			}
			else
			{
				sprintf(szDelayTime, "%ds", second);
			}

			sprintf(szSyncedDelaySeconds, "(%s delay)", szDelayTime);
			}
		}

		getHostnameByIp(pStorage->ip_addr, szHostname, sizeof(szHostname));
		if (*szHostname != '\0')
		{
			sprintf(szHostnamePrompt, " (%s)", szHostname);
		}
		else
		{
			*szHostnamePrompt = '\0';
		}

		if (pStorage->up_time != 0)
		{
			formatDatetime(pStorage->up_time, \
				"%Y-%m-%d %H:%M:%S", \
				szUpTime, sizeof(szUpTime));
		}
		else
		{
			*szUpTime = '\0';
		}

		printf( "\tStorage %d:\n" \
			"\t\tid = %s\n" \
			"\t\tip_addr = %s%s  %s\n" \
			"\t\thttp domain = %s\n" \
			"\t\tversion = %s\n" \
			"\t\tjoin time = %s\n" \
			"\t\tup time = %s\n" \
			"\t\ttotal storage = %d MB\n" \
			"\t\tfree storage = %d MB\n" \
			"\t\tupload priority = %d\n" \
			"\t\tstore_path_count = %d\n" \
			"\t\tsubdir_count_per_path = %d\n" \
			"\t\tstorage_port = %d\n" \
			"\t\tstorage_http_port = %d\n" \
			"\t\tcurrent_write_path = %d\n" \
			"\t\tsource storage id= %s\n" \
			"\t\tif_trunk_server= %d\n" \
			"\t\ttotal_upload_count = %"PRId64"\n"   \
			"\t\tsuccess_upload_count = %"PRId64"\n" \
			"\t\ttotal_append_count = %"PRId64"\n"   \
			"\t\tsuccess_append_count = %"PRId64"\n" \
			"\t\ttotal_modify_count = %"PRId64"\n"   \
			"\t\tsuccess_modify_count = %"PRId64"\n" \
			"\t\ttotal_truncate_count = %"PRId64"\n"   \
			"\t\tsuccess_truncate_count = %"PRId64"\n" \
			"\t\ttotal_set_meta_count = %"PRId64"\n" \
			"\t\tsuccess_set_meta_count = %"PRId64"\n" \
			"\t\ttotal_delete_count = %"PRId64"\n" \
			"\t\tsuccess_delete_count = %"PRId64"\n" \
			"\t\ttotal_download_count = %"PRId64"\n" \
			"\t\tsuccess_download_count = %"PRId64"\n" \
			"\t\ttotal_get_meta_count = %"PRId64"\n" \
			"\t\tsuccess_get_meta_count = %"PRId64"\n" \
			"\t\ttotal_create_link_count = %"PRId64"\n" \
			"\t\tsuccess_create_link_count = %"PRId64"\n"\
			"\t\ttotal_delete_link_count = %"PRId64"\n" \
			"\t\tsuccess_delete_link_count = %"PRId64"\n" \
			"\t\ttotal_upload_bytes = %"PRId64"\n" \
			"\t\tsuccess_upload_bytes = %"PRId64"\n" \
			"\t\ttotal_append_bytes = %"PRId64"\n" \
			"\t\tsuccess_append_bytes = %"PRId64"\n" \
			"\t\ttotal_modify_bytes = %"PRId64"\n" \
			"\t\tsuccess_modify_bytes = %"PRId64"\n" \
			"\t\tstotal_download_bytes = %"PRId64"\n" \
			"\t\tsuccess_download_bytes = %"PRId64"\n" \
			"\t\ttotal_sync_in_bytes = %"PRId64"\n" \
			"\t\tsuccess_sync_in_bytes = %"PRId64"\n" \
			"\t\ttotal_sync_out_bytes = %"PRId64"\n" \
			"\t\tsuccess_sync_out_bytes = %"PRId64"\n" \
			"\t\ttotal_file_open_count = %"PRId64"\n" \
			"\t\tsuccess_file_open_count = %"PRId64"\n" \
			"\t\ttotal_file_read_count = %"PRId64"\n" \
			"\t\tsuccess_file_read_count = %"PRId64"\n" \
			"\t\ttotal_file_write_count = %"PRId64"\n" \
			"\t\tsuccess_file_write_count = %"PRId64"\n" \
			"\t\tlast_heart_beat_time = %s\n" \
			"\t\tlast_source_update = %s\n" \
			"\t\tlast_sync_update = %s\n"   \
			"\t\tlast_synced_timestamp = %s %s\n",  \
			++k, pStorage->id, pStorage->ip_addr, \
			szHostnamePrompt, get_storage_status_caption( \
			    pStorage->status), pStorage->domain_name, \
			pStorage->version,  \
			formatDatetime(pStorage->join_time, \
				"%Y-%m-%d %H:%M:%S", \
				szJoinTime, sizeof(szJoinTime)), \
			szUpTime, pStorage->total_mb, \
			pStorage->free_mb,  \
			pStorage->upload_priority,  \
			pStorage->store_path_count,  \
			pStorage->subdir_count_per_path,  \
			pStorage->storage_port,  \
			pStorage->storage_http_port,  \
			pStorage->current_write_path,  \
			pStorage->src_id,  \
			pStorage->if_trunk_server,  \
			pStorageStat->total_upload_count, \
			pStorageStat->success_upload_count, \
			pStorageStat->total_append_count, \
			pStorageStat->success_append_count, \
			pStorageStat->total_modify_count, \
			pStorageStat->success_modify_count, \
			pStorageStat->total_truncate_count, \
			pStorageStat->success_truncate_count, \
			pStorageStat->total_set_meta_count, \
			pStorageStat->success_set_meta_count, \
			pStorageStat->total_delete_count, \
			pStorageStat->success_delete_count, \
			pStorageStat->total_download_count, \
			pStorageStat->success_download_count, \
			pStorageStat->total_get_meta_count, \
			pStorageStat->success_get_meta_count, \
			pStorageStat->total_create_link_count, \
			pStorageStat->success_create_link_count, \
			pStorageStat->total_delete_link_count, \
			pStorageStat->success_delete_link_count, \
			pStorageStat->total_upload_bytes, \
			pStorageStat->success_upload_bytes, \
			pStorageStat->total_append_bytes, \
			pStorageStat->success_append_bytes, \
			pStorageStat->total_modify_bytes, \
			pStorageStat->success_modify_bytes, \
			pStorageStat->total_download_bytes, \
			pStorageStat->success_download_bytes, \
			pStorageStat->total_sync_in_bytes, \
			pStorageStat->success_sync_in_bytes, \
			pStorageStat->total_sync_out_bytes, \
			pStorageStat->success_sync_out_bytes, \
			pStorageStat->total_file_open_count, \
			pStorageStat->success_file_open_count, \
			pStorageStat->total_file_read_count, \
			pStorageStat->success_file_read_count, \
			pStorageStat->total_file_write_count, \
			pStorageStat->success_file_write_count, \
			formatDatetime(pStorageStat->last_heart_beat_time, \
				"%Y-%m-%d %H:%M:%S", \
				szLastHeartBeatTime, sizeof(szLastHeartBeatTime)), \
			formatDatetime(pStorageStat->last_source_update, \
				"%Y-%m-%d %H:%M:%S", \
				szSrcUpdTime, sizeof(szSrcUpdTime)), \
			formatDatetime(pStorageStat->last_sync_update, \
				"%Y-%m-%d %H:%M:%S", \
				szSyncUpdTime, sizeof(szSyncUpdTime)), \
			formatDatetime(pStorageStat->last_synced_timestamp, \
				"%Y-%m-%d %H:%M:%S", \
				szSyncedTimestamp, sizeof(szSyncedTimestamp)),\
			szSyncedDelaySeconds);
	}

	return 0;
}
Ejemplo n.º 6
0
int fdfs_dump_tracker_global_vars_to_file(const char *filename)
{
	char buff[16 * 1024];
	char szCurrentTime[32];
	int len;
	int result;
	int fd;
	FDFSGroupInfo **ppGroup;
	FDFSGroupInfo **ppGroupEnd;

	fd = open(filename, O_WRONLY | O_CREAT | O_APPEND, 0644);
	if (fd < 0)
	{
		logError("file: "__FILE__", line: %d, "
			"open file %s fail, errno: %d, error info: %s",
			__LINE__, filename, errno, STRERROR(errno));
		return errno;
	}

	do
	{
		result = 0;
		formatDatetime(g_current_time, "%Y-%m-%d %H:%M:%S", 
				szCurrentTime, sizeof(szCurrentTime));

		len = sprintf(buff, "\n====time: %s  DUMP START====\n", 
				szCurrentTime);
		WRITE_TO_FILE(fd, buff, len)

		len = fdfs_dump_global_vars(buff, sizeof(buff));
		WRITE_TO_FILE(fd, buff, len)

		len = fdfs_dump_tracker_servers(buff, sizeof(buff));
		WRITE_TO_FILE(fd, buff, len)

		len = fdfs_dump_groups_info(buff, sizeof(buff));
		WRITE_TO_FILE(fd, buff, len)

		len = sprintf(buff, "\ngroup name list:\n");
		WRITE_TO_FILE(fd, buff, len)
		len = 0;
		ppGroupEnd = g_groups.groups + g_groups.count;
		for (ppGroup=g_groups.groups; ppGroup<ppGroupEnd; ppGroup++)
		{
			len += sprintf(buff+len, "\t%s\n", (*ppGroup)->group_name);
		}
		len += sprintf(buff+len, "\n");
		WRITE_TO_FILE(fd, buff, len)

		ppGroupEnd = g_groups.sorted_groups + g_groups.count;
		for (ppGroup=g_groups.sorted_groups; ppGroup<ppGroupEnd; ppGroup++)
		{
			len = sprintf(buff, "\nGroup %d.\n", 
				(int)(ppGroup - g_groups.sorted_groups) + 1);
			WRITE_TO_FILE(fd, buff, len)

			len = fdfs_dump_group_stat(*ppGroup, buff, sizeof(buff));
			WRITE_TO_FILE(fd, buff, len)
		}

		len = sprintf(buff, "\n====time: %s  DUMP END====\n\n", 
				szCurrentTime);
		WRITE_TO_FILE(fd, buff, len)
	} while(0);

	close(fd);

	return result;
}
Ejemplo n.º 7
0
static int fdfs_dump_group_stat(FDFSGroupInfo *pGroup, char *buff, const int buffSize)
{
	char szLastSourceUpdate[32];
	char szLastSyncUpdate[32];
	char szSyncedTimestamp[32];
	int total_len;
	FDFSStorageDetail **ppServer;
	FDFSStorageDetail **ppServerEnd;
	int i;
	int j;

	total_len = snprintf(buff, buffSize, 
		"group_name=%s\n"
		"total_mb="INT64_PRINTF_FORMAT"\n"
		"free_mb="INT64_PRINTF_FORMAT"\n"
		"alloc_size=%d\n"
		"server count=%d\n"
		"active server count=%d\n"
		"storage_port=%d\n"
		"storage_http_port=%d\n"
		"current_read_server=%d\n"
		"current_write_server=%d\n"
		"store_path_count=%d\n"
		"subdir_count_per_path=%d\n" 
		"current_trunk_file_id=%d\n"
		"pStoreServer=%s\n" 
		"pTrunkServer=%s\n" 
		"last_trunk_server_id=%s\n" 
		"chg_count=%d\n"
		"trunk_chg_count=%d\n"
		"last_source_update=%s\n"
		"last_sync_update=%s\n",
		pGroup->group_name, 
		pGroup->total_mb, 
		pGroup->free_mb, 
		pGroup->alloc_size, 
		pGroup->count, 
		pGroup->active_count, 
		pGroup->storage_port,
		pGroup->storage_http_port, 
		pGroup->current_read_server, 
		pGroup->current_write_server, 
		pGroup->store_path_count,
		pGroup->subdir_count_per_path,
		pGroup->current_trunk_file_id,
		pGroup->pStoreServer != NULL ? pGroup->pStoreServer->ip_addr : "",
		pGroup->pTrunkServer != NULL ? pGroup->pTrunkServer->ip_addr : "",
		pGroup->last_trunk_server_id,
		pGroup->chg_count,
		pGroup->trunk_chg_count,
		formatDatetime(pGroup->last_source_update, 
			"%Y-%m-%d %H:%M:%S", 
			szLastSourceUpdate, sizeof(szLastSourceUpdate)),
		formatDatetime(pGroup->last_sync_update, 
			"%Y-%m-%d %H:%M:%S", 
			szLastSyncUpdate, sizeof(szLastSyncUpdate))
	);

	total_len += snprintf(buff + total_len, buffSize - total_len, 
		"total server count=%d\n", pGroup->count);
	ppServerEnd = pGroup->all_servers + pGroup->count;
	for (ppServer=pGroup->all_servers; ppServer<ppServerEnd; ppServer++)
	{
		total_len += snprintf(buff + total_len, buffSize - total_len, 
			"\t%s\n", (*ppServer)->ip_addr);
	}

	total_len += snprintf(buff + total_len, buffSize - total_len, 
		"\nactive server count=%d\n", pGroup->active_count);
	ppServerEnd = pGroup->active_servers + pGroup->active_count;
	for (ppServer=pGroup->active_servers; ppServer<ppServerEnd; ppServer++)
	{
		total_len += snprintf(buff + total_len, buffSize - total_len, 
			"\t%s\n", (*ppServer)->ip_addr);
	}

#ifdef WITH_HTTPD
	total_len += snprintf(buff + total_len, buffSize - total_len, 
		"\nhttp active server count=%d\n"
		"current_http_server=%d\n", 
		pGroup->http_server_count,
		pGroup->current_http_server);

	ppServerEnd = pGroup->http_servers + pGroup->http_server_count;
	for (ppServer=pGroup->http_servers; ppServer<ppServerEnd; ppServer++)
	{
		total_len += snprintf(buff + total_len, buffSize - total_len, 
			"\t%s\n", (*ppServer)->ip_addr);
	}
#endif

	ppServerEnd = pGroup->sorted_servers + pGroup->count;
	for (ppServer=pGroup->sorted_servers; ppServer<ppServerEnd; ppServer++)
	{
		total_len += snprintf(buff + total_len, buffSize - total_len, 
				"\nHost %d.\n", 
				(int)(ppServer - pGroup->sorted_servers) + 1);
		total_len += fdfs_dump_storage_stat(*ppServer, buff + total_len,
				 buffSize - total_len);
	}

	total_len += snprintf(buff + total_len, buffSize - total_len, 
			"\nsynced timestamp table:\n");
	for (i=0; i<pGroup->count; i++)
	{
	for (j=0; j<pGroup->count; j++)
	{
		if (i == j)
		{
			continue;
		}

		total_len += snprintf(buff + total_len, buffSize - total_len, 
				"\t%s => %s: %s\n", 
				pGroup->all_servers[i]->ip_addr, 
				pGroup->all_servers[j]->ip_addr,
				formatDatetime(pGroup->last_sync_timestamps[i][j],
					"%Y-%m-%d %H:%M:%S", 
					szSyncedTimestamp, 
					sizeof(szSyncedTimestamp))
				);
	}
	}

	total_len += snprintf(buff + total_len, buffSize - total_len, 
			"\n\n");
	return total_len;
}
Ejemplo n.º 8
0
static int fdfs_dump_storage_stat(FDFSStorageDetail *pServer, 
		char *buff, const int buffSize)
{
	char szJoinTime[32];
	char szUpTime[32];
	char szLastHeartBeatTime[32];
	char szSrcUpdTime[32];
	char szSyncUpdTime[32];
	char szSyncedTimestamp[32];
	char szSyncUntilTimestamp[32];
	int i;
	int total_len;

	total_len = snprintf(buff, buffSize, 
		"ip_addr=%s\n"
		"version=%s\n"
		"status=%d\n"
		"domain_name=%s\n"
		"sync_src_server=%s\n"
		"sync_until_timestamp=%s\n"
		"join_time=%s\n"
		"up_time=%s\n"
		"total_mb="INT64_PRINTF_FORMAT" MB\n"
		"free_mb="INT64_PRINTF_FORMAT" MB\n"
		"changelog_offset="INT64_PRINTF_FORMAT"\n"
		"store_path_count=%d\n"
		"storage_port=%d\n"
		"storage_http_port=%d\n"
		"subdir_count_per_path=%d\n"
		"upload_priority=%d\n"
		"current_write_path=%d\n"
		"chg_count=%d\n"
#ifdef WITH_HTTPD
		"http_check_last_errno=%d\n"
		"http_check_last_status=%d\n"
		"http_check_fail_count=%d\n"
		"http_check_error_info=%s\n"
#endif

		"total_upload_count="INT64_PRINTF_FORMAT"\n"
		"success_upload_count="INT64_PRINTF_FORMAT"\n"
		"total_set_meta_count="INT64_PRINTF_FORMAT"\n"
		"success_set_meta_count="INT64_PRINTF_FORMAT"\n"
		"total_delete_count="INT64_PRINTF_FORMAT"\n"
		"success_delete_count="INT64_PRINTF_FORMAT"\n"
		"total_download_count="INT64_PRINTF_FORMAT"\n"
		"success_download_count="INT64_PRINTF_FORMAT"\n"
		"total_get_meta_count="INT64_PRINTF_FORMAT"\n"
		"success_get_meta_count="INT64_PRINTF_FORMAT"\n"
		"total_create_link_count="INT64_PRINTF_FORMAT"\n"
		"success_create_link_count="INT64_PRINTF_FORMAT"\n"
		"total_delete_link_count="INT64_PRINTF_FORMAT"\n"
		"success_delete_link_count="INT64_PRINTF_FORMAT"\n"
		"last_source_update=%s\n"
		"last_sync_update=%s\n"
		"last_synced_timestamp=%s\n"
		"last_heart_beat_time=%s\n",
		pServer->ip_addr, 
		pServer->version, 
		pServer->status, 
		pServer->domain_name, 
		pServer->psync_src_server != NULL ? 
		pServer->psync_src_server->ip_addr : "", 
		formatDatetime(pServer->sync_until_timestamp, 
			"%Y-%m-%d %H:%M:%S", 
			szSyncUntilTimestamp, sizeof(szSyncUntilTimestamp)),
		formatDatetime(pServer->join_time, 
			"%Y-%m-%d %H:%M:%S", 
			szJoinTime, sizeof(szJoinTime)),
		formatDatetime(pServer->up_time, 
			"%Y-%m-%d %H:%M:%S", 
			szUpTime, sizeof(szUpTime)),
		pServer->total_mb,
		pServer->free_mb, 
		pServer->changelog_offset, 
		pServer->store_path_count, 
		pServer->storage_port, 
		pServer->storage_http_port, 
		pServer->subdir_count_per_path, 
		pServer->upload_priority,
		pServer->current_write_path,
		pServer->chg_count,
#ifdef WITH_HTTPD
		pServer->http_check_last_errno,
		pServer->http_check_last_status,
		pServer->http_check_fail_count,
		pServer->http_check_error_info,
#endif
		pServer->stat.total_upload_count,
		pServer->stat.success_upload_count,
		pServer->stat.total_set_meta_count,
		pServer->stat.success_set_meta_count,
		pServer->stat.total_delete_count,
		pServer->stat.success_delete_count,
		pServer->stat.total_download_count,
		pServer->stat.success_download_count,
		pServer->stat.total_get_meta_count,
		pServer->stat.success_get_meta_count,
		pServer->stat.total_create_link_count,
		pServer->stat.success_create_link_count,
		pServer->stat.total_delete_link_count,
		pServer->stat.success_delete_link_count,
		formatDatetime(pServer->stat.last_source_update, 
			"%Y-%m-%d %H:%M:%S", 
			szSrcUpdTime, sizeof(szSrcUpdTime)), 
		formatDatetime(pServer->stat.last_sync_update,
			"%Y-%m-%d %H:%M:%S", 
			szSyncUpdTime, sizeof(szSyncUpdTime)), 
		formatDatetime(pServer->stat.last_synced_timestamp, 
			"%Y-%m-%d %H:%M:%S", 
			szSyncedTimestamp, sizeof(szSyncedTimestamp)),
		formatDatetime(pServer->stat.last_heart_beat_time,
			"%Y-%m-%d %H:%M:%S", 
			szLastHeartBeatTime, sizeof(szLastHeartBeatTime))
	);

	for (i=0; i<pServer->store_path_count; i++)
	{
		total_len += snprintf(buff + total_len, buffSize - total_len, 
			"disk %d: total_mb="INT64_PRINTF_FORMAT" MB, "
			"free_mb="INT64_PRINTF_FORMAT" MB\n",
			i+1, pServer->path_total_mbs[i],
			pServer->path_free_mbs[i]);
	}

	return total_len;
}
Ejemplo n.º 9
0
int main(int argc, char *argv[])
{
	char *conf_filename;
	char *local_filename;
	ConnectionInfo *pTrackerServer;
	ConnectionInfo *pStorageServer;
	int result;
	ConnectionInfo storageServer;
	char group_name[FDFS_GROUP_NAME_MAX_LEN + 1];
	char file_id[256];
	char appender_file_id[256];
	FDFSMetaData meta_list[32];
	int meta_count;
	char token[32 + 1];
	char file_url[256];
	char szDatetime[20];
	char szPortPart[16];
	int url_len;
	time_t ts;
	int64_t file_offset;
	int64_t file_size = 0;
	int store_path_index;
	FDFSFileInfo file_info;
	int upload_type;
	const char *file_ext_name;
	struct stat stat_buf;

	printf("This is FastDFS client test program v%d.%02d\n" \
"\nCopyright (C) 2008, Happy Fish / YuQing\n" \
"\nFastDFS may be copied only under the terms of the GNU General\n" \
"Public License V3, which may be found in the FastDFS source kit.\n" \
"Please visit the FastDFS Home Page http://www.csource.org/ \n" \
"for more detail.\n\n" \
, g_fdfs_version.major, g_fdfs_version.minor);

	if (argc < 3)
	{
		printf("Usage: %s <config_file> <local_filename> " \
			"[FILE | BUFF | CALLBACK]\n", argv[0]);
		return 1;
	}

	log_init();
	g_log_context.log_level = LOG_DEBUG;

	conf_filename = argv[1];
	if ((result=fdfs_client_init(conf_filename)) != 0)
	{
		return result;
	}

	pTrackerServer = tracker_get_connection();
	if (pTrackerServer == NULL)
	{
		fdfs_client_destroy();
		return errno != 0 ? errno : ECONNREFUSED;
	}

	local_filename = argv[2];
	if (argc == 3)
	{
		upload_type = FDFS_UPLOAD_BY_FILE;
	}
	else
	{
		if (strcmp(argv[3], "BUFF") == 0)
		{
			upload_type = FDFS_UPLOAD_BY_BUFF;
		}
		else if (strcmp(argv[3], "CALLBACK") == 0)
		{
			upload_type = FDFS_UPLOAD_BY_CALLBACK;
		}
		else
		{
			upload_type = FDFS_UPLOAD_BY_FILE;
		}
	}

	store_path_index = 0;
	*group_name = '\0';
	if ((result=tracker_query_storage_store(pTrackerServer, \
			&storageServer, group_name, &store_path_index)) != 0)
	{
		fdfs_client_destroy();
		printf("tracker_query_storage fail, " \
			"error no: %d, error info: %s\n", \
			result, STRERROR(result));
		return result;
	}

	printf("group_name=%s, ip_addr=%s, port=%d\n", \
		group_name, storageServer.ip_addr, \
		storageServer.port);

	if ((pStorageServer=tracker_connect_server(&storageServer, \
		&result)) == NULL)
	{
		fdfs_client_destroy();
		return result;
	}

	memset(&meta_list, 0, sizeof(meta_list));
	meta_count = 0;
	strcpy(meta_list[meta_count].name, "ext_name");
	strcpy(meta_list[meta_count].value, "jpg");
	meta_count++;
	strcpy(meta_list[meta_count].name, "width");
	strcpy(meta_list[meta_count].value, "160");
	meta_count++;
	strcpy(meta_list[meta_count].name, "height");
	strcpy(meta_list[meta_count].value, "80");
	meta_count++;
	strcpy(meta_list[meta_count].name, "file_size");
	strcpy(meta_list[meta_count].value, "115120");
	meta_count++;

	file_ext_name = fdfs_get_file_ext_name(local_filename);
	if (upload_type == FDFS_UPLOAD_BY_FILE)
	{
		if (stat(local_filename, &stat_buf) == 0 && \
				S_ISREG(stat_buf.st_mode))
		{
			file_size = stat_buf.st_size;
			result = storage_upload_appender_by_filename1( \
				pTrackerServer, pStorageServer, \
				store_path_index, local_filename, \
				file_ext_name, meta_list, meta_count, \
				group_name, file_id);
		}
		else
		{
			result = errno != 0 ? errno : ENOENT;
		}

		printf("storage_upload_appender_by_filename1\n");
	}
	else if (upload_type == FDFS_UPLOAD_BY_BUFF)
	{
		char *file_content;
		if ((result=getFileContent(local_filename, \
					&file_content, &file_size)) == 0)
		{
			result = storage_upload_appender_by_filebuff1( \
					pTrackerServer, pStorageServer, \
					store_path_index, file_content, \
					file_size, file_ext_name, \
					meta_list, meta_count, \
					group_name, file_id);
			free(file_content);
		}

		printf("storage_upload_appender_by_filebuff1\n");
	}
	else
	{
		if (stat(local_filename, &stat_buf) == 0 && \
				S_ISREG(stat_buf.st_mode))
		{
			file_size = stat_buf.st_size;
			result = storage_upload_appender_by_callback1( \
					pTrackerServer, pStorageServer, \
					store_path_index, uploadFileCallback, \
					local_filename, file_size, \
					file_ext_name, meta_list, meta_count, \
					group_name, file_id);
		}
		else
		{
			result = errno != 0 ? errno : ENOENT;
		}

		printf("storage_upload_appender_by_callback1\n");
	}

	if (result != 0)
	{
		printf("upload file fail, " \
			"error no: %d, error info: %s\n", \
			result, STRERROR(result));
		tracker_disconnect_server_ex(pStorageServer, true);
		fdfs_client_destroy();
		return result;
	}

	if (g_tracker_server_http_port == 80)
	{
		*szPortPart = '\0';
	}
	else
	{
		sprintf(szPortPart, ":%d", g_tracker_server_http_port);
	}

	url_len = sprintf(file_url, "http://%s%s/%s", \
			pTrackerServer->ip_addr, szPortPart, file_id);
	if (g_anti_steal_token)
	{
		ts = time(NULL);
		fdfs_http_gen_token(&g_anti_steal_secret_key, file_id, \
				ts, token);
		sprintf(file_url + url_len, "?token=%s&ts=%d", token, (int)ts);
	}

	printf("fild_id=%s\n", file_id);

	fdfs_get_file_info1(file_id, &file_info);
	printf("source ip address: %s\n", file_info.source_ip_addr);
	printf("file timestamp=%s\n", formatDatetime(
		file_info.create_timestamp, "%Y-%m-%d %H:%M:%S", \
		szDatetime, sizeof(szDatetime)));
	printf("file size="INT64_PRINTF_FORMAT"\n", file_info.file_size);
	printf("file crc32=%u\n", file_info.crc32);
	printf("file url: %s\n", file_url);


	strcpy(appender_file_id, file_id);
	if (storage_truncate_file1(pTrackerServer, pStorageServer, \
			appender_file_id, 0) != 0)
	{
		printf("truncate file fail, " \
			"error no: %d, error info: %s\n", \
			result, STRERROR(result));
		tracker_disconnect_server_ex(pStorageServer, true);
		fdfs_client_destroy();
		return result;
	}

	fdfs_get_file_info1(file_id, &file_info);
	printf("source ip address: %s\n", file_info.source_ip_addr);
	printf("file timestamp=%s\n", formatDatetime(
		file_info.create_timestamp, "%Y-%m-%d %H:%M:%S", \
		szDatetime, sizeof(szDatetime)));
	printf("file size="INT64_PRINTF_FORMAT"\n", file_info.file_size);
	printf("file crc32=%u\n", file_info.crc32);
	printf("file url: %s\n", file_url);
	if (file_info.file_size != 0)
	{
		fprintf(stderr, "file size: "INT64_PRINTF_FORMAT \
			" != 0!!!", file_info.file_size);
	}

	//sleep(70);
	if (upload_type == FDFS_UPLOAD_BY_FILE)
	{
		result = storage_append_by_filename1(pTrackerServer, \
				pStorageServer, local_filename, 
				appender_file_id);

		printf("storage_append_by_filename\n");
	}
	else if (upload_type == FDFS_UPLOAD_BY_BUFF)
	{
		char *file_content;
		if ((result=getFileContent(local_filename, \
				&file_content, &file_size)) == 0)
		{
			result = storage_append_by_filebuff1(pTrackerServer, \
				pStorageServer, file_content, \
				file_size, appender_file_id);
			free(file_content);
		}

		printf("storage_append_by_filebuff1\n");
	}
	else
	{
		if (stat(local_filename, &stat_buf) == 0 && \
			S_ISREG(stat_buf.st_mode))
		{
			file_size = stat_buf.st_size;
			result = storage_append_by_callback1(pTrackerServer, \
					pStorageServer, uploadFileCallback, \
					local_filename, file_size, \
					appender_file_id);
		}
		else
		{
			result = errno != 0 ? errno : ENOENT;
		}

		printf("storage_append_by_callback1\n");
	}

	if (result != 0)
	{
		printf("append file fail, " \
			"error no: %d, error info: %s\n", \
			result, STRERROR(result));
		tracker_disconnect_server_ex(pStorageServer, true);
		fdfs_client_destroy();
		return result;
	}
	printf("append file successfully.\n");
	fdfs_get_file_info1(appender_file_id, &file_info);
	printf("source ip address: %s\n", file_info.source_ip_addr);
	printf("file timestamp=%s\n", formatDatetime(
		file_info.create_timestamp, "%Y-%m-%d %H:%M:%S", \
		szDatetime, sizeof(szDatetime)));
	printf("file size="INT64_PRINTF_FORMAT"\n", file_info.file_size);
	if (file_info.file_size != file_size)
	{
		fprintf(stderr, "file size: "INT64_PRINTF_FORMAT \
			" != "INT64_PRINTF_FORMAT"!!!", file_info.file_size, \
			file_size);
	}

	file_offset = file_size;
	if (upload_type == FDFS_UPLOAD_BY_FILE)
	{
		result = storage_modify_by_filename1(pTrackerServer, \
				pStorageServer, local_filename, 
				file_offset, appender_file_id);

		printf("storage_modify_by_filename\n");
	}
	else if (upload_type == FDFS_UPLOAD_BY_BUFF)
	{
		char *file_content;
		if ((result=getFileContent(local_filename, \
				&file_content, &file_size)) == 0)
		{
			result = storage_modify_by_filebuff1( \
				pTrackerServer, pStorageServer, \
				file_content, file_offset, file_size, \
				appender_file_id);
			free(file_content);
		}

		printf("storage_modify_by_filebuff1\n");
	}
	else
	{
		if (stat(local_filename, &stat_buf) == 0 && \
			S_ISREG(stat_buf.st_mode))
		{
			file_size = stat_buf.st_size;
			result = storage_modify_by_callback1( \
					pTrackerServer, pStorageServer, \
					uploadFileCallback, \
					local_filename, file_offset, \
					file_size, appender_file_id);
		}
		else
		{
			result = errno != 0 ? errno : ENOENT;
		}

		printf("storage_modify_by_callback1\n");
	}

	if (result != 0)
	{
		printf("modify file fail, " \
			"error no: %d, error info: %s\n", \
			result, STRERROR(result));
		tracker_disconnect_server_ex(pStorageServer, true);
		fdfs_client_destroy();
		return result;
	}
	printf("modify file successfully.\n");
	fdfs_get_file_info1(appender_file_id, &file_info);
	printf("source ip address: %s\n", file_info.source_ip_addr);
	printf("file timestamp=%s\n", formatDatetime(
		file_info.create_timestamp, "%Y-%m-%d %H:%M:%S", \
		szDatetime, sizeof(szDatetime)));
	printf("file size="INT64_PRINTF_FORMAT"\n", file_info.file_size);
	if (file_info.file_size != 2 * file_size)
	{
		fprintf(stderr, "file size: "INT64_PRINTF_FORMAT \
			" != "INT64_PRINTF_FORMAT"!!!", file_info.file_size, \
			2 * file_size);
	}

	tracker_disconnect_server_ex(pStorageServer, true);
	tracker_disconnect_server_ex(pTrackerServer, true);

	fdfs_client_destroy();

	return result;
}
Ejemplo n.º 10
0
static int fdfs_dump_storage_stat(char *buff, const int buffSize)
{
	int total_len;
	char szLastHeartBeatTime[32];
	char szSrcUpdTime[32];
	char szSyncUpdTime[32];
	char szSyncedTimestamp[32];

	total_len = snprintf(buff, buffSize,
		"\ng_stat_change_count=%d\n"
		"g_sync_change_count=%d\n"
		"alloc_count=%d\n"
		"current_count=%d\n"
		"max_count=%d\n"
		"total_upload_count=%"PRId64"\n"
		"success_upload_count=%"PRId64"\n"
		"total_set_meta_count=%"PRId64"\n"
		"success_set_meta_count=%"PRId64"\n"
		"total_delete_count=%"PRId64"\n"
		"success_delete_count=%"PRId64"\n"
		"total_download_count=%"PRId64"\n"
		"success_download_count=%"PRId64"\n"
		"total_get_meta_count=%"PRId64"\n"
		"success_get_meta_count=%"PRId64"\n"
		"total_create_link_count=%"PRId64"\n"
		"success_create_link_count=%"PRId64"\n"
		"total_delete_link_count=%"PRId64"\n"
		"success_delete_link_count=%"PRId64"\n"
		"last_source_update=%s\n"
		"last_sync_update=%s\n"
		"last_synced_timestamp=%s\n"
		"last_heart_beat_time=%s\n",
		g_stat_change_count, g_sync_change_count,
        free_queue_alloc_connections(),
		g_storage_stat.connection.current_count,
		g_storage_stat.connection.max_count,
		g_storage_stat.total_upload_count,
		g_storage_stat.success_upload_count,
		g_storage_stat.total_set_meta_count,
		g_storage_stat.success_set_meta_count,
		g_storage_stat.total_delete_count,
		g_storage_stat.success_delete_count,
		g_storage_stat.total_download_count,
		g_storage_stat.success_download_count,
		g_storage_stat.total_get_meta_count,
		g_storage_stat.success_get_meta_count,
		g_storage_stat.total_create_link_count,
		g_storage_stat.success_create_link_count,
		g_storage_stat.total_delete_link_count,
		g_storage_stat.success_delete_link_count,
		formatDatetime(g_storage_stat.last_source_update, 
			"%Y-%m-%d %H:%M:%S", 
			szSrcUpdTime, sizeof(szSrcUpdTime)), 
		formatDatetime(g_storage_stat.last_sync_update,
			"%Y-%m-%d %H:%M:%S", 
			szSyncUpdTime, sizeof(szSyncUpdTime)), 
		formatDatetime(g_storage_stat.last_synced_timestamp, 
			"%Y-%m-%d %H:%M:%S", 
			szSyncedTimestamp, sizeof(szSyncedTimestamp)),
		formatDatetime(g_storage_stat.last_heart_beat_time,
			"%Y-%m-%d %H:%M:%S", 
			szLastHeartBeatTime, sizeof(szLastHeartBeatTime)));

	return total_len;
}
Ejemplo n.º 11
0
static int fdfs_dump_global_vars(char *buff, const int buffSize)
{
	char szStorageJoinTime[32];
	char szSyncUntilTimestamp[32];
	char szUptime[32];
	char reserved_space_str[32];
	int total_len;
	int i;

	total_len = snprintf(buff, buffSize,
		"g_fdfs_connect_timeout=%ds\n"
		"g_fdfs_network_timeout=%ds\n"
		"g_fdfs_base_path=%s\n"
		"g_fdfs_version=%d.%02d\n"
		"g_continue_flag=%d\n"
		"g_schedule_flag=%d\n"
		"g_server_port=%d\n"
		"g_max_connections=%d\n"
		"g_storage_thread_count=%d\n"
		"g_group_name=%s\n"
		"g_sync_log_buff_interval=%d\n"
		"g_subdir_count_per_path=%d\n"
		"g_http_port=%d\n"
		"g_last_server_port=%d\n"
		"g_last_http_port=%d\n"
		"g_allow_ip_count=%d\n"
		"g_run_by_group=%s\n"
		"g_run_by_user=%s\n"
		"g_http_domain=%s\n"
		"g_file_distribute_path_mode=%d\n"
		"g_file_distribute_rotate_count=%d\n"
		"g_fsync_after_written_bytes=%d\n"
		"g_dist_path_index_high=%d\n"
		"g_dist_path_index_low=%d\n"
		"g_dist_write_file_count=%d\n"
		"g_disk_rw_direct=%d\n"
		"g_disk_rw_separated=%d\n"
		"g_disk_reader_threads=%d\n"
		"g_disk_writer_threads=%d\n"
		"g_extra_open_file_flags=%d\n"
		"g_tracker_reporter_count=%d\n"
		"g_heart_beat_interval=%d\n"
		"g_stat_report_interval=%d\n"
		"g_sync_wait_usec=%dms\n"
		"g_sync_interval=%dms\n"
		"g_sync_start_time=%d:%d\n"
		"g_sync_end_time=%d:%d\n"
		"g_sync_part_time=%d\n"
		"g_sync_log_buff_interval=%ds\n"
		"g_sync_binlog_buff_interval=%ds\n"
		"g_write_mark_file_freq=%d\n"
		"g_sync_stat_file_interval=%ds\n"
		"g_storage_join_time=%s\n"
		"g_sync_old_done=%d\n"
		"g_sync_src_id=%s\n"
		"g_sync_until_timestamp=%s\n"
		"g_my_server_id_str=%s\n"
		"g_tracker_client_ip=%s\n"
		"g_last_storage_ip=%s\n"
		"g_check_file_duplicate=%d\n"
		"g_key_namespace=%s\n"
		"g_namespace_len=%d\n"
		"g_bind_addr=%s\n"
		"g_client_bind_addr=%d\n"
		"g_storage_ip_changed_auto_adjust=%d\n"
		"g_thread_kill_done=%d\n"
		"g_thread_stack_size=%d\n"
		"g_upload_priority=%d\n"
		"g_up_time=%s\n"
		"g_if_alias_prefix=%s\n"
		"g_binlog_fd=%d\n"
		"g_binlog_index=%d\n"
		"g_storage_sync_thread_count=%d\n"
		"g_use_storage_id=%d\n"
		"g_if_use_trunk_file=%d\n"
		"g_if_trunker_self=%d\n"
		"g_slot_min_size=%d\n"
		"g_trunk_file_size=%d\n"
		"g_store_path_mode=%d\n"
		"storage_reserved_mb=%s\n"
		"g_avg_storage_reserved_mb=%d\n"
		"g_store_path_index=%d\n"
		"g_current_trunk_file_id=%d\n"
		"g_trunk_sync_thread_count=%d\n"
		"g_trunk_server=%s:%d\n"
		"g_trunk_total_free_space=%"PRId64"\n"
		"g_use_connection_pool=%d\n"
		"g_connection_pool_max_idle_time=%d\n"
		"connection_pool_conn_count=%d\n"
	#ifdef WITH_HTTPD
		"g_http_params.disabled=%d\n"
		"g_http_params.anti_steal_token=%d\n"
		"g_http_params.server_port=%d\n"
		"g_http_params.content_type_hash item count=%d\n"
		"g_http_params.anti_steal_secret_key length=%d\n"
		"g_http_params.token_check_fail_buff length=%d\n"
		"g_http_params.default_content_type=%s\n"
		"g_http_params.token_check_fail_content_type=%s\n"
		"g_http_params.token_ttl=%d\n"
		"g_http_trunk_size=%d\n"
	#endif
	#if defined(DEBUG_FLAG) && defined(OS_LINUX)
		"g_exe_name=%s\n"
	#endif
		, g_fdfs_connect_timeout
		, g_fdfs_network_timeout
		, g_fdfs_base_path
		, g_fdfs_version.major, g_fdfs_version.minor
		, g_continue_flag
		, g_schedule_flag
		, g_server_port
		, g_max_connections
		, g_storage_thread_count
		, g_group_name
		, g_sync_log_buff_interval
		, g_subdir_count_per_path 
		, g_http_port 
		, g_last_server_port 
		, g_last_http_port
		, g_allow_ip_count
		, g_run_by_group
		, g_run_by_user
		, g_http_domain
		, g_file_distribute_path_mode
		, g_file_distribute_rotate_count
		, g_fsync_after_written_bytes
		, g_dist_path_index_high
		, g_dist_path_index_low
		, g_dist_write_file_count
		, g_disk_rw_direct
		, g_disk_rw_separated
		, g_disk_reader_threads
		, g_disk_writer_threads
		, g_extra_open_file_flags
		, g_tracker_reporter_count
		, g_heart_beat_interval
		, g_stat_report_interval
		, g_sync_wait_usec / 1000
		, g_sync_interval
		, g_sync_start_time.hour, g_sync_start_time.minute
		, g_sync_end_time.hour, g_sync_end_time.minute
		, g_sync_part_time
		, g_sync_log_buff_interval
		, g_sync_binlog_buff_interval
		, g_write_mark_file_freq
		, g_sync_stat_file_interval
		, formatDatetime(g_storage_join_time, "%Y-%m-%d %H:%M:%S", 
			szStorageJoinTime, sizeof(szStorageJoinTime))
		, g_sync_old_done
		, g_sync_src_id
		, formatDatetime(g_sync_until_timestamp, "%Y-%m-%d %H:%M:%S", 
			szSyncUntilTimestamp, sizeof(szSyncUntilTimestamp))
                , g_my_server_id_str
		, g_tracker_client_ip
		, g_last_storage_ip
		, g_check_file_duplicate
		, g_key_namespace
		, g_namespace_len
		, g_bind_addr
		, g_client_bind_addr
		, g_storage_ip_changed_auto_adjust
		, g_thread_kill_done
		, g_thread_stack_size
		, g_upload_priority
		, formatDatetime(g_up_time, "%Y-%m-%d %H:%M:%S", 
			szUptime, sizeof(szUptime))
		, g_if_alias_prefix
		, g_binlog_fd
		, g_binlog_index
		, g_storage_sync_thread_count
		, g_use_storage_id
		, g_if_use_trunk_file
		, g_if_trunker_self
		, g_slot_min_size
		, g_trunk_file_size
		, g_store_path_mode
		, fdfs_storage_reserved_space_to_string( \
			&g_storage_reserved_space, reserved_space_str) \
		, g_avg_storage_reserved_mb
		, g_store_path_index
		, g_current_trunk_file_id
		, g_trunk_sync_thread_count
		, g_trunk_server.ip_addr, g_trunk_server.port
		, g_trunk_total_free_space
		, g_use_connection_pool
		, g_connection_pool_max_idle_time
		, g_use_connection_pool ? conn_pool_get_connection_count( \
			&g_connection_pool) : 0
	#ifdef WITH_HTTPD
		, g_http_params.disabled
		, g_http_params.anti_steal_token
		, g_http_params.server_port
		, hash_count(&(g_http_params.content_type_hash))
		, g_http_params.anti_steal_secret_key.length
		, g_http_params.token_check_fail_buff.length
		, g_http_params.default_content_type
		, g_http_params.token_check_fail_content_type
		, g_http_params.token_ttl
		, g_http_trunk_size
	#endif
		
	#if defined(DEBUG_FLAG) && defined(OS_LINUX)
		, g_exe_name
	#endif
	);

	total_len += snprintf(buff + total_len, buffSize - total_len,
			"\ng_fdfs_store_paths.count=%d\n", g_fdfs_store_paths.count);
	for (i=0; i<g_fdfs_store_paths.count; i++)
	{
		total_len += snprintf(buff + total_len, buffSize - total_len,
				"\tg_fdfs_store_paths.paths[%d]=%s, " \
				"total=%d MB, free=%d MB\n", i, \
				g_fdfs_store_paths.paths[i], \
				g_path_space_list[i].total_mb, \
				g_path_space_list[i].free_mb);
	}

	total_len += snprintf(buff + total_len, buffSize - total_len,
			"\ng_local_host_ip_count=%d\n", g_local_host_ip_count);
	for (i=0; i<g_local_host_ip_count; i++)
	{
		total_len += snprintf(buff + total_len, buffSize - total_len,
				"\tg_local_host_ip_addrs[%d]=%s\n", i, 
				g_local_host_ip_addrs + i * IP_ADDRESS_SIZE);
	}

	return total_len;
}