Snorby / snorby

Ruby On Rails Application For Network Security Monitoring
Other
1k stars 226 forks source link

2.6.2: lib/snorby/worker.rb: 'ps' arguments assume linux #319

Open marksolaris opened 11 years ago

marksolaris commented 11 years ago

When running the

rake --verbose --trace --rules snorby:setup

command, these errors were seen:

usage: ps [ -aAdeflcjLPyZ ] [ -o format ] [ -t termlist ]
        [ -u userlist ] [ -U userlist ] [ -G grouplist ]
        [ -p proclist ] [ -g pgrplist ] [ -s sidlist ] [ -z zonelist ]
  'format' is one or more of:
        user ruser group rgroup uid ruid gid rgid pid ppid pgid sid taskid ctid
        pri opri pcpu pmem vsz rss osz nice class time etime stime zone zoneid
        f s c lwp nlwp psr tty addr wchan fname comm args projid project pset
ps: unknown output format: -o %cpu
ps: unknown output format: -o %mem
ps: unknown output format: -o vsize
ps: unknown output format: -o tt
ps: unknown output format: -o stat
ps: unknown output format: -o start
ps: unknown output format: -o command

because lib/snorby/worker.rb has this command in it:

29      def self.process
30        if Worker.pid
31          Snorby::Process.new(`ps -o ruser,pid,%cpu,%mem,vsize,rss,tt,stat,start,etime,command -p #{Worker.pid} |grep delayed_job |grep -v grep`.chomp.strip)
32        end
33      end

This command won't work on Solaris.

marksolaris commented 11 years ago

You can use this:

def self.process
    if Worker.pid
        case RUBY_PLATFORM
        when /solaris/
            Snorby::Process.new(`ps -o ruser,pid,pcpu,pmem,vsz,rss,tty,s,stime,etime,comm -p #{Worker.pid} |grep delayed_job |grep -v grep`.chomp.strip)
        else
            Snorby::Process.new(`ps -o ruser,pid,%cpu,%mem,vsize,rss,tt,stat,start,etime,command -p #{Worker.pid} |grep delayed_job |grep -v grep`.chomp.strip)
        end
    end
end

and add more 'when' clauses for other O.S. requirements.