Reputation: 1517
I've coded a custom munin plugin, named sse
. It's my first Munin plugin and I followed this guide, however my plugin graph doesn't show up in Munin web interface.
Here is the plugin code:
#!/bin/bash
export PATH=/usr/bin:/usr/sbin:/bin:/sbin:$PATH
if [ "$1" == "config" ] ; then
curl -X GET "http://localhost:3000/api/v1/sse/muninstats/1" -H "accept: */*" 2>/dev/null | sed -e 's/\\n/\n/g' | cut -d'"' -f2 | grep -v '^$'
else
curl -X GET "http://localhost:3000/api/v1/sse/muninstats/0" -H "accept: */*" 2>/dev/null | sed -e 's/\\n/\n/g' | cut -d'"' -f2
fi
Which only calls a local RESTful webservice I wrote and reformats its output to match the syntax Munin is expecting. When I run munin-run sse
I get:
subscriptions.value 0
When I run munin-run sse config
I get:
graph_title Stato SSE
graph_vlabel subscriptions
subscriptions.label subscriptions
graph_args --base 100 -l 0
graph_category appserver
graph_info Una sottoscrizione è una Response che resta aperta verso un client per aggiornamenti sui dati modificati.
subscriptions.info Numero di sottoscrizioni attive.
So it seems to work. The plugin is installed into Munin like this:
root@t470 ~ # ls -l /etc/munin/plugins/sse
lrwxrwxrwx 1 root root 22 3 set 22.43 /etc/munin/plugins/sse -> /usr/local/sbin/sse
root@t470 ~ # ls -l /usr/local/sbin/sse
-rwxr-xr-x 1 root root 374 3 set 22.43 /usr/local/sbin/sse
and Munin seems to agree:
root@t470 ~ # munin-node-configure --libdir /usr/local/sbin | grep ^sse
sse | yes |
I've already stopped and restarted Munin and Munin-node services via systemctl
. However when I try fetch sse
via telnet, I get:
root@t470 ~ # telnet localhost 4949
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
# munin node at t470
fetch sse
# Unknown service
.
so the graph does not show up in the web interface.
Munin log files do not contain any errors, nor any sse
mentions, and I'm at a loss.
My system is a Debian GNU/Linux distro, if that ever matters.
Upvotes: 0
Views: 83
Reputation: 1517
I'm pretty sure I always waited at least 5 minutes before trying fetch
via telnet, however I tried again after about half an hour and it finally worked:
root@t470 ~ # telnet localhost 4949
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
# munin node at t470
fetch sse
subscriptions.value 0
.
Then there was a problem with --base 100
option, because the only valid values are 1000 and 1024, but that's another story.
Upvotes: 0