mirror of
https://github.com/drakkan/sftpgo.git
synced 2024-11-21 23:20:24 +00:00
sftpd stats: add file path for active upload/download
This commit is contained in:
parent
9f5722a894
commit
90607d4f86
4 changed files with 17 additions and 2 deletions
|
@ -28,7 +28,7 @@ Regularly the test cases are manually executed and pass on Windows. Other UNIX v
|
|||
## Requirements
|
||||
|
||||
- Go 1.12 or higher
|
||||
- A suitable SQL server to use as data provider: PostreSQL (9+) or MySQL (4.1+) or SQLite 3.x
|
||||
- A suitable SQL server to use as data provider: PostreSQL (9+) or MySQL (5.6+) or SQLite 3.x
|
||||
|
||||
## Installation
|
||||
|
||||
|
@ -89,7 +89,7 @@ If you don't configure any private host keys, the daemon will use `id_rsa` in th
|
|||
|
||||
Before starting `sftpgo` a dataprovider must be configured.
|
||||
|
||||
Sample SQL scripts to create the required database structure can be found insite the source tree [sql](https://github.com/drakkan/sftpgo/tree/master/sql "sql") directory. The SQL scripts filename's is, by convention, the date as `YYYYMMDD` and the suffix `.sql`. You need to apply all the SQL scripts for your database ordered by name, for example `20190706.sql` must be applied before `20190728.sql` and so on.
|
||||
Sample SQL scripts to create the required database structure can be found inside the source tree [sql](https://github.com/drakkan/sftpgo/tree/master/sql "sql") directory. The SQL scripts filename's is, by convention, the date as `YYYYMMDD` and the suffix `.sql`. You need to apply all the SQL scripts for your database ordered by name, for example `20190706.sql` must be applied before `20190728.sql` and so on.
|
||||
|
||||
The `sftpgo` configuration file contains the following sections:
|
||||
|
||||
|
|
|
@ -602,6 +602,9 @@ components:
|
|||
enum:
|
||||
- upload
|
||||
- download
|
||||
path:
|
||||
type: string
|
||||
description: SFTP file path for the upload/download
|
||||
start_time:
|
||||
type: integer
|
||||
format: int64
|
||||
|
|
|
@ -110,3 +110,13 @@ func (u *User) GetHomeDir() string {
|
|||
func (u *User) HasQuotaRestrictions() bool {
|
||||
return u.QuotaFiles > 0 || u.QuotaSize > 0
|
||||
}
|
||||
|
||||
// GetRelativePath returns the path for a file relative to the user's home dir.
|
||||
// This is the path as seen by SFTP users
|
||||
func (u *User) GetRelativePath(path string) string {
|
||||
rel, err := filepath.Rel(u.GetHomeDir(), path)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return "/" + filepath.ToSlash(rel)
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ type connectionTransfer struct {
|
|||
StartTime int64 `json:"start_time"`
|
||||
Size int64 `json:"size"`
|
||||
LastActivity int64 `json:"last_activity"`
|
||||
Path string `json:"path"`
|
||||
}
|
||||
|
||||
// ActiveQuotaScan defines an active quota scan
|
||||
|
@ -210,6 +211,7 @@ func GetConnectionsStats() []ConnectionStatus {
|
|||
StartTime: utils.GetTimeAsMsSinceEpoch(t.start),
|
||||
Size: size,
|
||||
LastActivity: utils.GetTimeAsMsSinceEpoch(t.lastActivity),
|
||||
Path: c.User.GetRelativePath(t.path),
|
||||
}
|
||||
conn.Transfers = append(conn.Transfers, connTransfer)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue