-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log tab on the website #101
Comments
This assumes the user that is running the controller is the user "pi". If you've set up another user on your Raspberry Pi, you'll need to change the user accordingly. Where the notes say "pi" below, substitute the user you've configured. As the user pi, do the following:
Create the file 'command' in /home/pi with your text editor. It will contain the following:
Make this file executable:
Create the file 'parse.awk' in /home/pi with your text editor. It will contain the following:
Create the file 'txtstyle.css' in /home/pi/garage-door-controller/www/css. It will contain the following:
Edit the 'index.html' file in /home/pi/garage-door-controller/www with your text editor. Below these lines:
Insert this line: Now set the command to be automatically executed periodically. You'll be editing the system crontab, so be careful not to change things already there. You're going to add a line to the file that will execute the command to populate garage_door.html ever 10 minutes. With your text editor do the following:
Add this line:
Save and exit nano (or whatever text editor you're using). Notes: Every 10 minutes, the system will execute /home/pi/command. The command pulls every line containing "garage_controller" and passes them to the awk script which converts the text to some minimal html. The script only passes along the lines that don't contain the word "toggled", and pulls out the timestamp and the relevant text. The output of the script is written to the garage_door.html file in the www folder. Whenever you browse to the web page, index.html will pull in the text in the garage_door.html file and display it on the page. Voila! |
Thanks a lot.
It works perfectly.
My 2 cents : the file ‘command’ : I have used ‘tac’ instead of ‘cat’ because I prefer to have the last records first :)
Gilles
From: NCAvian [mailto:notifications@github.com]
Sent: samedi 16 février 2019 05:09
To: andrewshilliday/garage-door-controller <garage-door-controller@noreply.github.com>
Cc: Subscribed <subscribed@noreply.github.com>
Subject: Re: [andrewshilliday/garage-door-controller] Log tab on the website (#101)
This assumes the user that is running the controller is the user "pi". If you've set up another user on your Raspberry Pi, you'll need to change the user accordingly. Where the notes say "pi" below, substitute the user you've configured.
As the user pi, do the following:
cd /home/pi
touch garage-door-controller/www/garage_door.html
Create the file 'command' in /home/pi with your text editor. It will contain the following:
#!/bin/bash
cat /var/log/syslog | grep 'garage_controller' | awk -f /home/pi/parse.awk > /home/pi/garage-door-controller/www/garage_door.html
Make this file executable:
chmod +x command
Create the file 'parse.awk' in /home/pi with your text editor. It will contain the following:
BEGIN {print "<html><link href='/css/txtstyle.css' rel='stylesheet' type='text/css' /><p>"}
! /toggled/ {print substr($0,1,16) substr($0,45) "<br>"}
END {print "</p></html>"}
Create the file 'txtstyle.css' in /home/pi/garage-door-controller/www/css. It will contain the following:
html, body {font-family:Helvetica, Arial, sans-serif; line-height: 10px; white-space: pre-wrap;}
Edit the 'index.html' file in /home/pi/garage-door-controller/www with your text editor. Below these lines:
<div class="content-primary">
<ul id="doorlist" data-role="listview"></ul>
</div>
Insert this line:
<div id="list"><p><iframe src="garage_door.html" width=400 height=600 frameborder=0 ></iframe></p></div>
Now set the command to be automatically executed periodically. You'll be editing the system crontab, so be careful not to change things already there. You're going to add a line to the file that will execute the command to populate garage_door.html ever 10 minutes. With your text editor do the following:
sudo nano /etc/crontab
Add this line:
*/10 * * * * root /home/pi/command
Save and exit nano (or whatever text editor you're using).
Notes:
The files 'txtstyle.css' and 'garage_door.html' must be owned by the pi user in order to work properly. If root owns them, you'll get missing file errors in the web browser.
Every 10 minutes, the system will execute /home/pi/command. The command pulls every line containing "garage_controller" and passes them to the awk script which converts the text to some minimal html. The script only passes along the lines that don't contain the word "toggled", and pulls out the timestamp and the relevant text. The output of the script is written to the garage_door.html file in the www folder. Whenever you browse to the web page, index.html will pull in the text in the garage_door.html file and display it on the page.
Voila!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#101 (comment)> , or mute the thread <https://github.com/notifications/unsubscribe-auth/AQHIgYGOhsawBxP1EoW__L-yaEAKpN1Iks5vN4RygaJpZM4Zo70i> . <https://github.com/notifications/beacon/AQHIgWrwPqzoQ1Uiu5pnaJlVeAVQA-Emks5vN4RygaJpZM4Zo70i.gif>
|
Good deal! It was easier than I thought. I'm not an html guru, but I can Google them!Bob On Feb 16, 2019 12:48 PM, Gilles94500 <notifications@github.com> wrote:Thanks a lot.
It works perfectly.
My 2 cents : the file ‘command’ : I have used ‘tac’ instead of ‘cat’ because I prefer to have the last records first :)
Gilles
From: NCAvian [mailto:notifications@github.com]
Sent: samedi 16 février 2019 05:09
To: andrewshilliday/garage-door-controller <garage-door-controller@noreply.github.com>
Cc: Subscribed <subscribed@noreply.github.com>
Subject: Re: [andrewshilliday/garage-door-controller] Log tab on the website (#101)
This assumes the user that is running the controller is the user "pi". If you've set up another user on your Raspberry Pi, you'll need to change the user accordingly. Where the notes say "pi" below, substitute the user you've configured.
As the user pi, do the following:
cd /home/pi
touch garage-door-controller/www/garage_door.html
Create the file 'command' in /home/pi with your text editor. It will contain the following:
#!/bin/bash
cat /var/log/syslog | grep 'garage_controller' | awk -f /home/pi/parse.awk > /home/pi/garage-door-controller/www/garage_door.html
Make this file executable:
chmod +x command
Create the file 'parse.awk' in /home/pi with your text editor. It will contain the following:
BEGIN {print "<html><link href='/css/txtstyle.css' rel='stylesheet' type='text/css' /><p>"}
! /toggled/ {print substr($0,1,16) substr($0,45) "<br>"}
END {print "</p></html>"}
Create the file 'txtstyle.css' in /home/pi/garage-door-controller/www/css. It will contain the following:
html, body {font-family:Helvetica, Arial, sans-serif; line-height: 10px; white-space: pre-wrap;}
Edit the 'index.html' file in /home/pi/garage-door-controller/www with your text editor. Below these lines:
<div class="content-primary">
<ul id="doorlist" data-role="listview"></ul>
</div>
Insert this line:
<div id="list"><p><iframe src="garage_door.html" width=400 height=600 frameborder=0 ></iframe></p></div>
Now set the command to be automatically executed periodically. You'll be editing the system crontab, so be careful not to change things already there. You're going to add a line to the file that will execute the command to populate garage_door.html ever 10 minutes. With your text editor do the following:
sudo nano /etc/crontab
Add this line:
*/10 * * * * root /home/pi/command
Save and exit nano (or whatever text editor you're using).
Notes:
The files 'txtstyle.css' and 'garage_door.html' must be owned by the pi user in order to work properly. If root owns them, you'll get missing file errors in the web browser.
Every 10 minutes, the system will execute /home/pi/command. The command pulls every line containing "garage_controller" and passes them to the awk script which converts the text to some minimal html. The script only passes along the lines that don't contain the word "toggled", and pulls out the timestamp and the relevant text. The output of the script is written to the garage_door.html file in the www folder. Whenever you browse to the web page, index.html will pull in the text in the garage_door.html file and display it on the page.
Voila!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#101 (comment)> , or mute the thread <https://github.com/notifications/unsubscribe-auth/AQHIgYGOhsawBxP1EoW__L-yaEAKpN1Iks5vN4RygaJpZM4Zo70i> . <https://github.com/notifications/beacon/AQHIgWrwPqzoQ1Uiu5pnaJlVeAVQA-Emks5vN4RygaJpZM4Zo70i.gif>
—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or mute the thread.
|
Feature request:
Have a tab on the website that displays the log info either from syslog (grep garage_controller) or the files dumped to a specific file.
The text was updated successfully, but these errors were encountered: