Ad Widget

Collapse

How to gather data received by external script?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • forkman
    Junior Member
    • Nov 2012
    • 2

    #1

    How to gather data received by external script?

    Hello I am not sure how to do this.

    I need to monitor Ubiquiti devices which are able to send their status as HTTP POST to predefined URL. So the my question: Is possible to gather data received by that script?

    The way of communication is that:

    UBNT device -> http://some.url/script.php -> here I get parsed pamams and values

    How can I use this for serving values to zabbix?

    I have only one idea: fill some mysql database by my script and use other zabbix external script to read data from this database. But I hope it can be done by better way.

    Thank you.
  • zabbixx
    Member
    • Jul 2012
    • 71

    #2
    Hello,
    if the data is going to php script, you can try to execute there the system run command and pas the data to the shell, where you can send an SNMP trap.

    zabbix dont acept data "pasive check" via HTTP-POST ...

    check if you can
    1) sned smp-trap from that host to zabbix
    2) you config the php to execute scripts


    so there is a posibility to send the data to the zabbix!!!!

    good luck!

    Comment

    • mikovec
      Junior Member
      • Apr 2015
      • 2

      #3
      Ubiquiti

      error_reporting(E_ALL & ~E_NOTICE);
      var_export($HTTP_RAW_POST_DATA,true);

      $data=substr($HTTP_RAW_POST_DATA,strpos($HTTP_RAW_ POST_DATA,"deviceName="));

      $data=str_replace("\n\n","\n",$data);
      $data=str_replace(",","\n",$data);
      $data_l=explode("\n",$data);

      foreach ($data_l as $line) {
      $l=explode("=",$line);
      if ($l[0]) $result[$l[0]]=$l[1];
      }

      # PROCESS $result

      error_reporting(E_ALL | E_STRICT);
      require_once __DIR__ . '/vendor/autoload.php'; // using composer.phar
      /*
      method chain pattern
      */
      $sender = new \Net\Zabbix\Sender();
      $out = $sender
      ->setServerName('localhost')
      ->setServerPort(10051)
      ->setTimeout(10)
      ->addData($result["deviceName"],'ubnt.wlanConnections',abs(intval($result["wlanConnections"])))
      ->addData($result["deviceName"],'ubnt.signal',abs(intval($result["signal"])))
      ->addData($result["deviceName"],'ubnt.noise',abs(intval($result["noise"])))
      ->addData($result["deviceName"],'ubnt.ccq',abs(intval($result["ccq"])))
      ->addData($result["deviceName"],'ubnt.uptime',intval($result["uptime"]))
      ->addData($result["deviceName"],'ubnt.ackTimeout',intval($result["ackTimeout"]))
      ->addData($result["deviceName"],'ubnt.distance',intval($result["distance"]))
      ->addData($result["deviceName"],'ubnt.wlanTxRate',intval($result["wlanTxRate"]))
      ->addData($result["deviceName"],'ubnt.wlanRxRate',intval($result["wlanRxRate"]))
      ->addData($result["deviceName"],'ubnt.wlanTxLatency',intval($result["wlanTxLatency"]))
      ->addData($result["deviceName"],'ubnt.wlanTxErrors',intval($result["wlanTxErrors"]))
      ->addData($result["deviceName"],'ubnt.wlanRxErrNwid',intval($result["wlanRxErrNwid"]))
      ->addData($result["deviceName"],'ubnt.wlanRxErrFrag',intval($result["wlanRxErrFrag"]))
      ->addData($result["deviceName"],'ubnt.wlanRxErrRetries',intval($result["wlanRxErrRetries"]))
      ->addData($result["deviceName"],'ubnt.wlanRxErrBmiss',intval($result["wlanRxErrBmiss"]))
      ->addData($result["deviceName"],'ubnt.wlanRxErrOther',intval($result["wlanRxErrOther"]))
      ->addData($result["deviceName"],'ubnt.lanRxBytes',intval($result["lanRxBytes"]))
      ->addData($result["deviceName"],'ubnt.lanTxBytes',intval($result["lanTxBytes"]))
      ->addData($result["deviceName"],'ubnt.lanPlugged',intval($result["lanPlugged"]))
      ->send();

      Comment

      Working...