tslenter / RSX-RSC

Remote Syslog Core / X / C
https://www.remotesyslog.com/
GNU General Public License v3.0
8 stars 1 forks source link

Installing on Ubuntu 20.04/Rasberry PI web live console does not work. #38

Closed auadams closed 3 years ago

auadams commented 3 years ago

I noticed after install i cannot get the live console to work. I do have active sys logs hitting the file specified in the syslog-ns

in the option menu there appears to be the following errors

Archive Notice: Undefined index: pg in /var/www/html/rsc/PHPTail.php on line 355

Test message Notice: Undefined index: pg in /var/www/html/rsc/PHPTail.php on line 356

These errors are causing the log to not apear in my webgui.

for reference the rscli works just fine.

auadams commented 3 years ago

further inspection it apears this is the issue on the web console. Warning: filesize(): stat failed for /var/log/remote_syslog/remote_syslog.log in /var/www/html/rsc/PHPTail.php on line 95 {"size":false,"file":"\/var\/log\/remote_syslog\/remote_syslog.log","data":[]}

 public function getNewLines($file, $lastFetchedSize, $grepKeyword, $invert) {
        /**
         * Clear the stat cache to get the latest results
         */
        clearstatcache();
        /**
         * Define how much we should load from the log file
         * @var
         */
        if(empty($file)) {
            $file = key(array_slice($this->log, 0, 1, true));
        }
        $fsize = filesize($this->log[$file]); <--- This line right here is failing
        $maxLength = ($fsize - $lastFetchedSize);
        /**
         * Verify that we don't load more data then allowed.
         */
        if($maxLength > $this->maxSizeToLoad) {
            $maxLength = ($this->maxSizeToLoad / 2);
        }
        /**
         * Actually load the data
         */
        $data = array();
        if($maxLength > 0) {

            $fp = fopen($this->log[$file], 'r');
            fseek($fp, -$maxLength , SEEK_END);
            $data = explode("\n", fread($fp, $maxLength));

        }
        /**
         * Run the grep function to return only the lines we're interested in.
         */
tslenter commented 3 years ago

Case: Web console does not display logging:

Issue duplicated by removing or modify permissions of /var/log/remote_syslog/remote_syslog.log:

[Tue Mar 09 16:47:53.200014 2021] [php7:warn] [pid 5909] [client 192.168.91.129:57543] PHP Warning: filesize(): stat failed for /var/log/remote_syslog/remote_syslog.log in /var/www/html/rsc/PHPTail.php on line 95, referer: https://192.168.91.130/rsc/rsc.php [Tue Mar 09 16:47:55.191957 2021] [php7:notice] [pid 5909] [client 192.168.91.129:57543] PHP Notice: session_start(): A session had already been started - ignoring in /var/www/html/rsc/PHPTail.php on line 33, referer: https://192.168.91.130/rsc/rsc.php [Tue Mar 09 16:47:59.211215 2021] [php7:notice] [pid 5909] [client 192.168.91.129:57543] PHP Notice: Undefined index: pg in /var/www/html/rsc/PHPTail.php on line 362 [Tue Mar 09 16:47:59.211219 2021] [php7:notice] [pid 5909] [client 192.168.91.129:57543] PHP Notice: Undefined index: pg in /var/www/html/rsc/PHPTail.php on line 363

To get started we need to know if this issue occurs when it is installed on an unmodified Ubuntu machine (Raspberry Pi).

To help you we got the following information: We think permissions of the remote_syslog.log are off. Default it should be:

Run: ls -lah /var/log/remote_syslog/

Expected output: -rw-r--r-- www-data www-data remote_syslog.log

Run: ps aux | grep apache2

www-data ........ /usr/sbin/apache2 -k start

It expects that the apache2 webservice runs with the www-data user.

syslog-ng configuration sets the file permissions. These can be found: /etc/syslog-ng/conf.d/99-remote.conf

Check destination Y within the config.

auadams commented 3 years ago

Might be an issue with the apache config or my old syslog-ng files. Let me reinstall on a fresh rasberry pi.

ubuntu@syslogpi:~$ ps aux | grep apache
root        2218  0.3  0.5 205232 20564 ?        Ss   21:41   0:00 /usr/sbin/apache2 -k start
www-data    2219  0.0  0.2 205752 11612 ?        S    21:41   0:00 /usr/sbin/apache2 -k start
www-data    2220  0.0  0.2 205752 11612 ?        S    21:41   0:00 /usr/sbin/apache2 -k start
www-data    2221  0.0  0.2 205752 11612 ?        S    21:41   0:00 /usr/sbin/apache2 -k start
www-data    2222  0.0  0.2 205752 11612 ?        S    21:41   0:00 /usr/sbin/apache2 -k start
www-data    2223  0.0  0.2 205752 11612 ?        S    21:41   0:00 /usr/sbin/apache2 -k start

I Change the permissions on the file to be certian it wasn't syslog-ng setting the permissions to low

ubuntu@syslogpi:/etc/apache2/sites-enabled$  ls -lah /var/log/remote_syslog/
total 1.6M
drw-r-xr-x  2 www-data www-data 4.0K Mar  9 11:35 .
drwxr-xr-x 13 root     syslog   4.0K Mar  9 11:07 ..
-rwxrwxrwx  1 www-data www-data 1.6M Mar  9 21:44 remote_syslog.log

I modified my old syslog-ng config to match what seemed to be required by the software

@version: 3.25
@include "scl.conf"

# Syslog-ng configuration file, compatible with default Debian syslogd
# installation.

# First, set some global options.
options { 
          chain_hostnames(off); 
          flush_lines(0);
          use_dns(yes); 
          use_fqdn(yes);
          dns_cache(no); 
          owner("www-data"); 
          group("www-data"); 
          perm(0777);
          stats_freq(0); 
          bad_hostname("^gconfd$"); 
          create_dirs(yes);
          dir-owner("root");
          dir-group("adm");
      dir-perm(0777);
};

########################
# Sources
########################
# This is the default behavior of sysklogd package
# Logs may come from unix stream, but not from another machine.
#
source s_src {
       system();
       internal();
};

source s_net { udp( ip(0.0.0.0) port(514)); };

#destination d_syslog { file("/mnt/syslog/remote.log"); };
destination d_syslog { file("/var/log/remote_syslog/remote_syslog.log"); };

log { source(s_net); destination(d_syslog); };
auadams commented 3 years ago

Yup it was my syslog-ng config conflicting with the software.

sorry for the trouble.

tslenter commented 3 years ago

Good to know that the issue is resolved by modifying the syslog-ng configuration. Thanks for sharing.