From ac3f146b909e0d91da865144f0846089eeb6b15c Mon Sep 17 00:00:00 2001 From: Michael Neumann Date: Tue, 9 Jul 2019 17:03:41 +0200 Subject: [PATCH] Scrape more Instances --- main.go | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/main.go b/main.go index 3756934..8bc04fa 100644 --- a/main.go +++ b/main.go @@ -53,7 +53,7 @@ type Exporter struct { var ( // Version will be set at build time. - Version = "1.1.2" + Version = "1.1.3" listenAddress = flag.String("web.listen-address", ":9161", "Address to listen on for web interface and telemetry.") metricPath = flag.String("web.telemetry-path", "/metrics", "Path under which to expose metrics.") pTabRows = flag.Bool("tablerows", false, "Expose Table rows (CAN TAKE VERY LONG)") @@ -224,7 +224,7 @@ func (e *Exporter) ScrapeQuery() { for _, query := range conn.Queries { rows, err = conn.db.Query(query.Sql) if err != nil { - break + continue } defer rows.Close() for rows.Next() { @@ -251,7 +251,7 @@ func (e *Exporter) ScrapeParameter() { if conn.db != nil { rows, err = conn.db.Query(`select name,value from v$parameter WHERE num=43`) if err != nil { - break + continue } defer rows.Close() for rows.Next() { @@ -278,7 +278,7 @@ func (e *Exporter) ScrapeServices() { if conn.db != nil { rows, err = conn.db.Query(`select name from v$active_services`) if err != nil { - break + continue } defer rows.Close() for rows.Next() { @@ -311,7 +311,7 @@ func (e *Exporter) ScrapeCache() { from v$sysmetric where group_id=2 and metric_id in (2000,2050,2112,2110)`) if err != nil { - break + continue } defer rows.Close() for rows.Next() { @@ -338,7 +338,7 @@ func (e *Exporter) ScrapeRedo() { if conn.db != nil { rows, err = conn.db.Query(`select count(*) from v$log_history where first_time > sysdate - 1/24/12`) if err != nil { - break + continue } defer rows.Close() for rows.Next() { @@ -363,7 +363,7 @@ func (e *Exporter) ScrapeRecovery() { rows, err = conn.db.Query(`SELECT sum(percent_space_used) , sum(percent_space_reclaimable) from V$FLASH_RECOVERY_AREA_USAGE`) if err != nil { - break + continue } defer rows.Close() for rows.Next() { @@ -391,7 +391,7 @@ func (e *Exporter) ScrapeInterconnect() { FROM V$SYSSTAT WHERE name in ('gc cr blocks served','gc cr blocks flushed','gc cr blocks received')`) if err != nil { - break + continue } defer rows.Close() for rows.Next() { @@ -421,7 +421,7 @@ func (e *Exporter) ScrapeAsmspace() { AND d.header_status = 'MEMBER' GROUP by g.name, g.group_number`) if err != nil { - break + continue } defer rows.Close() for rows.Next() { @@ -463,7 +463,7 @@ func (e *Exporter) ScrapeTablespace() { FROM dba_temp_free_space GROUP BY tablespace_name`) if err != nil { - break + continue } defer rows.Close() for rows.Next() { @@ -495,7 +495,7 @@ func (e *Exporter) ScrapeSession() { FROM v$session GROUP BY decode(username,NULL,'SYSTEM','SYS','SYSTEM','USER'),status`) if err != nil { - break + continue } defer rows.Close() for rows.Next() { @@ -537,7 +537,7 @@ func (e *Exporter) ScrapeSysstat() { rows, err = conn.db.Query(`SELECT name, value FROM v$sysstat WHERE statistic# in (6,7,1084,1089)`) if err != nil { - break + continue } defer rows.Close() for rows.Next() { @@ -565,7 +565,7 @@ func (e *Exporter) ScrapeWaitclass() { FROM v$waitclassmetric m, v$system_wait_class n WHERE m.wait_class_id=n.wait_class_id and n.wait_class != 'Idle'`) if err != nil { - break + continue } defer rows.Close() for rows.Next() { @@ -596,7 +596,7 @@ func (e *Exporter) ScrapeSysmetric() { if conn.db != nil { rows, err = conn.db.Query("select metric_name,value from v$sysmetric where metric_id in (2092,2093,2124,2100)") if err != nil { - break + continue } defer rows.Close() for rows.Next() { @@ -624,7 +624,7 @@ func (e *Exporter) ScrapeTablerows() { from dba_tables where owner not like '%SYS%' and num_rows is not null`) if err != nil { - break + continue } defer rows.Close() for rows.Next() { @@ -655,7 +655,7 @@ func (e *Exporter) ScrapeTablebytes() { WHERE stab.owner = tab.owner AND stab.segment_name = tab.table_name AND tab.owner NOT LIKE '%SYS%'`) if err != nil { - break + continue } defer rows.Close() for rows.Next() { @@ -686,7 +686,7 @@ func (e *Exporter) ScrapeIndexbytes() { and table_owner NOT LIKE '%SYS%' group by table_owner,table_name`) if err != nil { - break + continue } defer rows.Close() for rows.Next() { @@ -717,7 +717,7 @@ func (e *Exporter) ScrapeLobbytes() { and l.owner NOT LIKE '%SYS%' group by l.owner,l.table_name`) if err != nil { - break + continue } defer rows.Close() for rows.Next() { @@ -779,7 +779,7 @@ func (e *Exporter) Connect() { if err == nil { err = config.Cfgs[i].db.QueryRow("select db_unique_name,instance_name from v$database,v$instance").Scan(&dbname,&inname) if err == nil { - if (conf.Database != dbname) || (conf.Instance != inname) { + if (len(conf.Database)==0) || (len(conf.Instance)==0) { config.Cfgs[i].Database = dbname config.Cfgs[i].Instance = inname }