-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1231 from kofemann/nfs
packetbeat: add support for NFS v3 and v4 protocols
- Loading branch information
Showing
20 changed files
with
1,221 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"@timestamp": "2016-03-28T06:18:18.431Z", | ||
"beat": { | ||
"hostname": "localhost", | ||
"name": "localhost" | ||
}, | ||
"count": 1, | ||
"dst": "127.0.0.1", | ||
"dst_port": 2049, | ||
"nfs": { | ||
"minor_version": 1, | ||
"opcode": "GETATTR", | ||
"status": "NFSERR_NOENT", | ||
"tag": "", | ||
"version": 4 | ||
}, | ||
"rpc": { | ||
"auth_flavor": "unix", | ||
"call_size": 200, | ||
"cred": { | ||
"gid": 500, | ||
"gids": [ | ||
491, | ||
499, | ||
500 | ||
], | ||
"machinename": "localhost", | ||
"stamp": 4597002, | ||
"uid": 500 | ||
}, | ||
"reply_size": 96, | ||
"status": "success", | ||
"time": 25631000, | ||
"time_str": "25.631ms", | ||
"xid": "2cf0c876" | ||
}, | ||
"src": "127.0.0.1", | ||
"src_port": 975, | ||
"type": "nfs" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
NFS packetbeat | ||
============== | ||
|
||
NFS v3 and v4 protocols parsing for packetbeat. | ||
|
||
Can be extended to handle other SunRPC based protocols as well. | ||
|
||
Sample output: | ||
-------------- | ||
```json | ||
{ | ||
"@timestamp": "2016-03-28T06:18:18.431Z", | ||
"beat": { | ||
"hostname": "localhost", | ||
"name": "localhost" | ||
}, | ||
"count": 1, | ||
"dst": "127.0.0.1", | ||
"dst_port": 2049, | ||
"nfs": { | ||
"minor_version": 1, | ||
"opcode": "GETATTR", | ||
"status": "NFSERR_NOENT", | ||
"tag": "", | ||
"version": 4 | ||
}, | ||
"rpc": { | ||
"auth_flavor": "unix", | ||
"call_size": 200, | ||
"cred": { | ||
"gid": 500, | ||
"gids": [ | ||
491, | ||
499, | ||
500 | ||
], | ||
"machinename": "localhost", | ||
"stamp": 4597002, | ||
"uid": 500 | ||
}, | ||
"reply_size": 96, | ||
"status": "success", | ||
"time": 25631000, | ||
"time_str": "25.631ms", | ||
"xid": "2cf0c876" | ||
}, | ||
"src": "127.0.0.1", | ||
"src_port": 975, | ||
"type": "nfs" | ||
} | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package nfs | ||
|
||
import ( | ||
"github.com/elastic/beats/packetbeat/config" | ||
"github.com/elastic/beats/packetbeat/protos" | ||
) | ||
|
||
type rpcConfig struct { | ||
config.ProtocolCommon `config:",inline"` | ||
} | ||
|
||
var ( | ||
defaultConfig = rpcConfig{ | ||
ProtocolCommon: config.ProtocolCommon{ | ||
TransactionTimeout: protos.DefaultTransactionExpiration, | ||
}, | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package nfs | ||
|
||
import ( | ||
"github.com/elastic/beats/libbeat/common" | ||
"time" | ||
) | ||
|
||
type Nfs struct { | ||
xdr Xdr | ||
vers uint32 | ||
proc uint32 | ||
event common.MapStr | ||
ts time.Time | ||
} | ||
|
||
func (nfs *Nfs) getRequestInfo() { | ||
|
||
nfsInfo := common.MapStr{} | ||
nfsInfo["version"] = nfs.vers | ||
|
||
switch nfs.vers { | ||
case 3: | ||
nfsInfo["opcode"] = nfs.getV3Opcode() | ||
case 4: | ||
switch nfs.proc { | ||
case 0: | ||
nfsInfo["opcode"] = "NULL" | ||
case 1: | ||
tag := nfs.xdr.getDynamicOpaque() | ||
nfsInfo["tag"] = string(tag) | ||
nfsInfo["minor_version"] = nfs.xdr.getUInt() | ||
nfsInfo["opcode"] = nfs.getV4Opcode() | ||
} | ||
} | ||
nfs.event["nfs"] = nfsInfo | ||
} | ||
|
||
func (nfs *Nfs) getReplyInfo(xdr *Xdr) { | ||
nfsInfo := nfs.event["nfs"].(common.MapStr) | ||
stat := int(xdr.getUInt()) | ||
nfsInfo["status"] = NFS_STATUS[stat] | ||
} |
Oops, something went wrong.