Attached is a (very) preliminary patch for extending the "cpu" discovery
agent to support non-x86 processors, specifically 32-bit ARM systems in
this case...and single CPU systems to be even more specific. Example
output is:
{
"discovertype": "cpu",
"description": "CPU information",
"host": "apc-apricot",
"source": "./cpu",
"data": {
"ARMv6-compatible processor rev 7 (v6l)": {
"BogoMIPS": 532.24,
"Features":
{"swp":true,"half":true,"thumb":true,"fastmult":true,"vfp":true,"edsp":true,"java":true},
"CPU implementer": "0x41",
"CPU architecture": 7,
"CPU variant": "0x0",
"CPU part": "0xb76",
"CPU revision": 7,
"Hardware": "WMT",
"Revision": 0000,
"Serial": 0000000000000000,
"MemTotal": 461604
}
}
}
The patch also provides a framework for supporting even more CPU
architectures. Output of the "uname -m" command drives this and the text
matching was largely gleaned from a few automake "configure" scripts.
Processors that don't have a parser for the CPU data currently just
return the output of "uname -m" and the string "unsupported" for now:
{
"discovertype": "cpu",
"description": "CPU information",
"host": "not-really-an-irix",
"source": "./cpu",
"data": {
"mips": "unsupported"
}
}
Let me know what you think! Just be kind... I'm knocking off the rust as
I go along here :-)
--- discovery_agents/cpu.orig 2013-03-24 10:31:07.000000000 -0500
+++ discovery_agents/cpu 2013-04-14 21:55:00.000000000 -0500
@@ -63,10 +63,7 @@
printf '}'
}
-# Discover our CPU info from /proc/cpuinfo (and a little from /proc/meminfo)
-discover() {
- proccomma=''
- comma=''
+emit_prolog() {
cat <<-!
{
"discovertype": "cpu",
@@ -75,7 +72,17 @@
"source": "$0",
"data": {
!
- # Parse /proc/cpuinfo
+}
+
+emit_epilog() {
+ printf '\n }\n }\n}\n'
+}
+
+# Discover our CPU info from /proc/cpuinfo (and a little from /proc/meminfo)
+discover_x86() {
+ emit_prolog
+ proccomma=''
+ comma=''
(cat $CPUINFO;
egrep '^(MemTotal|Hugepagesize):' <$MEMINFO | sed 's% kB$%%') |
while
@@ -103,7 +110,88 @@
comma=',
'
done
- printf '\n }\n }\n}\n'
+ emit_epilog
}
-discover
+discover_arm() {
+ emit_prolog
+ proccomma=''
+ comma=''
+ (cat $CPUINFO;
+ egrep '^(MemTotal):' <$MEMINFO | sed 's% kB$%%') |
+ while
+ read line
+ do
+ case $line in
+ Processor*)
+ proc=$(echo $line | sed -e 's%.*:[ ]*%"%' -e 's%$%":%')
+ printf '%s %s {\n ' "$proccomma" "$proc"
+ proccomma='
+ },
+'
+ comma=''
+ continue;;
+ "") continue;;
+ esac
+ name=$(echo "$line" | sed -e 's%[ ]*:.*%%')
+ value=$(echo "$line" | sed -e 's%.*:[ ]*%%')
+ # Format "Features" as a JSON hash table of boolean-valued names
+ case $name in
+ Features*)
+ printf '%s"%s": %s' "$comma" "$name" "$(fmtflags $value)";;
+ *) printf '%s"%s": %s' "$comma" "$name" "$(scalarfmt "$value")";;
+ esac
+ comma=',
+ '
+ done
+ emit_epilog
+}
+
+
+cpu_unsupported() {
+ emit_prolog
+ printf ' "%s": "unsupported"\n }\n}\n' "$1"
+}
+
+arch=$(uname -m)
+case "$arch" in
+ aarch64|arm64)
+ # discover_aarch64
+ cpu_unsupported $arch
+ ;;
+ arm*|iPad*)
+ discover_arm
+ ;;
+ mips*|IP*)
+ # discover_mips
+ cpu_unsupported $arch
+ ;;
+ parisc*|hppa*)
+ # discover_parisc
+ cpu_unsupported $arch
+ ;;
+ "Power Macintosh"|ppc*|powerpc*)
+ # discover_ppc
+ cpu_unsupported $arch
+ ;;
+ s390|s390x)
+ # discover_s390
+ cpu_unsupported $arch
+ ;;
+ sh4|sh)
+ # discover_sh4
+ cpu_unsupported $arch
+ ;;
+ sun4u|sparc*)
+ # discover_sparc
+ cpu_unsupported $arch
+ ;;
+ tilegx|tile-gx)
+ # discover_tilegx
+ cpu_unsupported $arch
+ ;;
+ i[3-6]86|i86pc|BePC|x86pc|x86_64|x86_32|amd64|bdver)
+ discover_x86
+ ;;
+esac
+
_______________________________________________
Assimilation mailing list - Discovery-Driven Monitoring
[email protected]
http://lists.community.tummy.com/cgi-bin/mailman/listinfo/assimilation
http://assimmon.org/