Overview
What this demonstrates:- Handling NVM-managed Node.js binaries
- Custom binary path configuration
- SSL capture from non-standard installations
oisp-cookbook/edge-cases/nvm-node
The Challenge
Problem: NVM installs Node.js in user home directories (~/.nvm/versions/node/...) with statically linked OpenSSL, making automatic detection difficult.
Solution: Explicitly configure OISP Sensor to monitor NVM binaries.
Prerequisites
- Linux with eBPF support (kernel 5.8+)
- NVM installed
- Node.js installed via NVM
- OpenAI API key
Running the Example
With Docker Compose (Recommended)
- Container installs NVM and Node.js v20
- OISP Sensor starts with custom binary path
- Node.js script makes OpenAI API call
- Events captured and validated
Without Docker
1. Find your NVM Node.js binary:Expected Output
Application Output
Events Captured
ai.request event:
Configuration
Option 1: Command Line
Option 2: Config File
/etc/oisp/config.toml:
How It Works
Standard Node.js vs NVM Node.js
Standard installation:OISP Sensor Attachment
When you specify--binary-path:
- Binary discovery - Sensor locates the NVM Node.js binary
- Symbol resolution - Finds OpenSSL symbols (SSL_read, SSL_write)
- eBPF attachment - Attaches uprobes to the binary
- SSL capture - Intercepts TLS traffic from NVM Node.js
Verification
Check sensor logs to verify attachment:Architecture Diagram
Code Walkthrough
app.js:
- Process start -
node app.jsstarts - SSL handshake - TLS connection to api.openai.com
- Request - JSON payload with messages
- Response - Streamed completion
- Event export - ai.request + ai.response events
Validation
The cookbook includes automated validation:- ✅ Events file exists
- ✅ Contains ai.request event
- ✅ Contains ai.response event
- ✅ Process name is “node”
- ✅ Provider is “OpenAI”
- ✅ Binary path contains “.nvm”
Troubleshooting
No events captured
1. Verify binary path:Wrong Node.js version
If you have multiple NVM versions, ensure you’re monitoring the active one:Wildcard pattern not working
The wildcard pattern (~/.nvm/versions/node/*/bin/node) may not expand correctly in some shells. Use explicit path instead:
Related Examples
- pyenv Python - Similar issue with pyenv-managed Python
- Node.js + OpenAI Simple - Standard Node.js installation
- Linux Troubleshooting - NVM/pyenv troubleshooting
Production Recommendations
For development:- Use explicit binary path in config
- Monitor all NVM versions with wildcard
- Use system Node.js (not NVM) for better detectability
- If NVM required, pin version and use explicit path
- Add binary path to systemd service config
Next Steps
- Linux Platform Guide - Full Linux documentation
- Configuration - Config file reference
- All Cookbooks - Browse all examples