I have the following output of running SNMPstat which is
Code: Select all
snmpnetstat -v2c -c public -Cs -Cp udp 172.0.1.11
Code: Select all
udp:
198 total datagrams received
65 datagrams to invalid port
0 datagrams dropped due to errors
265 output datagram requests
Code: Select all
<fieldname_1>:<value_1> <fieldname_2>:<value_2> ... <fieldname_n>:<value_n>
Therefore, I have written the *bash script* and it returns exactly the output I want when I run for example `
Code: Select all
./udp_netstat.sh 172.0.1.11
Code: Select all
Received Datagrams:258 Invalid port:63 Dropped datagrams:0 Datagram requests:471520
Code: Select all
$ cat udp_netstat.sh
#!/bin/bash
rs="$(snmpnetstat -v2c -c public -Cs -Cp udp "$@")"
# You have to quote "$rs" so newlines don't break
ReceivedDatagrams="$(echo "$rs" | cut -d$'\n' -f2 | tr -s ' '| cut -d' ' -f2)"
InvalidPort="$(echo "$rs" | cut -d$'\n' -f3 | tr -s ' '| cut -d' ' -f2)"
DroppedDatagrams="$(echo "$rs" | cut -d$'\n' -f4 | tr -s ' '| cut -d' ' -f2)"
DatagramRequests="$(echo "$rs" | cut -d$'\n' -f5 | tr -s ' '| cut -d' ' -f2)"
Starting with a data input method, I gave the following path `/usr/share/cacti/site/scripts/udp_netstat <hostname>` then I added the input fields as well as the output, according to the bash file output.
For the Data Source, I added data source items also according to the bash file output and made Data source type as COUNTER. Then, I proceed to Graph Template where I added the line of each output I have.
Here is the steps and some screenshots:
It seems to be in the workflow of adding a new script, however, nothing so far is shown in the graph.
Input Data Source
Data Template
Graph Template
I assume there is a mistake with the Input String.
Thank you