first let me apologize, i'm a network engineer, not an encoder ... so please if you carry with me here.
This is what I am opposed to, and I cannot find an elegant way for me to do this.
I use nagios (of course, many of you are familiar with it), and I get performance data from a service check. This, in particular, returns values such as: temperature at the input of module 2 temperature at the output of module 2 temperature of the module 2-a-4 temperature at the entrance to module 3 temperature at the output of module 3 input temperature of the module 4 temperature at the output of module 4 .. . and so on. These values are presented in one array. What I'm trying to do is: match the first two words / values in a string to create “groups” of array key values that will be used to generate RRD plots with ... part of RRD I don't need help, but I’m matching and finding to do.
It should also be noted that there may be different values of the array, depending on the device from which the data comes from (ie it can be displayed as "Temperature No. 1 of sensor No. 1"), and for now I do not have to worry about it at the moment , I will use this script to evaluate these values in the future to create my own graphs.
So, down to business, I was thinking of creating two arrays from the original: first use preg_match to search for /.outlet.|.asic./, since these are hot temps, and then clarify by breaking this new array into just the second value (int) or first two values (module #) for later comparison
use preg_match secondly to search for /.inlet./, since this is a "cold" pace, and then refine by breaking up this new array in the same way as the first.
Now you need to have two arrays with the key => # or key => module # then use array_intersect to find matches between the two arrays and output the keys so that I can use them to generate graphs.
It makes sense? In other words, I want the appropriate entries in module # to be selected for input in my graph. that is, the input of module 2, release 2 of the module, module 2, and then repeat the input for module 3, the output of module 3, etc.
This is what I tried and it didn't work the way I wanted:
$test = array("module 1 inlet temperature", "module 2 inlet temperature", "module 2 asic-4 temperature", "module 2 outlet temperature", "module 1 outlet temperature"); $results = array(); foreach($test as $key => $value) { preg_match("/.*inlet.*|.*asic.*/", $test[$key]); preg_match("/module [0-9]?[0-9]/", $test[$key]); $results[] = $value; } if(preg_match("/.*outlet.*/", $test[$key])); foreach($test as $key1 => $value1) { preg_match("/module [0-9]?[0-9]/", $test[$key1]); $results1[] = $value1; }
Any help here would be really appreciated. I am sure that my explanation here was rather confusing, so I hope that someone will pity me and give the guy a hand ...
Thanks in advance.