It is currently Wed Sep 18, 2019 1:43 pm
All times are UTC + 8 hours

[HOW TO] Write system/connect/file log for your applications

Share your awesome tips and tricks here.

Re: [HOW TO] Write system/connect/file log for your applications

Postby MikeG.6.5 » Sun May 01, 2016 7:41 pm

I am trying to write a small script that is called by PlexPy to write when someone starts and stops watching a show in the File Access logs.

When I try to use this line: /usr/sbin/syslog -g 2 -l 0 --user admin --event "PlexPy is reporting $2 is streaming $3 on $4 from $5" I get this instead of a returned prompt:

Code: Select all
SysLog. Ver. 0.1.0
Copyright (C) 2011-2013 Asustor Systems, Inc.  All Rights Reserved.

Usage: /usr/sbin/syslog options
  -h --help             Display this usage information.
  -q --quiet            Be quiet.
  -g --log <type>       Type of log (0: System, 1: Connection, 2: File Access, 3: Boot Up)
  -l --level <type>     Type of level (0: INFO, 1: WARNING, 2: ERROR, 3: CRITICAL)
  -t --time <datetime>  Date and time format YYYY-MM-DD HH:mm:ss (2012-03-15 09:13:38)
  -u --user <name>      User name
  -e --event <msg>      Event message
  -f --from <address>   Log from which host ip address
  -c --computer <name>  Log from which computer name
  -p --protocol <name>  Connection/File Access protocol (service)
  -i --action <type>    Connection action (0: Sign in, 1: Sign out, 2: Sign in failed)
  -a --access <type>    File access type (0: Read, 1: Write, 2: Delete, 3: Create, 4: Create Folder, 5: Delete Folder, 6: Rename, 7: Move/Copy )
  -s --source <path>    File access file full path

Example:
  System log:
    /usr/sbin/syslog --log 0 --level 0 --user admin --event "System started"
  Connection log:
    /usr/sbin/syslog -g 1 -l 1 -u admin -f 192.168.0.1 -c User-PC -p SAMBA -i 2
  File access log:
    /usr/sbin/syslog -g 2 -l 1 -u admin -f 192.168.1.10 -p FTP -a 2 -s "/volume1/Public/file.txt"
  Boot up log:
    /usr/sbin/syslog --log 3 --level 0 --time "2012-03-14 23:59:59" --user system --event "NAS boot up"


And nothing shows up in the File Access Logs. When I use this line: /usr/sbin/syslog -g 0 -l 0 -u admin -e "PlexPy is reporting $2 is streaming $3 on $4 from $5"
I get an entry in the System Logs, but I don't get the passed parameters. So something isn't quite right with how the syslog works. It's not writing to the specified log file. As far as what to pass it I hope I can set that in the file somehow, too... I'm going to try messing with that a bit more.

The parameters I'm passing are Server Name, Plex User ID, Title of show/movie, Device and IP they are accessing the file from.

I need a developer to look into the syslog functions, as they appear to be broken for right now. I can't write to either the connection or the file access logs via a shell script at all. Only the system logs.

I will copy and paste this into a ticket as well.
MikeG.6.5
 
Posts: 911
Joined: Fri May 15, 2015 1:56 am

Re: [HOW TO] Write system/connect/file log for your applications

Postby orion » Tue May 03, 2016 4:30 pm

I checked the function being working fine. If you want to put log in "File Access log", you need to specify log, level, user, IP, action, source and protocol (just the same as columns in System Information -> Log -> File Access log), i.e., -g, -l, -u, -f, -p, -a, -s. And you need to enable logging protocols under System Information -> Log -> Preferences -> Management.
User avatar
orion
 
Posts: 2336
Joined: Wed May 29, 2013 11:09 am

Previous

Return to Tips & Tricks

  • You cannot post new topics in this forum
    You cannot reply to topics in this forum
    You cannot edit your posts in this forum
    You cannot delete your posts in this forum
    You cannot post attachments in this forum
  • Who is online

    Users browsing this forum: No registered users and 1 guest