Retrieve entire timestamp hexadecimal string from snmp to $value so I can pass to a user function

I have a time stamp that is hexadecimal:
.1.3.6.1.4.1.4130.10.2.4.1.2.3.1.8.12.11110 = Hex-STRING: 07 E7 07 1C 0C 33 24 00 2B 00 00
That comes out to 2023-07-28 12:51:36 00 36 00 00 for a date and time. I just need the date and time to the minute (07 E7 07 1C 0C 33). The value gets parsed down to just 07 during the discover or poller. Is there a way to get the whole hexadecimal passed to $value so I can run it through a user function and convert it so I can create a last seen x minutes ago poll?

I figured it out. I had to create another class. Then I had to catch the value in the functions.inc.php and covert it using this code to turn it into minutes as an integer. I am not the greatest at coding, but it works. :grinning:

if ($class === ‘visible’) {
// transfer hex date
$sensor_value = $mysensor_value;
$sensor_value = preg_replace(‘/\s+/’, ‘’, $sensor_value);
$vyears = hexdec(substr($sensor_value, 0, 4));
$vmonths = hexdec(substr($sensor_value, 4, 2));
$vdays = hexdec(substr($sensor_value, 6, 2));
$vhours = hexdec(substr($sensor_value, 8, 2));
$vminutes = hexdec(substr($sensor_value, 10, 2));
$vsecondss = hexdec(substr($sensor_value, 12, 2));
$time_sers = date(“Y-m-d H:i:s”);
echo “Server time: “.$time_sers.”\n”;
$time_sds = “$vyears-$vmonths-$vdays $vhours:$vminutes:$vsecondss”;
echo “Remote radio last seen: “.$time_sds.”\n”;
$from_times = strtotime($time_sds);
$to_times = strtotime($time_sers);
$sensor_value = round(abs($from_times - $to_times) / 60,2);
$time_adjust = 22;
$sensor_value = $sensor_value - $time_adjust;
}
echo “after function: “.$sensor_value .”\n”;

input from snmp:
.1.3.6.1.4.1.4130.10.2.4.1.2.3.1.8.12.11110 = Hex-STRING: 07 E7 07 1C 0C 33 24 00 2B 00 00

output:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.