Skip to content

Instantly share code, notes, and snippets.

@EricMyers
Last active January 5, 2021 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EricMyers/f164c32a2d096c95fe82b88eeb044fbd to your computer and use it in GitHub Desktop.
Save EricMyers/f164c32a2d096c95fe82b88eeb044fbd to your computer and use it in GitHub Desktop.
Sample monitoring for a Raspberry Pi Access Point
<?php
echo "<html>\n<head>\n";
$hostname=`hostname`;
echo "<title>$hostname</title>\n";
// Refresh the page periodically
echo "<meta http-equiv='Refresh' content='47; URL=/'>\n";
echo "</head><body>\n";
function showit($title, $cmd_output){
echo "\n<h4 style='background: MidnightBlue; color: white; padding: 7px'> $t
itle </h4>\n";
if(empty($cmd_output)) {
echo "<div style='background: pink'><pre>NOT DETECTED </pre></div>\n";
}
else {
echo "<pre>$cmd_output </pre>\n";
}
}
$timestamp=`date`;
showit("$hostname", "Status as of $timestamp");
showit("Uptime", `uptime`);
showit("Host Access Point Daemon (hostapd)", `ps aux | grep hostapd | grep -v grep`);
showit("DHCP server daemon", `ps aux | grep dhcpd | grep -v grep`);
showit("Route", `route -n`);
showit("Interfaces", `ifconfig|egrep -v "TX|RX"`);
showit("Interface Statistics", `netstat -i`);
showit("Who", `who`);
showit("Web Server (nginx)", `ps aux | grep nginx | grep -v grep`);
showit("CPU Info", `cat /proc/cpuinfo`);
echo "</body>\n</html>\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment