|
|
 |
« on: August 10, 2011, 08:14:05 PM » |
|
Hi guys,
Its me again,
Well i have one smallhardware (running one closed linux) and id like to create a custom agent to it.
Basically i was reading the Pandora 3.2 documentation i found
"Pandora FMS's agents can be developed in almost any language, as long as it complies with the API for data interchange with Pandora FMS's data server (defined by a data interchange XML). The Windows agents are developed in a free environment for C++ (Mingw) and use the same interface and modularity as the UNIX agents, though with quite some own peculiar oddities."
This is a closed Linux, so im not able to install Pandora_Agent as usual, but i can create a ShellScript to find out the information (cat with greps and cuts) that i want and send to my server by FTP.
Something like that (true commands):
filename=`cat /var/log/device | grep Serial | awk -F"=" '{print $2}'` gwip=`cat /apps/etc/network.cfg | grep eth0.gw0.addr | awk -F"=" '{print $2}'` lan_on=`route | grep $gwip | awk '{print $5}' | grep -c 101` tstamp=`date +%s`
#Make management string
gprsis=`cat /var/log/stat/netrouter.info | grep mobile_network_provider | awk -F":" '{print $2}' | awk -F"/" '{print $1}'` gprssignal=`cat /var/log/stat/netrouter.info | grep mobile_network_signal | awk -F":" '{print $2}'` gprsip=` cat /var/log/stat/netrouter.info | grep mobile_network_ip | awk -F":" '{print $2}'` if [ $lan_on == 0 ]; then linkis=0 string=$tstamp":"$linkis":"$gprsis":"$gprssignal":"$gprsip":" echo $string > /tmp/mngt.info ftpput -u USER -p PASS IP $filename /tmp/mngt.info else linkis=1 string=$tstamp":"$linkis":"$gprsis":"$gprssignal":"$gprsip":" echo $string > /tmp/mngt.info ftpput -u USER -p PASS IP $filename /tmp/mngt.info fi
Id like to rewrite this shell to work as an agent, so Pandora when receive the file can automatically insert into the Console. Is that possible? exit 0
|
|
|
|
|
Logged
|
|
|
|
|
|
|
 |
« Reply #1 on: August 10, 2011, 08:29:56 PM » |
|
Something like that:
filename=`cat /var/log/device | grep Serial | awk -F"=" '{print $2}'` gprsis=`cat /var/log/stat/netrouter.info | grep mobile_network_provider | awk -F":" '{print $2}' | awk -F"/" '{print $1}'` gprssignal=`cat /var/log/stat/netrouter.info | grep mobile_network_signal | awk -F":" '{print $2}'` gprsip=` cat /var/log/stat/netrouter.info | grep mobile_network_ip | awk -F":" '{print $2}'` lan_on=`route | grep $gwip | awk '{print $5}' | grep -c 101`
<agent data os_name=”Other” os_version=”1.0” timestamp=”600” agent_name=”$filename” version=”1.0”> <module> <name>gprsis</name> <type>generic_data_string</type> <data>$gprsis</data> </module> <module> <name>gprssignal</name> <type>generic_data_string</type> <data>$gprssignal</data> </module> <module> <name>gprsip</name> <type>generic_data_string</type> <data>$gprsip</data> </module> <module> <name>lan_on</name> <type>generic_boolean</type> <data>$lan_on</data> </module> </agent_data>
What else i need? How i need to save it? What name? Will FTP Service (Pandora Server) be able to recognize the file?
|
|
|
|
|
Logged
|
|
|
|
|
tpalacios
Administrator
Sr. Member
   
Karma: 8
Offline
Posts: 190
The Game
|
 |
« Reply #2 on: August 11, 2011, 10:18:33 AM » |
|
The current version of the Pandora Agent is based in Perl...
However, I'm pretty sure prior versions of the agent are based in Shell... so you might want to check them out.
If the agent provides a correct XML format, I think you shouldn't have any problem.
Regards.
|
|
|
|
|
Logged
|
|
|
|
|
|
|
 |
« Reply #3 on: August 11, 2011, 02:36:22 PM » |
|
Well i didnt know that, can someone give me some tips how to do that?
I think its a good idea to keep a Agent Based on Shell for case such as mine, i only have FTP avaliable i cant install standart agents.
Todays scenario i have one shell that send me a file with some information(by FTP), next i have to build one Plugin Module for each information in the file, so manually i have to add the Agents inserting the Plugins modules. Its bring me a lot of problems because ill have many agents based on Plugins (each with 12 modules = 12 information) and Add this manually is not good.
|
|
|
|
|
Logged
|
|
|
|
|
|
|
 |
« Reply #4 on: August 11, 2011, 10:30:19 PM » |
|
Do i really need the .checksum file or just the .data is ok? I dont have MD5 and is not possible to install it.
|
|
|
|
|
Logged
|
|
|
|
|
|