Skip to content

Instantly share code, notes, and snippets.

@KokoseiJ
Last active May 25, 2023 17:13
Show Gist options
  • Save KokoseiJ/1837ba17c954465575364a606fcc8d11 to your computer and use it in GitHub Desktop.
Save KokoseiJ/1837ba17c954465575364a606fcc8d11 to your computer and use it in GitHub Desktop.
Simple sensord setup with Lighttpd for CGI monitoring utilization
server.modules=("mod_cgi")
server.breakagelog="/var/log/cgi_error.log"
server.document-root="/tmp/www"
server.port=1727
cgi.assign=(".cgi"=>"")
[Unit]
Description="Lighttpd service"
Wants=sensord.service
[Service]
Type=simple
ExecStart=/etc/templogging/lighttpd/lighttpd -D -m /etc/templogging/lighttpd/libs -f /etc/templogging/lighttpd.conf
[Install]
WantedBy=multi-user.target
#!/bin/sh
mkdir -p /tmp/www/sensord
sensord -a -r /var/log/sensord.rrd -g /tmp/www/sensord | tee /tmp/www/sensord.cgi
chmod +x /tmp/www/sensord.cgi
ln -s /var/log/sensord.rrd /tmp/www/
[Unit]
Description="Sensord Daemon for Temperature Logging"
[Service]
Type=forking
PIDFile=/var/run/sensord.pid
ExecStart=sensord -a -r /var/log/sensord.rrd
ExecStartPre=/etc/templogging/pre_start.sh
[Install]
WantedBy=multi-user.target
mkdir -p /etc/templogging
tee /etc/templogging/pre_start.sh <<EOF
#!/bin/sh
mkdir -p /tmp/www/sensord
sensord -a -r /var/log/sensord.rrd -g /tmp/www/sensord | tee /tmp/www/sensord.cgi
chmod +x /tmp/www/sensord.cgi
rm -rf /tmp/www/sensord.rrd
ln -s /var/log/sensord.rrd /tmp/www/sensord.rrd
EOF
chmod +x /etc/templogging/pre_start.sh
tee /etc/templogging/lighttpd.conf <<EOF
server.modules=("mod_cgi")
server.breakagelog="/var/log/cgi_error.log"
server.document-root="/tmp/www"
server.port=1727
cgi.assign=(".cgi"=>"")
EOF
tee /etc/systemd/system/sensord.service <<EOF
[Unit]
Description="Sensord Daemon for Temperature Logging"
[Service]
Type=forking
PIDFile=/var/run/sensord.pid
ExecStart=sensord -a -t 5 -r /var/log/sensord.rrd
ExecStartPre=/etc/templogging/pre_start.sh
[Install]
WantedBy=multi-user.target
EOF
tee /etc/systemd/system/lighttpd.service <<EOF
[Unit]
Description="Lighttpd service"
Wants=sensord.service
[Service]
Type=simple
ExecStart=lighttpd -D -f /etc/templogging/lighttpd.conf
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now sensord lighttpd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment