Pandora FMS community forums

Full Version: Plugin scripts does not work
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I have created a plugin, with runs through a file called sensit.txt and the output will be the data that needs te be send to the pandora server.

this plugin looks like this:
--------------------------------------------------------------------------------------
#!/bin/bash

while read line
do

appname=`echo -e "$line"| awk '{print $2}'`
port=`echo -e "$line"| awk '{print $1}'`

  total=$(curl -s -u user:password http://localhost:${port}/api/v1/dataCollectors/status | sed s/.*total\":// | sed s/,.*//)
    pres=$(curl -s -u userr:password http://localhost:${port}/api/v1/dataCollectors/status | sed s/.*present\":// | sed s/,.*//)
    let mis=total-pres

latency=$(curl -s -u user:password http://localhost:${port}/api/v1/network/status | sed s/.*latency\":// | sed s/\\..*//)

# Module to get amount of absent datacollectors
echo -e "\t<module>"
echo -e "\t<name><![CDATA[Gateways: $appname]]></name>"
echo -e "\t<type>generic_data</type>"
echo -e "\t<data><![CDATA[$mis]]></data>"
echo -e "\t<description><![CDATA[amount of absent gateways]]></description>"
echo -e "\t<module_group>websites</module_group>"
echo -e "\t</module>"

# Module to get the latency
echo -e "\t<module>"
echo -e "\t<name><![CDATA[Latency: $appname]]></name>"
echo -e "\t<type>generic_data</type>"
echo -e "\t<data><![CDATA[$latency]]></data>"
echo -e "\t<description><![CDATA[Network Latency Sensit Radio Network]]></description>"
echo -e "\t<module_group>websites</module_group>"
echo -e "\t</module>"

done <sensit.txt
--------------------------------------------------

When running this script manually in the terminal the output is like this:

-------------------------------------------------

        <name><![CDATA[Gateways: Nedap-groenlo]]></name>
        <type>generic_data</type>
        <data><![CDATA[0]]></data>
        <description><![CDATA[amount of absent gateways]]></description>
        <module_group>websites</module_group>
        </module>
        <module>
        <name><![CDATA[Latency: Nedap-groenlo]]></name>
        <type>generic_data</type>
        <data><![CDATA[2]]></data>
        <description><![CDATA[Network Latency Sensit Radio Network]]></description>
        <module_group>websites</module_group>
        </module>
        <module>
        <name><![CDATA[Gateways: Huawei]]></name>
        <type>generic_data</type>
        <data><![CDATA[0]]></data>
        <description><![CDATA[amount of absent gateways]]></description>
        <module_group>websites</module_group>
        </module>
        <module>
        <name><![CDATA[Latency: Huawei]]></name>
        <type>generic_data</type>
        <data><![CDATA[0]]></data>
        <description><![CDATA[Network Latency Sensit Radio Network]]></description>
        <module_group>websites</module_group>
        </module>
---------------------------------------------------------

But as soon as a add this plugin to the pandora_agent.conf, i don't get this result. I enabled the debug mode. And also no result from this plugin.

The plugin has execute rights.

I am really stuck on this. 

When i create a plugin which has fixes fields and data is works fine, other plugin which i downloaded are working as well.

hope someone can help
Hi michel.korthout,

Can you show me the results of the script when you execute it manually?
Also, show me the module config in the pandora agent conf file.

Best regards,

vic.
Hello Vic,

The result of the output when i run it manually:
        <module>
        <name><![CDATA[Gateways: Nedap-groenlo]]></name>
        <type>generic_data</type>
        <data><![CDATA[0]]></data>
        <description><![CDATA[amount of absent gateways]]></description>
        <module_group>websites</module_group>
        </module>
        <module>
        <name><![CDATA[Latency: Nedap-groenlo]]></name>
        <type>generic_data</type>
        <data><![CDATA[2]]></data>
        <description><![CDATA[Network Latency Sensit Radio Network]]></description>
        <module_group>websites</module_group>
        </module>
        <module>
        <name><![CDATA[Gateways: Huawei]]></name>
        <type>generic_data</type>
        <data><![CDATA[0]]></data>
        <description><![CDATA[amount of absent gateways]]></description>
        <module_group>websites</module_group>
        </module>
        <module>
        <name><![CDATA[Latency: Huawei]]></name>
        <type>generic_data</type>
        <data><![CDATA[0]]></data>
        <description><![CDATA[Network Latency Sensit Radio Network]]></description>
        <module_group>websites</module_group>
        </module>


The name if this plugin is called sensit_monitor

i added module_plugin sensit_monitor in the pandora_agent.conf
Hello,

i just solved the issue, this had to do with the path the the .txt file. i chanced this to an absolute path and now it works fine.

thanks