Hello There, Guest! Login Register
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

/usr/local/share/nems/nems-scripts/stats-livestatus.py - Errno 111 on startup

#1
Hey Robbie,

I think I discovered a very minor processing issue here on startup. Over the weekend, I installed apticron so that I can get email when updates are available on the NEMS box. It's a standard I do on all my Raspberry Pi servers. Side Note: I am aware that NEMS automatically applies security updates as I reading that in another forum. I just prefer to know when I have updates and apticron sends the package details on what the updates are.

Anyway since I now get email notifications on cron jobs, I get the ones when a cron job fails. Whenever I startup NEMS, I get this email notification error:

Traceback (most recent call last):
  File "/usr/local/share/nems/nems-scripts/stats-livestatus.py", line 35, in <module>
    main()
  File "/usr/local/share/nems/nems-scripts/stats-livestatus.py", line 15, in main
    s.connect(socket_path)
  File "/usr/lib/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 111] Connection refused
Traceback (most recent call last):
  File "/usr/local/share/nems/nems-scripts/stats-livestatus.py", line 35, in <module>
    main()
  File "/usr/local/share/nems/nems-scripts/stats-livestatus.py", line 15, in main
    s.connect(socket_path)
  File "/usr/lib/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 111] Connection refused

I believe I understand what's going on here. The python file loads at reboot and NEMS isn't quite "fully initialized". Hence the cron job fails and now I get this email since I have apticron installed. It may be best to have add in a sleep 60 to put in a one minute delay. I would edit the crontab job, but I know that it's discouraged to manually edit config files. So just an idea down the road as a possible enhancement to NEMS.
 Reply
#2
Thanks so much. I didn't catch this, and your little email script has revealed it :)

Yes, you're bang-on. stats-livestatus.py connects to Nagios via [you guessed it] the livestatus socket. Well, I didn't think to add errorhandling if the socket isn't yet initialized (eg., Nagios hasn't loaded yet).

Rather than a sleep 60 as you suggest, I will modify the program to wait until the socket becomes ready.

Will push that out today. Thanks again.

Robbie
Robbie Ferguson // The Bald Nerd

Did I help you out? Appreciate what I do? Please consider saying thanks:
 Reply
#3
Patch issued. Please run: sudo nems-update

Then, reboot and let me know if the error is gone.

Cheers!
Robbie Ferguson // The Bald Nerd

Did I help you out? Appreciate what I do? Please consider saying thanks:
 Reply
#4
This error means that the client cannot connect to the port on the computer running server script.   This can be caused by few things, like lack of routing to the destination or you have a firewall somewhere between your client and the server - it could be on server itself or on the client etc. Note that a server must perform the sequence socket(), bind(), listen(), accept() (possibly repeating the accept() to service more than one client), while a client only needs the sequence socket(), connect(). Also note that the server does not sendall()/recv() on the socket it is listening on but on the new socket returned by accept(). Try the following:
  • Check if you really have that port listening on the server (this should tell you if your code does what you think it should): based on you OS, but on linux you could do something like netstat -ntulp
  • Check from the server, if you're accepting the connections to the server: again based on your OS, but telnet LISTENING_IP LISTENING_PORT should do the job
  • Check if you can access the port of the server from the client , but not using the code: just us the telnet (or appropriate command for your OS) from the client
 Reply
 
 
Forum Jump:

Users browsing this thread: 1 Guest(s)