I am trying to make an extension attribute to report which network segment a device is in for reporting to a "search inventory" report. Since you cannot really report on JAMFs network segments in settings in any meaningful way I am trying an extension attribute. Thankfully I only have 3 segments of interest for this specific situation.
We have a number of Mac Mini’s in our datacenter for contractors to remote access. I am trying to provide something easy for support to look at in an inventory report that tells them which computer belongs to which segment when they go to assign a device. I’m wanting it to tell them which vendors subnet the device is in (ie result1) as our support could not remember IP ranges if their live depended on it.
The following is what I was able to come up with however all devices come back with the "Does not fall in to 3 results" result regardless of their IP address. I have not tried to make an EA this complex before and have not really found anything useful so I am sure I missed something simple. Any help or suggestions would be much appreciated.
I have changed information to protect the identity of the individuals involved and to keep my legal team happy.
#!/bin/sh
IPAddress=$(ifconfig | grep "inet " | grep -Fv 127.0.0.1 | awk '{print $2}')
if [[$IPAddress =~ 10.1.[147].*]]; then
echo "<result>Result1</result>"
elif [[$IPAddress =~ 10.1.[246].*]]; then
echo "<result>result2</result>"
elif [[$IPAddress =~ 10.1.[345].*]]; then
echo "<result>result3</result>"
else
echo "<result>Does not fall in to 3 results<result>"
fi