A TypeScript-based SignalK plugin for monitoring and managing Mosquitto MQTT broker with significantly reduced sudo requirements.
- MQTT $SYS topics monitoring - No bash commands needed for statistics
- Direct port health checks - No
netstat
orss
commands required - User-space configuration management - Config files in SignalK data directory
- Optional systemd integration - Can run completely without sudo access
- Real-time broker status and health monitoring
- Connection count and performance metrics
- Automatic broker discovery and connection testing
- Detailed statistics from $SYS topics
- SignalK data publishing for dashboard integration
- Modern TypeScript-based web interface
- Real-time status updates
- Configuration file editor (user-space)
- Control broker via multiple methods
- Activity logging and monitoring
- Auto: Automatically choose best available method
- MQTT: Direct MQTT-based monitoring (no sudo)
- Systemd: Optional systemd integration (requires permissions)
- Port: Basic port-based health checking
Install directly from GitHub:
npm install motamman/signalk-mosquitto-manager
Or clone and install locally:
git clone https://github.com/motamman/signalk-mosquitto-manager.git
cd signalk-mosquitto-manager
npm install
npm run build
Feature | Original Plugin | TypeScript Version | Sudo Required? |
---|---|---|---|
Broker Status | systemctl status |
MQTT + Port Check | ❌ No |
Statistics | ps , ss commands |
$SYS Topics | ❌ No |
Connection Count | ss | grep | wc |
Port monitoring | ❌ No |
Configuration | /etc/mosquitto/ |
User data directory | ❌ No |
Start/Stop | systemctl |
Optional | |
Log Reading | /var/log/ |
Optional |
{
"enabled": true,
"monitorInterval": 30,
"brokerUrl": "mqtt://localhost",
"brokerPort": 1883,
"useSysTopics": true,
"useSystemdControl": false
}
For completely sudo-free operation, set:
{
"useSystemdControl": false,
"useSysTopics": true,
"confDPath": "/home/signalk/.signalk/mosquitto-configs"
}
This configuration:
- Uses MQTT $SYS topics for monitoring (no bash commands)
- Stores configs in user-writable directory
- Monitors via direct MQTT connections
- Provides all essential functionality without elevated permissions
If you want systemd control and have appropriate permissions:
{
"useSystemdControl": true,
"enableSystemControl": true
}
Option | Default | Description | Sudo Required? |
---|---|---|---|
enabled |
true |
Enable/disable plugin | ❌ |
monitorInterval |
30 |
Check interval (seconds) | ❌ |
brokerUrl |
mqtt://localhost |
MQTT broker URL | ❌ |
brokerPort |
1883 |
MQTT broker port | ❌ |
serviceName |
mosquitto |
Systemd service name | |
confDPath |
${dataDir}/mosquitto-configs |
Config directory | ❌ |
useSysTopics |
true |
Monitor $SYS topics | ❌ |
useSystemdControl |
false |
Enable systemctl commands | |
enableSystemControl |
true |
Show control buttons | ❌ |
// Subscribes to broker statistics topics
$SYS/broker/uptime
$SYS/broker/clients/connected
$SYS/broker/messages/received
$SYS/broker/bytes/sent
// No bash commands needed!
// Tests if MQTT port is accessible
const socket = new net.Socket();
socket.connect(1883, 'localhost');
// No netstat/ss commands needed!
// Direct MQTT client connection test
const client = mqtt.connect('mqtt://localhost:1883');
client.on('connect', () => { /* healthy */ });
// No systemctl commands needed!
Access the management interface at:
http://your-signalk-server/plugins/signalk-mosquitto-manager/
- Real-time Status: Live broker status and health indicators
- Statistics Dashboard: Connections, messages, bytes transferred
- Configuration Editor: Edit config files in user-space
- Control Panel: Start/stop broker (if permissions allow)
- Method Selection: Choose monitoring/control method
- Activity Logs: Real-time operation logging
The plugin publishes broker data to SignalK:
vessels.self.system.mqtt.broker.status.running
vessels.self.system.mqtt.broker.status.reachable
vessels.self.system.mqtt.broker.connections.count
vessels.self.system.mqtt.broker.stats.clientsConnected
vessels.self.system.mqtt.broker.stats.messagesReceived
vessels.self.system.mqtt.broker.stats.messagesSent
The plugin creates configs in the SignalK data directory:
~/.signalk/mosquitto-configs/
Ensure Mosquitto publishes statistics by adding to mosquitto.conf
:
# Enable $SYS topics
sys_interval 10
Ensure the SignalK user can connect to MQTT:
# Test MQTT connection
mosquitto_pub -h localhost -t test -m "hello"
- Check if $SYS topics are enabled in Mosquitto
- Verify MQTT connection in web interface
- Check broker allows client connections
- Set
enableSystemControl: true
in config - For systemd control: ensure user permissions
- Alternative: use external systemd user service
- Check config directory is writable
- Verify MQTT broker accessibility
- Consider sudo-free configuration options
npm run build
npm run dev
src/
├── index.ts # Main plugin logic
└── types.ts # TypeScript interfaces
public/
├── index.html # Web interface
└── mosquitto.png # Icon
dist/ # Compiled JavaScript
Aspect | Original JS | TypeScript Version |
---|---|---|
Sudo Dependencies | High | Minimal |
Type Safety | None | Full |
Error Handling | Basic | Comprehensive |
Monitoring Method | Bash commands | MQTT + Direct |
Config Management | System files | User-space |
Maintainability | Limited | Enhanced |
- Install TypeScript version
- Update configuration to use user directory
- Disable systemd control if sudo-free desired
- Enable $SYS topics in Mosquitto
- Test functionality with reduced permissions
MIT
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
For issues, questions, or feature requests, please open an issue on GitHub.
This TypeScript version provides the same functionality as the original with significantly reduced sudo requirements, making it more suitable for containerized and security-conscious environments.