Custom Equipment Monitoring with Openwrt and Carambola
Total Page:16
File Type:pdf, Size:1020Kb
Custom Equipment Monitoring with OpenWRT and Carambola Sysadmin Miniconf Linux.conf.au Perth - 6 January 2014 Andrew McDonnell - Software Engineer & Tech Problem Solver [email protected] Twitter: @pastcompute http://blog.oldcomputerjunk.net https://launchpad.net/~andymc73 https://github.com/andymc73 Overview ● Equipment Monitoring with a Budget ● Introduction to Carambola ● Introduction to OpenWRT ● Monitoring with OpenWRT and Carambola Andrew McDonnell – LCA2014 Sysadmin Miniconf - Custom equipment monitoring with OpenWRT and Carambola – [email protected] 2 Use Case ● Everything has a computer in it these days ● And a connection: http://en.wikipedia.org/wiki/File:SolarpanelBp.JPG http://en.wikipedia.org/wiki/File:2008-07-11_Air_conditioners_at_UNC-CH.jpg http://en.wikipedia.org/wiki/File:Davis_VantagePro.jpg Andrew McDonnell – LCA2014 Sysadmin Miniconf - Custom equipment monitoring with OpenWRT and Carambola – [email protected] 3 Use Case Requirements ● So if you have a <insert widget here>? ● And a small physical space requirement? ● How do you have it talk to <insert toolkit here>? i2c rs485 http://openclipart.org/detail/182810/old-computer-by-jhnri4-182810 http://openclipart.org/detail/188441/sid-chip-by-arvin61r58-188441 Andrew McDonnell – LCA2014 Sysadmin Miniconf - Custom equipment monitoring with OpenWRT and Carambola – [email protected] 4 Potential Solutions ● Industrial COTS ● Embedded microcontrollers ● arduino ● Embedded Linux ● Raspberry Pi ● Beaglebone Black ● Carambola2 http://www.openelectrical.org/wiki/images/4/43/Programmable-logic-controller-plc-22971.jpg Andrew McDonnell – LCA2014 Sysadmin Miniconf - Custom equipment monitoring with OpenWRT and Carambola – [email protected] 5 Embedded Linux Computers. ● Raspberry Pi ● Beaglebone black – Aimed at education market – High performance – Small footprint, very cheap – Good connectivity – Power, Ethernet performance? – Runs various distros Image: Andy Kirkpatrick http://en.wikipedia.org/wiki/File:RaspberryPi.jpg Andrew McDonnell – LCA2014 Sysadmin Miniconf - Custom equipment monitoring with OpenWRT and Carambola – [email protected] 6 Image: andrewmcdonnell.net Carambola2 Andrew McDonnell – LCA2014 Sysadmin Miniconf - Custom equipment monitoring with OpenWRT and Carambola – [email protected] 7 Embedded Linux : Carambola2 ● Carambola2 – Very cheap < $100 with cabling & casing, small footprint – Build from even smaller module and connector board – Integrated wifi, plus dual ethernet with switch – USB host and USB serial slave – Low power usage – GPIO: SPI, I2C, serial & RS485, i2s, SPDIF – AR9331 SOC – MIPS 400MHz, 64MB RAM – Runs OpenWRT Linux – https://github.com/8devices/ http://8devices.com/wiki_carambola/doku.php/carambola Andrew McDonnell – LCA2014 Sysadmin Miniconf - Custom equipment monitoring with OpenWRT and Carambola – [email protected] 8 Image: andrewmcdonnell.net Andrew McDonnell – LCA2014 Sysadmin Miniconf - Custom equipment monitoring with OpenWRT and Carambola – [email protected] 9 Simple Carambola solution example i2c web snmp http://openclipart.org/detail/1723/stacked_servers-by-ajith http://openclipart.org/detail/18063/hobbs-hour-meter-by-startright Andrew McDonnell – LCA2014 Sysadmin Miniconf - Custom equipment monitoring with OpenWRT and Carambola – [email protected] 10 OpenWRT Linux & Carambola ● OpenWRT is an embedded Linux distribution ● OpenWRT has GPLv2 license ● Carambola: designed with ease of use of OpenWRT in mind ● 8devices maintained github fork of OpenWRT ● The Carambola2 ships with OpenWRT installed ● Firmware images and package library at http://pkg.8devices.com/?dir=v2.4/carambola2/ Andrew McDonnell – LCA2014 Sysadmin Miniconf - Custom equipment monitoring with OpenWRT and Carambola – [email protected] 11 What is OpenWRT? ● In their own words: “Instead of trying to create a single, static firmware, OpenWrt provides a fully writable filesystem with package management. This frees you from the application selection and configuration provided by the vendor and allows you to customize the device through the use of packages to suit any application. For developer, OpenWrt is the framework to build an application without having to build a complete firmware around it; for users this means the ability for full customization, to use the device in ways never envisioned.” http://en.wikipedia.org/wiki/File:Linksys_WRT54G_V1.jpg Andrew McDonnell – LCA2014 Sysadmin Miniconf - Custom equipment monitoring with OpenWRT and Carambola – [email protected] 12 OpenWRT features ● Large package library ● OPKG – package management system ● UCI – common configuration interface ● LUCI – polished web interface ● Community project ● Open Source (GPL v2) Andrew McDonnell – LCA2014 Sysadmin Miniconf - Custom equipment monitoring with OpenWRT and Carambola – [email protected] 13 OpenWRT Tour $$ sshssh root@openwrtroot@openwrt BusyBoxBusyBox v1.15.3v1.15.3 (2010-04-06(2010-04-06 03:14:1103:14:11 CEST)CEST) built-inbuilt-in shellshell (ash)(ash) EnterEnter 'help''help' forfor aa listlist ofof built-inbuilt-in commands.commands. ______________ ________________ ____ || |.-----.-----.-----.||.-----.-----.-----.| || || |.----.||.----.| |_|_ || -- |||| __ || -__|-__| |||| || || |||| _||_|| _|_| |_______|||_______|| __|_____|__|__||________||__|__|_____|__|__||________||__| |____||____| |__||__| WW II RR EE LL EE SS SS FF RR EE EE DD OO MM BackfireBackfire (10.03,(10.03, r20728)r20728) ---------------------------------------------------- ** 1/31/3 shotshot KahluaKahlua InIn aa shotshot glass,glass, layerlayer KahluaKahlua ** 1/31/3 shotshot Bailey'sBailey's onon thethe bottom,bottom, thenthen Bailey's,Bailey's, ** 1/31/3 shotshot VodkaVodka thenthen Vodka.Vodka. ------------------------------------------------------------------------------------------------------ root@openwrt:~#root@openwrt:~# Andrew McDonnell – LCA2014 Sysadmin Miniconf - Custom equipment monitoring with OpenWRT and Carambola – [email protected] 14 It really is Linux... ## psps PIDPID USERUSER VSZVSZ STATSTAT COMMANDCOMMAND 11 rootroot 13601360 SS initinit 22 rootroot 00 SWSW [kthreadd][kthreadd] 33 rootroot 00 SWSW [ksoftirqd/0][ksoftirqd/0] 44 rootroot 00 SWSW [events/0][events/0] 55 rootroot 00 SWSW [khelper][khelper] 88 rootroot 00 SWSW [async/mgr][async/mgr] 4141 rootroot 00 SWSW [sync_supers][sync_supers] 4343 rootroot 00 SWSW [bdi-default][bdi-default] 4545 rootroot 00 SWSW [kblockd/0][kblockd/0] 7171 rootroot 00 SWSW [aio/0][aio/0] 8484 rootroot 00 SWSW [mtdblockd][mtdblockd] 9090 rootroot 00 SWSW [ar71xx-spi][ar71xx-spi] 225225 rootroot 00 SWSW [ipolldevd][ipolldevd] 279279 rootroot 00 SWNSWN [jffs2_gcd_mtd3][jffs2_gcd_mtd3] 294294 rootroot 13601360 SS initinit 313313 rootroot 13641364 SS syslogdsyslogd -C16-C16 -L-L -R-R 192.168.1.27:514192.168.1.27:514 315315 rootroot 13481348 SS klogdklogd 809809 rootroot 00 SWSW [cfg80211][cfg80211] 12571257 rootroot 00 SWSW [phy0][phy0] 45384538 rootroot 11361136 SS /usr/sbin/dropbear/usr/sbin/dropbear -p-p 192.168.1.11:22192.168.1.11:22 -P-P /var/run/dro/var/run/dro 45584558 rootroot 26722672 SS /usr/sbin/sshd/usr/sbin/sshd 45734573 rootroot 14641464 SS /usr/sbin/uhttpd/usr/sbin/uhttpd -f-f -h-h /www/www -r-r tytotyto -x-x /cgi-bin/cgi-bin -t-t 6060 47804780 nobodynobody 12201220 SS gkrellmdgkrellmd 48084808 rootroot 00 SW<SW< [loop0][loop0] 48154815 rootroot 13561356 SS watchdogwatchdog -t-t 55 /dev/watchdog/dev/watchdog 92539253 rootroot 14361436 SS hostapdhostapd -P-P /var/run/wifi-phy0.pid/var/run/wifi-phy0.pid -B-B /var/run/hostapd/var/run/hostapd 1318613186 rootroot 13321332 SS /usr/sbin/ntpd/usr/sbin/ntpd -g-g -p-p /var/run/ntpd.pid/var/run/ntpd.pid 1318713187 rootroot 14401440 SS /bin/sh/bin/sh /usr/lib/ddns/dynamic_dns_updater.sh/usr/lib/ddns/dynamic_dns_updater.sh myddnsmyddns 00 1327813278 rootroot 13681368 SS udhcpcudhcpc -t-t 00 -i-i eth0.2eth0.2 -b-b -p-p /var/run/eth0.2.pid/var/run/eth0.2.pid -O-O roro 1399313993 nobodynobody 920920 SS /usr/sbin/dnsmasq/usr/sbin/dnsmasq -K-K -D-D -f-f -N-N -q-q -y-y -Z-Z -b-b -E-E -z-z -s-s eaea 1400414004 rootroot 44404440 SS arpwatcharpwatch -f-f /sd/var/arpwatch/arp.dat/sd/var/arpwatch/arp.dat -i-i br-lanbr-lan Andrew McDonnell – LCA2014 Sysadmin Miniconf - Custom equipment monitoring with OpenWRT and Carambola – [email protected] 15 OpenWRT web interface Andrew McDonnell – LCA2014 Sysadmin Miniconf - Custom equipment monitoring with OpenWRT and Carambola – [email protected] 16 OpenWRT Package Management ## opkgopkg list_installedlist_installed |head|head arptablesarptables -- 0.0.3-3-10.0.3-3-1 arpwatcharpwatch -- 2.1a15-22.1a15-2 base-filesbase-files -- 42-r2072842-r20728 bind-digbind-dig -- 9.7.2-P3-19.7.2-P3-1 bind-hostbind-host -- 9.7.2-P3-19.7.2-P3-1 bind-libsbind-libs -- 9.6.1-P2-29.6.1-P2-2 block-hotplugblock-hotplug -- 0.1.0-10.1.0-1 block-mountblock-mount -- 0.1.0-10.1.0-1 busyboxbusybox -- 1.15.3-21.15.3-2 Bzip2Bzip2 –– 1.0.5-11.0.5-1 ## opkgopkg searchsearch /bin/vi/bin/vi BusyboxBusybox –– 1.15.3-21.15.3-2 ## opkgopkg installinstall -d-d extext tcpdumptcpdump UpgradingUpgrading tcpdumptcpdump onon extext fromfrom 4.0.0-24.0.0-2 toto 4.1.1-2...4.1.1-2... DownloadingDownloading http://downloads.openwrt.org/.../ar71xx/packages/tcpdump_4.1.1-2_ar71xx.ipk.http://downloads.openwrt.org/.../ar71xx/packages/tcpdump_4.1.1-2_ar71xx.ipk. ConfiguringConfiguring tcpdumptcpdump ## opkgopkg filesfiles tcpdumptcpdump PackagePackage tcpdumptcpdump (4.1.1-2)(4.1.1-2) isis installedinstalled