| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | package apache |
| 4 | |
| 5 | import "github.com/netdata/netdata/go/plugins/plugin/framework/collectorapi" |
| 6 | |
| 7 | const ( |
| 8 | prioRequests = collectorapi.Priority + iota |
| 9 | prioConnection |
| 10 | prioConnsAsync |
| 11 | prioScoreboard |
| 12 | prioNet |
| 13 | prioWorkers |
| 14 | prioReqPerSec |
| 15 | prioBytesPerSec |
| 16 | prioBytesPerReq |
| 17 | prioUptime |
| 18 | ) |
| 19 | |
| 20 | var baseCharts = collectorapi.Charts{ |
| 21 | chartConnections.Copy(), |
| 22 | chartConnsAsync.Copy(), |
| 23 | chartWorkers.Copy(), |
| 24 | chartScoreboard.Copy(), |
| 25 | } |
| 26 | |
| 27 | var extendedCharts = collectorapi.Charts{ |
| 28 | chartRequests.Copy(), |
| 29 | chartBandwidth.Copy(), |
| 30 | chartReqPerSec.Copy(), |
| 31 | chartBytesPerSec.Copy(), |
| 32 | chartBytesPerReq.Copy(), |
| 33 | chartUptime.Copy(), |
| 34 | } |
| 35 | |
| 36 | func newCharts(s *serverStatus) *collectorapi.Charts { |
| 37 | charts := baseCharts.Copy() |
| 38 | |
| 39 | // ServerMPM: prefork |
| 40 | if s.Connections.Total == nil { |
| 41 | _ = charts.Remove(chartConnections.ID) |
| 42 | } |
| 43 | if s.Connections.Async.KeepAlive == nil { |
| 44 | _ = charts.Remove(chartConnsAsync.ID) |
| 45 | } |
| 46 | |
| 47 | if s.Total.Accesses != nil { |
| 48 | _ = charts.Add(*extendedCharts.Copy()...) |
| 49 | } |
| 50 | |
| 51 | return charts |
| 52 | } |
| 53 | |
| 54 | // simple status |
| 55 | var ( |
| 56 | chartConnections = collectorapi.Chart{ |
| 57 | ID: "connections", |
| 58 | Title: "Connections", |
| 59 | Units: "connections", |
| 60 | Fam: "connections", |
| 61 | Ctx: "apache.connections", |
| 62 | Priority: prioConnection, |
| 63 | Dims: collectorapi.Dims{ |
| 64 | {ID: "conns_total", Name: "connections"}, |
| 65 | }, |
| 66 | } |
| 67 | chartConnsAsync = collectorapi.Chart{ |
| 68 | ID: "conns_async", |
| 69 | Title: "Async Connections", |
| 70 | Units: "connections", |
| 71 | Fam: "connections", |
| 72 | Ctx: "apache.conns_async", |
| 73 | Type: collectorapi.Stacked, |
| 74 | Priority: prioConnsAsync, |
| 75 | Dims: collectorapi.Dims{ |
| 76 | {ID: "conns_async_keep_alive", Name: "keepalive"}, |
| 77 | {ID: "conns_async_closing", Name: "closing"}, |
| 78 | {ID: "conns_async_writing", Name: "writing"}, |
| 79 | }, |
| 80 | } |
| 81 | chartWorkers = collectorapi.Chart{ |
| 82 | ID: "workers", |
| 83 | Title: "Workers Threads", |
| 84 | Units: "workers", |
| 85 | Fam: "workers", |
| 86 | Ctx: "apache.workers", |
| 87 | Type: collectorapi.Stacked, |
| 88 | Priority: prioWorkers, |
| 89 | Dims: collectorapi.Dims{ |
| 90 | {ID: "idle_workers", Name: "idle"}, |
| 91 | {ID: "busy_workers", Name: "busy"}, |
| 92 | }, |
| 93 | } |
| 94 | chartScoreboard = collectorapi.Chart{ |
| 95 | ID: "scoreboard", |
| 96 | Title: "Scoreboard", |
| 97 | Units: "connections", |
| 98 | Fam: "connections", |
| 99 | Ctx: "apache.scoreboard", |
| 100 | Priority: prioScoreboard, |
| 101 | Dims: collectorapi.Dims{ |
| 102 | {ID: "scoreboard_waiting", Name: "waiting"}, |
| 103 | {ID: "scoreboard_starting", Name: "starting"}, |
| 104 | {ID: "scoreboard_reading", Name: "reading"}, |
| 105 | {ID: "scoreboard_sending", Name: "sending"}, |
| 106 | {ID: "scoreboard_keepalive", Name: "keepalive"}, |
| 107 | {ID: "scoreboard_dns_lookup", Name: "dns_lookup"}, |
| 108 | {ID: "scoreboard_closing", Name: "closing"}, |
| 109 | {ID: "scoreboard_logging", Name: "logging"}, |
| 110 | {ID: "scoreboard_finishing", Name: "finishing"}, |
| 111 | {ID: "scoreboard_idle_cleanup", Name: "idle_cleanup"}, |
| 112 | {ID: "scoreboard_open", Name: "open"}, |
| 113 | }, |
| 114 | } |
| 115 | ) |
| 116 | |
| 117 | // extended status |
| 118 | var ( |
| 119 | chartRequests = collectorapi.Chart{ |
| 120 | ID: "requests", |
| 121 | Title: "Requests", |
| 122 | Units: "requests/s", |
| 123 | Fam: "requests", |
| 124 | Ctx: "apache.requests", |
| 125 | Priority: prioRequests, |
| 126 | Dims: collectorapi.Dims{ |
| 127 | {ID: "total_accesses", Name: "requests", Algo: collectorapi.Incremental}, |
| 128 | }, |
| 129 | } |
| 130 | chartBandwidth = collectorapi.Chart{ |
| 131 | ID: "net", |
| 132 | Title: "Bandwidth", |
| 133 | Units: "kilobits/s", |
| 134 | Fam: "bandwidth", |
| 135 | Ctx: "apache.net", |
| 136 | Type: collectorapi.Area, |
| 137 | Priority: prioNet, |
| 138 | Dims: collectorapi.Dims{ |
| 139 | {ID: "total_kBytes", Name: "sent", Algo: collectorapi.Incremental, Mul: 8}, |
| 140 | }, |
| 141 | } |
| 142 | chartReqPerSec = collectorapi.Chart{ |
| 143 | ID: "reqpersec", |
| 144 | Title: "Lifetime Average Number Of Requests Per Second", |
| 145 | Units: "requests/s", |
| 146 | Fam: "statistics", |
| 147 | Ctx: "apache.reqpersec", |
| 148 | Type: collectorapi.Area, |
| 149 | Priority: prioReqPerSec, |
| 150 | Dims: collectorapi.Dims{ |
| 151 | {ID: "req_per_sec", Name: "requests", Div: 100000}, |
| 152 | }, |
| 153 | } |
| 154 | chartBytesPerSec = collectorapi.Chart{ |
| 155 | ID: "bytespersec", |
| 156 | Title: "Lifetime Average Number Of Bytes Served Per Second", |
| 157 | Units: "KiB/s", |
| 158 | Fam: "statistics", |
| 159 | Ctx: "apache.bytespersec", |
| 160 | Type: collectorapi.Area, |
| 161 | Priority: prioBytesPerSec, |
| 162 | Dims: collectorapi.Dims{ |
| 163 | {ID: "bytes_per_sec", Name: "served", Mul: 8, Div: 1024 * 100000}, |
| 164 | }, |
| 165 | } |
| 166 | chartBytesPerReq = collectorapi.Chart{ |
| 167 | ID: "bytesperreq", |
| 168 | Title: "Lifetime Average Response Size", |
| 169 | Units: "KiB", |
| 170 | Fam: "statistics", |
| 171 | Ctx: "apache.bytesperreq", |
| 172 | Type: collectorapi.Area, |
| 173 | Priority: prioBytesPerReq, |
| 174 | Dims: collectorapi.Dims{ |
| 175 | {ID: "bytes_per_req", Name: "size", Div: 1024 * 100000}, |
| 176 | }, |
| 177 | } |
| 178 | chartUptime = collectorapi.Chart{ |
| 179 | ID: "uptime", |
| 180 | Title: "Uptime", |
| 181 | Units: "seconds", |
| 182 | Fam: "availability", |
| 183 | Ctx: "apache.uptime", |
| 184 | Priority: prioUptime, |
| 185 | Dims: collectorapi.Dims{ |
| 186 | {ID: "uptime"}, |
| 187 | }, |
| 188 | } |
| 189 | ) |