Closed jamestombs closed 6 years ago
@jamestombs The current implementation works only with an integer, meaning 70G
or 19%
is not going to work.
Thanks. For those using bash you can use | sed 's/[^0-9]*//g'
to everything other than the numbers.
The following code is now working:
#!/bin/bash
TOTAL="$(df -h | grep "/vz/" | awk '{ print $2; }' | sed 's/[^0-9]*//g')"
USED="$(df -h | grep "/vz/" | awk '{ print $3; }' | sed 's/[^0-9]*//g')"
AVAIL="$(df -h | grep "/vz/" | awk '{ print $4; }' | sed 's/[^0-9]*//g')"
PERC="$(df -h | grep "/vz/" | awk '{ print $5; }' | sed 's/[^0-9]*//g')"
echo "hdd.total:${TOTAL}|gauge"
echo "hdd.used:${USED}|gauge"
echo "hdd.available:${AVAIL}|gauge"
echo "hdd.percentage:${PERC}|gauge"
Spoke too soon. Although the test on the local machine is working:
# /opt/amonagent/amonagent -test-plugin=custom
{"hdd":{"gauges":{"hdd.available":58,"hdd.percentage":19,"hdd.total":70,"hdd.used":13}}}
The plugin is appearing on the amon server but states that there's no data.
Moved bash script to /usr/local/bin but still not getting any data through to Amon.
amonagent@hostname:~$ amonagent -test-plugin=custom
{"hdd":{"gauges":{"hdd.available":57,"hdd.percentage":19,"hdd.total":70,"hdd.used":14}}}
Executed in 15.446176ms
@jamestombs Can you try running it as the amonagent user:
sudo -u amonagent -s
whoami # amonagent
amonagent -test-plugin=custom
That command was as amonagent.
@jamestombs The next step would be to see if you get at least the metric names in the Amon interface, when you click on Servers -> Plugins -> Custom?
Actually it has picked up now. Guess it needed a bit of time to gather data before plotting the graph. Looks like it was just a simple case of amonagent not being able to read the script from /root.
@jamestombs Nice to hear that it is working. I will put the potential permissions / location issue in a more prominent place in the documentation for future reference.
Struggling to understand how custom plugins are supposed to be working.
We have some openvz guests which we want to monitor but the disk space isn't being picked up. I've created the following bash script:
This outputs the following:
In /etc/opt/amonagent/plugins-enabled/custom.conf we have:
Which when tested results in: