Sample code/Sh/Status Information

From GumstixDocsWiki

Jump to: navigation, search

Contents

How To Use Shell Scripts

These simple scripts allow you to monitor the status of important information on your gumstix via command line or the web.

To use these scripts:

  • copy their contents to a new file
  • save it with a sensible name like netstatus
  • make the file executable via chmod a+x+r netstatus
  • test it by typing ./netstatus
  • put it somewhere useful:
 --> /var/www/cgi-bin/  (for web access)
 --> /usr/bin/  (for general command line use from any directory)

Network Status (Web Usable)

#!/bin/sh
echo -e 'HTTP/1.1 200 OK\r\nContent-type: text/plain\r\n\r\n'
echo -e '\n  *  ifconfig Data  *  \n'
/sbin/ifconfig

echo -e '\n  *  iwconfig Data  *  \n'
/sbin/iwconfig

Processor Status (Web Usable)

#!/bin/sh
echo -e 'HTTP/1.1 200 OK\r\nContent-type: text/plain\r\n\r\n'

echo -e '\n\n  *  CPU Load Average (in %)  *  \n'
echo -e '1Min 5Min 15Mn Thrd Proc'
cat /proc/loadavg

echo -e '\n\n  *  CPU Info  *  \n'
cat /proc/cpuinfo

echo -e '\n\n  *  Current Processes  *  \n'
ps -ef

Memory Status (Web Usable)

#!/bin/sh
echo -e 'HTTP/1.1 200 OK\r\nContent-type: text/plain\r\n\r\n'
echo -e '\n\n  *  Memory Status  *  \n'
cat /proc/meminfo

Kernel Status (Web Usable)

#!/bin/sh
echo -e 'HTTP/1.1 200 OK\r\nContent-type: text/plain\r\n\r\n'
echo -e '\n  *  Kernel Messages  *  \n'
dmesg
Personal tools