So my goal here is to create a simple extension attribute that will tell me whether a device is on or off the network. Given the wide swath of 10.x.x.x IPs that we use here (some are internal on the network, others are guest off the network), and the logic to that is hard to boil down easily, I have decided to go at this with an extension attribute.
Basically the extension attribute would go something like this:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE extensionAttribute PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<extensionAttribute>
<displayName>On the network or not</displayName>
<displayInCategory/>
<dataType>string</dataType>
<description>This Extension Attribute will let me know whether it is possible to ping a specific only on the network site. If the device cannot ping this site, then it is off the network.</description>
<scriptContentsMac>#!/bin/sh
# my goal here is to send 2 pings to a given internal server. I know a status of 0 on exit means I can successfully ping the server. I just don't know how to write this syntax
if [ /sbin/ping -c 2 'myinternalserver.local' HELP NEEDED HERE TO WRITE SYNTAX, IF THIS PING EXITS WITH A 0 STATUS ] ; then
/bin/echo "on the network"
else
/bin/echo "off the network"
fi
exit</scriptContentsMac>
</extensionAttribute>