+
Skip to content

Add remote_user parsing #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ pull:
run:
NGTOP_LOGS_PATH=./logs/access.log* go run .

test:
go test ./...

db:
sqlite3 -cmd ".open ngtop.db"

Expand Down
10 changes: 8 additions & 2 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ const SAMPLE_LOGS = `xx.xx.xx.xx - - [24/Jul/2024:00:00:28 +0000] "GET /feed HTT
xx.xx.xx.xx - - [24/Jul/2024:00:00:30 +0000] "GET /feed HTTP/1.1" 301 169 "-" "feedi/0.1.0 (+https://github.com/facundoolano/feedi)"
xx.xx.xx.xx - - [24/Jul/2024:00:00:56 +0000] "GET /blog/deconstructing-the-role-playing-videogame/ HTTP/1.1" 200 14224 "-" "feedi/0.1.0 (+https://github.com/facundoolano/feedi)"
xx.xx.xx.xx - - [24/Jul/2024:00:01:18 +0000] "GET /feed.xml HTTP/1.1" 200 9641 "https://olano.dev/feed.xml" "FreshRSS/1.24.0 (Linux; https://freshrss.org)"
xx.xx.xx.xx - - [24/Jul/2024:00:01:20 +0000] "GET /feed.xml HTTP/1.1" 200 9641 "https://olano.dev/feed.xml" "FreshRSS/1.24.0 (Linux; https://freshrss.org)"
xx.xx.xx.xx - - [24/Jul/2024:00:01:51 +0000] "GET /feed.xml HTTP/1.1" 200 9641 "https://olano.dev/feed.xml" "FreshRSS/1.24.0 (Linux; https://freshrss.org)"
xx.xx.xx.xx - facundo [24/Jul/2024:00:01:20 +0000] "GET /feed.xml HTTP/1.1" 200 9641 "https://olano.dev/feed.xml" "FreshRSS/1.24.0 (Linux; https://freshrss.org)"
xx.xx.xx.xx - facundo [24/Jul/2024:00:01:51 +0000] "GET /feed.xml HTTP/1.1" 200 9641 "https://olano.dev/feed.xml" "FreshRSS/1.24.0 (Linux; https://freshrss.org)"
xx.xx.xx.xx - - [24/Jul/2024:00:02:17 +0000] "GET / HTTP/1.1" 200 1120 "https://olano.dev/" "SimplePie/1.8.0 (Feed Parser; http://simplepie.org; Allow like Gecko) Build/1674203855"
xx.xx.xx.xx - - [24/Jul/2024:00:04:49 +0000] "GET /blog/mi-descubrimiento-de-america HTTP/1.1" 301 169 "-" "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.6478.126 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
xx.xx.xx.xx - - [24/Jul/2024:00:06:41 +0000] "GET /blog/a-few-more-things-you-can-do-on-your-website HTTP/1.1" 301 169 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9"
Expand Down Expand Up @@ -179,6 +179,12 @@ func TestMultiField(t *testing.T) {
assertEqual(t, len(rows), 2)
assertEqual(t, rows[0], []string{"301", "GET", "6"})
assertEqual(t, rows[1], []string{"200", "GET", "5"})

columns, rows = runCommand(t, DEFAULT_LOG_FORMAT, SAMPLE_LOGS, []string{"user"})
assertEqual(t, columns, []string{"user", "#reqs"})
assertEqual(t, len(rows), 2)
assertEqual(t, rows[0], []string{"", "9"})
assertEqual(t, rows[1], []string{"facundo", "2"})
}

func TestWhereFilter(t *testing.T) {
Expand Down
6 changes: 6 additions & 0 deletions ngtop/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ var KNOWN_FIELDS = []LogField{
ColumnName: "ip",
ColumnSpec: "TEXT",
},
{
LogFormatVar: "remote_user",
CLINames: []string{"user", "username", "remote_user", "remoteuser"},
ColumnName: "user",
ColumnSpec: "TEXT",
},
{
LogFormatVar: "status",
CLINames: []string{"status"},
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载