sebhildebrandt / systeminformation

System Information Library for Node.JS
MIT License
2.72k stars 309 forks source link

Not all ifaces detected, users problem #11

Closed lapsio closed 8 years ago

lapsio commented 8 years ago

So i just tried new version of systeminformation.

It doesn't crash without root - that's great. But few things don't look entirely correct:

networkStats:

sys.networkInterfaces(function(s){console.log(s)})
Promise { <pending> }
> [ { iface: 'lo', ip4: '127.0.0.1', ip6: '::1', internal: true },
{ iface: 'br0',
ip4: '192.168.1.3',
ip6: 'fe80::f66d:4ff:fe97:cc1c',
internal: false },
{ iface: 'vmnet1',
ip4: '172.16.56.1',
ip6: 'fe80::250:56ff:fec0:1',
internal: false },
{ iface: 'vmnet8',
ip4: '192.168.99.1',
ip6: 'fe80::250:56ff:fec0:8',
internal: false } ]

whereas:

lapsio@linux-qzuq ~> ip link list
1: lo: ...
2: eno1: ... <- missing
3: br0: ...
4: vmnet1:...
5: vmnet8: ...

I just checked and os.networkInterfaces is also missing eno1

And .users() returns empty array now on my machine.

Here's result of command you use, I hope it helps: http://pastebin.com/YW41Dpma

I found it quite confusing that .services without srv argument return nothing instead of all and those "-1"s in many places also look confusing. I followed code and considering _disk_io.ms doesn't seem to be set anywhere they're like hardcoded?

sebhildebrandt commented 8 years ago

Hi again,

Thank you for testing the new version and thank you for your comments!! I had a first look on it:

  1. .networkInterfaces .... well yes I am relying on node.js os.networkInterfaces(), very interesting that this does not return all interfaces ... so this is something we should handle over to the node.js group?? Btw, on my machines I get the same results with os.networkInterfaces() and ip link list (or ip address).
  2. .users --> empty list: the problem here might be the who command (respectively the options). So there is obviously a bug in my approach! Can you provide me 3 things: --> output of who --version --> output of who --help --> which OS / distro you are working with? I will then work on an workarround! Thank you in advance!
  3. .services returning "nothing" when you don't provide srv variable: hmmmm, it should then return an empty array (and as far as I see, it does exactly that). What would be your suggestion here?
  4. -1 return values: I need a way to show, that a specific value is NOT yet available. 0 would be a possible correct value, so I cannot use it. But if you get back -1, you can be sure, this is either not available or not detected yet. Any other idea on that?
  5. _disk_io.ms : this is an internal value that I need to determine the delta time between two calls of .disksIO. I am setting it in line 964 (linux) and 1002 (Darwin). So I do not really get the problem you described here. Can you be more specific here?

Thank you for your support!

sebhildebrandt commented 8 years ago

Hi again, some more details concerning your comments/bug report:

  1. .networkInterfaces: In the nodejs docs, I found this: "The os.networkInterfaces() method returns an object containing only network interfaces that have been assigned a network address." So here it seems, that in your case, eno1 has not yet an assigned network address. I need to think, if I can write a better solution (not relying on os.networkInterfaces()). Please give me some time to think about that
  2. .users: I am already working on a solution but I am not sure if that works. It would be nice to get some details to verify, if this could work: --> output of who; echo '---'; w | tail -n +2 --> output of uname -a (to be more sure, what type of OS is not working with the current version)

Thank you in advance!

lapsio commented 8 years ago

oh sorry I saw previous message but forgot to reply.

my OS:

> sys.osInfo(function(s){console.log(s)})
Promise { <pending> }
> { platform: 'Linux',
  distro: 'openSUSE',
  release: '13.2',
  codename: '',
  kernel: '4.6.4-1-default',
  arch: 'x64',
  hostname: 'linux-qzuq',
  logofile: 'opensuse' }

lapsio@linux-qzuq ~> uname -a
Linux linux-qzuq 4.6.4-1-default #1 SMP PREEMPT Mon Jul 11 17:59:12 UTC 2016 (103c936) x86_64 x86_64 x86_64 GNU/Linux

(older OpenSUSE 13.2 with Tumbleweed kernel and some other critical packages) Most of my machines are running various versions of OpenSUSE mostly 13.2 with some modifications. Also there's one Arch machine but I haven't tested this lib on it yet

who

lapsio@linux-qzuq ~> who --version 
who (GNU coreutils) 8.23

lapsio@linux-qzuq ~> who --help
Usage: who [OPTION]... [ FILE | ARG1 ARG2 ]
Print information about users who are currently logged in.

  -a, --all         same as -b -d --login -p -r -t -T -u
  -b, --boot        time of last system boot
  -d, --dead        print dead processes
  -H, --heading     print line of column headings
  -l, --login       print system login processes
      --lookup      attempt to canonicalize hostnames via DNS
  -m                only hostname and user associated with stdin
  -p, --process     print active processes spawned by init
  -q, --count       all login names and number of users logged on
  -r, --runlevel    print current runlevel
  -s, --short       print only name, line, and time (default)
  -t, --time        print last system clock change
  -T, -w, --mesg    add user's message status as +, - or ?
  -u, --users       list users logged in
      --message     same as -T
      --writable    same as -T
      --help     display this help and exit
      --version  output version information and exit

If FILE is not specified, use /var/run/utmp.  /var/log/wtmp as FILE is common.
If ARG1 ARG2 given, -m presumed: 'am i' or 'mom likes' are usual.

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info '(coreutils) who invocation'

about services. Well idk systemctl status without giving any service just shows status of all services active and running on system. I think that's the reason I expected similar behavior.

about 5. I meant that I followed code to figure out what are those -1 values and I came to conclusion that condition required for them to be set to something else than -1 is always false but maybe I overlooked something.

about interfaces: oh well that's quite... HUGE simplification. This machine is just workstation so it has only 1 network card, laptop has 2. By default OpenSUSE always makes bridge and bridges all interfaces under single address so physical NICs never have address bound to them. But on other machine working as DNS server / rsyslog server / router out of 31 interfaces (12 physical, 19 virtual) only 6 have address assigned and they're actually again bridges. All other ifaces are bridged or operating on L2 without address at all. Whereas I don't really think it's necessary to support full networking like vlans, tunnels etc (sounds pretty much like implementing support for full device mapper) i think that bridges and interface bonding should be supported because those 2 things are kinda common on workstations / desktop PCs and they introduce interfaces without address. I think VPNs and tunnels usually have own addresses as long as they operate as client tunnel not full network tunnel.

sebhildebrandt commented 8 years ago

Thank you once again! I just published a patch (version 3.0.1)

  1. .users: I implemented a bug-fix for users. Would be great if you can test it ;-)
  2. .networkInterfaces: I completely agree! I need to think of reimplementing it. I already have some ideas but this will take some time to get it reliable.
  3. .services: Ahhh, now I got it! Well thats a pretty nice idea, I think I will implement it in one of the next releases.
  4. .disksIO: I really found a small bug here, but this is not related to your comment. When walking through the code once again, I found an other small mistake ;-)

So if your test concerning users is ok, allow me to close this open issue. I will then think of rewriting networkInterfaces in one of the next releases.

Thank you again!

lapsio commented 8 years ago

I think it works. A bit weird but works. I mean on OpenSUSE it shows screen sessions and on Arch doesn't quite weird. But apart from that it works.

lapsio commented 8 years ago

Oh wait no it totally doesn't work, doesn't show sessions running in other systemd slices ;) jk, I know It's detail I just learned today about systemd cool bits and it blown my mind.

However it might be good idea to filter out this:

{ user: 'lapsio',
tty: 'pts/0',
date: '2016-08-18',
time: '19:36',
ip: ':0',
command: '/bin/sh -c who; echo \'---\'; w | tail -n +2' }

because lol... Unfortunately it seems to be quite unpredictible. Now it shows full command but few seconds ago when I launched it it showed just w without the rest of command. So it might not be worth to waste time on this

sebhildebrandt commented 8 years ago

Thank you for testing again!! If ok, I will close it for now and make further investigations later. OK for you? I will anyway push another version 3.2 tomorrow morning

plus some smaller improvements

sebhildebrandt commented 8 years ago

closing it for now. making further investigations later.

ricardopolo commented 4 years ago

@sebhildebrandt are you still planning to implement show all nics?

sebhildebrandt commented 4 years ago

@ricardopolo yes, as I have another open issue where this is relevant, I will refactor networkInterfaces()