ℹ️ Your data is safe here... unless you make the SNIP gods angry. And let's just say they have a really bad sense of humor.

From wraggzeh, 4 Years ago, written in PHP.
Embed
  1. <?php
  2. use LibreNMS\RRD\RrdDefinition;
  3.  
  4. $name = 'cabinet_climate';
  5. $app_id = $app['app_id'];
  6. $options = '-Oqv';
  7. $oid = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.15.99.97.98.105.110.101.116.95.99.108.105.109.97.116.101';
  8.  
  9. $cabinet_climate = snmp_walk($device, $oid, $options);
  10.  
  11. $inside_cabinet_temperature,
  12. $inside_cabinet_humidity,
  13. $outside_cabinet_temperature,
  14. $outside_cabinet_humidity,
  15. ) = explode("\n", $cabinetclimate);
  16.  
  17. $rrd_name = array(
  18.     'app',
  19.     $name,
  20.     $app_id
  21. );
  22.  
  23. $rrd_def = RrdDefinition::make()
  24.     ->addDataset('inside_cabinet_temperature', 'GAUGE', 0)
  25.     ->addDataset('inside_cabinet_humidity', 'GAUGE', 0)
  26.     ->addDataset('outside_cabinet_temperature', 'GAUGE', 0)
  27.     ->addDataset('outside_cabinet_humidity', 'GAUGE', 0)
  28. ;
  29.  
  30. $fields = array(
  31.     'inside_cabinet_temperature' => $inside_cabinet_temperature,
  32.     'inside_cabinet_humidity' => $inside_cabinet_humidity,
  33.     'outside_cabinet_temperature' => $outside_cabinet_temperature,
  34.     'outside_cabinet_humidity' => $outside_cabinet_humidity,
  35. );
  36.  
  37. $tags = array(
  38.     'name' => $name,
  39.     'app_id' => $app_id,
  40.     'rrd_def' => $rrd_def,
  41.     'rrd_name' => $rrd_name
  42. );
  43.  
  44. data_update($device, 'app', $tags, $fields);
  45. update_application($app, $cabinetclimate, $fields);
captcha