我有一个配置文件,如下所示:
[host1]
connection = host1
disabled = 0
index = mssql
index_time_mode = current
interval = 7200
mode = batch
query = SELECT CONVERT(CHAR(100), SERVERPROPERTY('Servername')) AS Server, msdb.dbo.backupset.database_name,(msdb.dbo.backupset.backup_start_date) AS started_bkup_date, (msdb.dbo.backupset.backup_finish_date) AS last_db_backup_date, msdb.dbo.backupmediafamily.physical_device_name,DATEDIFF(hh, (msdb.dbo.backupset.backup_finish_date), GETDATE()) AS [Backup_Age_Hours],msdb.dbo.backupset.type FROM sys.databases, msdb.dbo.backupmediafamily inner join msdb.dbo.backupset ON msdb.dbo.backupmediafamily.media_set_id = msdb.dbo.backupset.media_set_id where (msdb.dbo.backupset.type = 'D' or msdb.dbo.backupset.type = 'I') and msdb.dbo.backupset.database_name=sys.databases.name and sys.databases.state_desc='ONLINE' and msdb.dbo.backupset.backup_finish_date > DATEADD(dd,-7,GETDATE()) order by [Backup_Age_Hours]
sourcetype = mssql:bkup_history
[host2]
connection = host2
disabled = 0
index = mssql
index_time_mode = current
interval = 7200
mode = batch
query = SELECT CONVERT(CHAR(100), SERVERPROPERTY('Servername')) AS Server, msdb.dbo.backupset.database_name,(msdb.dbo.backupset.backup_start_date) AS started_bkup_date, (msdb.dbo.backupset.backup_finish_date) AS last_db_backup_date, msdb.dbo.backupmediafamily.physical_device_name,DATEDIFF(hh, (msdb.dbo.backupset.backup_finish_date), GETDATE()) AS [Backup_Age_Hours],msdb.dbo.backupset.type FROM sys.databases, msdb.dbo.backupmediafamily inner join msdb.dbo.backupset ON msdb.dbo.backupmediafamily.media_set_id = msdb.dbo.backupset.media_set_id where (msdb.dbo.backupset.type = 'D' or msdb.dbo.backupset.type = 'I') and msdb.dbo.backupset.database_name=sys.databases.name and sys.databases.state_desc='ONLINE' and msdb.dbo.backupset.backup_finish_date > DATEADD(dd,-7,GETDATE()) order by [Backup_Age_Hours]
sourcetype = mssql:bkup_history
我正在尝试使用配置解析器模块进行解析
import configparser
config = configparser.ConfigParser()
config.read("/path/to/myfile.txt")
但是得到错误
section u'database_name' already exists
查询部分具有两个database_name声明,但是它们在同一行上出现。有没有办法将整个行与模块一起解析?