Configuring xymon client in local mode - hobbitmon

I am trying to configure xymon (ex hobbit or bigbrother) in local mode. Basically the client would not send any data to the server. When using the --debug option the following information is obtained.
31017 2015-02-02 15:51:39 Want msg 1, startpos 0, fillpos 0, endpos -1, usedbytes=0, bufleft=528383
31017 2015-02-02 15:51:39 Got 150930 bytes
31017 2015-02-02 15:51:39 /opt/xymon/client/bin/xymond_client: Got message 1 ##client#1|0|127.0.0.1|hostname|linux
31017 2015-02-02 15:51:39 startpos 150930, fillpos 150930, endpos -1
31017 2015-02-02 15:51:39 Opening file /opt/xymon/client/etc/localclient.cfg
31017 2015-02-02 15:51:39 Client report from host hostname
31017 2015-02-02 15:51:39 hostname: Duplicate client message at time 0, seq 1, lastseq 0
31017 2015-02-02 15:51:39 Want msg 2, startpos 150930, fillpos 150930, endpos -1, usedbytes=0, bufleft=377453
31017 2015-02-02 15:51:39 get_xymond_message: Returning NULL due to EOF
This bug seems to be the same than:
http://lists.xymon.com/archive/2012-February/033896.html

The solution was given by the person hosting:
http://terabithia.org/rpms/xymon/
Many thanks to him. And I though I should report it here.
So it consisted in changing the following line in xymonclient.sh:
echo "##client#1|0|127.0.0.1|$MACHINEDOTS|$SERVEROSTYPE" >> $MSGTMPFILE
To:
echo "##client#1|1|127.0.0.1|$MACHINEDOTS|$SERVEROSTYPE" >> $MSGTMPFILE
And then data was sent to the server. Not sure what is going on here but that could help.

Related

socket.getaddrinfo doesn't return my IPV6 address with AF_INET6 or "0" as arguments

I'm using the following Python code to fetch ipv4 and ipv6 addresses information (according to millions of tutorials i went through including https://docs.python.org/3.5/library/socket.html), but i receive only the ipv4 info. My ipv6 connection is ok, i can see my addresses via "ipconfig /all", the host i'm trying to connect to is "akamai.com" (also tried www.python.org and example.org).
I have also tried the 0 argument (full range of results) instead of limiting it to socket.AF_INET6 or socket.AF_INET and yet i receive only the ipv4 address
import sys, socket
x = socket.getaddrinfo("akamai.com", 80, socket.AF_INET6, 0, socket.IPPROTO_IP, socket.AI_CANONNAME)
#Expected format (as i found in some examples in this site):
socket.getaddrinfo("www.python.org", 80, 0, 0, socket.SOL_TCP)
[(2, 1, 6, '', ('82.94.164.162', 80)),
(10, 1, 6, '', ('2001:888:2000:d::a2', 80, 0, 0))]
I receive only the first tulip (plus the canonical name)
Thanks for your help in advance

Pysnmp openServerMode with IPv6

I try to start a SNMP Agent with pysnmp.
for IPv4 and IPv6 bind, it works pretty fine with localhost ('127.0.0.1' and '::1')
but when I try to use other IPv6 IP which I fetched from interface, it failed due to
[vagrant#test SOURCES]$ sudo python snmp_agent.py enp0s8
Traceback (most recent call last):
File "snmp_agent.py", line 172, in <module>
master_agent_startup(ifname=sys.argv[1])
File "snmp_agent.py", line 101, in master_agent_startup
(get_ipv6_address(interface_name), SNMP_AGENT_PORT))
File "/usr/lib/python2.7/site-packages/pysnmp/carrier/asyncore/dgram/base.py", line 50, in openServerMode
raise error.CarrierError('bind() for %s failed: %s' % (iface, sys.exc_info()[1],))
pysnmp.carrier.error.CarrierError: bind() for ('fe80::a00:27ff:fe9e:9c16', 8001) failed: [Errno 22] Invalid argument
This is the output from the interface 'enp0s8':
[vagrant#test SOURCES]$ ifconfig enp0s8
enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.20.20.26 netmask 255.255.255.0 broadcast 172.20.20.255
inet6 fe80::a00:27ff:fe9e:9c16 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:9e:9c:16 txqueuelen 1000 (Ethernet)
RX packets 874053 bytes 115842841 (110.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 862314 bytes 114652475 (109.3 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
This is the code piece I used for IPv6 bind:
def get_ipv6_address(ifname):
return netifaces.ifaddresses(ifname)[netifaces.AF_INET6][0]['addr'].split('%')[0]
config.addSocketTransport(snmpEngine, udp.domainName,
udp.UdpTransport().openServerMode(
(get_ipv4_address(interface_name), SNMP_AGENT_PORT))
)
config.addSocketTransport(snmpEngine, udp6.domainName,
udp6.Udp6SocketTransport().openServerMode(
(get_ipv6_address(interface_name), SNMP_AGENT_PORT))
)
From pysnmp sample, it seems the parameter inside "openServerMode()" is just a tuple of IP and port.
And from output error I suppose there is no error for given IP and port.
so why it failed due to Invalid argument?
Could you #Ilya Etingof or some other pysnmp expert help me with it?
Thanks.
UPDATE: I try to bind it with given suggestion, but is still doesn't work.
the bind command was run from a new installed CentOS. but it still failed:
[root#test ~]# ifconfig
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.10.20.4 netmask 255.255.255.0 broadcast 10.10.20.255
inet6 fe80::f816:3eff:fee1:5475 prefixlen 64 scopeid 0x20<link>
ether fa:16:3e:e1:54:75 txqueuelen 1000 (Ethernet)
RX packets 12242 bytes 962552 (939.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 12196 bytes 957826 (935.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root#test ~]# python
Python 2.7.5 (default, Oct 11 2015, 17:47:16)
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM, 0)
>>> addr_and_port = ('fe80::f816:3eff:fedb:ba4f', 8001)
>>> s.bind(addr_and_port)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 22] Invalid argument
>>>
[1]+ Stopped python
[root#test ~]# netstat -anp | grep 8001
[root#test ~]#
One more update:
I suppose the bind is failed due to my environment has some issue with IPv6 configuration. As I'm only able to get one IPv4 address by using "socket.getaddrinfo()" method.
Br,
-Dapeng Jiao
You could get this error if attempted to bind the same socket more than once. But I can't see that is the case in your code.
That .openServerMode() method does no magic -- it just calls .bind() on socket object. For inspiration, does this work in at your Python prompt?
from pysnmp.carrier.asyncore.dgram import udp6
addr_and_port = ('fe80::a00:27ff:fe9e:9c16', 8001)
udp6.Udp6SocketTransport().openServerMode(addr_and_port)
or even:
import socket
s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM, 0)
addr_and_port = ('fe80::a00:27ff:fe9e:9c16', 8001)
s.bind(addr_and_port)
My hope is that tests like these may help you figuring out the problem...
When you use an IPv6 link-local address, you must always use the scope along with it. The link-local address is not valid without its scope, thus you will receive an Invalid argument error.
For example, instead of using fe80::a00:27ff:fe9e:9c16 you must use fe80::a00:27ff:fe9e:9c16%enp0s8.

Metadata is not showing ffmpeg C++

I am muxing h264 encoded video data and PCM g711 encoded audio data into a .mov media container. I am trying to write metadata on header but the metadata is not showing when I go to file->right click->properties->details on windows and likewise in Ubuntu. This is my code -
// Instead of creating new AVDictionary object, I also tried following way
// stated here: http://stackoverflow.com/questions/17024192/how-to-set-header-metadata-to-encoded-video
// but no luck
AVDictionary* pMetaData = m_pFormatCtx->metadata;
av_dict_set(&pMetaData, "title", "Cloud Recording", 0);
av_dict_set(&pMetaData, "artist", "Foobar", 0);
av_dict_set(&pMetaData, "copyright", "Foobar", 0);
av_dict_set(&pMetaData, "filename", m_sFilename.c_str(), 0);
time_t now = time(0);
struct tm tStruct = *localtime(&now);
char date[100];
strftime(date, sizeof(date), "%c", &tStruct); // i.e. Thu Aug 23 14:55:02 2001
av_dict_set(&pMetaData, "date", date, 0);
av_dict_set(&pMetaData, "creation_time", date, 0);
av_dict_set(&pMetaData, "comment", "This video has been created using Eyeball MSDK", 0);
// ....................
// .................
/* write the stream header, if any */
int ret = avformat_write_header(m_pFormatCtx, &pMetaData);
I also tried to see if the file contains any metadata using mediainfo and exiftools in linux. Also I tried ffmpeg -i output.mov but no metadata is shown.
Whats the problem? Is the flags value 0 in av_dict_set okay? DO I need to set different flags for different platform (windows/linux) ?
I saw this link and it stated that for windows, I have to use id3v2_version 3 and -write_id3v1 1 to make metadata working. If so, how can I do this in C++?
I have something similar to your code, but I'm adding the AVDictionary to my AVFormatContext metadata parameter and it works for me that way. Here's a snippet based on your code.
AVDictionary *pMetaData = NULL;
av_dict_set(&pMetaData, "title", "Cloud Recording", 0);
m_pFormatCtx->metadata = pMetaData;
avformat_write_header(m_pFormatCtx, NULL);

Send socket result 0x000000be

What means a result of 0x000000be in send command:
iResult = send( ConnectSocket, dataToSend, (int) strlen(dataToSend), 0 );
I didn't found this return code here: http://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx
Any ideas?
Thx
The value returned by send is the number of bytes it sent. If it fails it returns SOCKET_ERROR and you use WSAGetLastError to get the error code, which is the codes listed in your link. Read the manual page for send instead.

Running python Django script from console: Segmentation fault

Ububntu 11.10, Python 2.7.2+, Django 1.3.1
When I'm starting huge script "parser.py" with command # python parser.py (in the root directory of my django app), it returns "Segmentation fault" after several minutes of working.
parser.py:
from django.core.management import setup_environ
import settings
setup_environ(settings)
# here comes lots of code for parsing some pages
I'm using urllib and xmlrpclib in this script.
I'm usng vps from this template http://wiki.openvz.org/Download/template/precreated (ubuntu-11.10-x86_64.tar.gz (signature))
maybe problem is here?
root#spravker:/var/log# cat /proc/user_beancounters
Version: 2.5
uid resource held maxheld barrier limit failcnt
2311649: kmemsize 9042870 19404189 52497139 57746852 0
lockedpages 0 1034 2563 2563 0
privvmpages 125787 208103 262144 262144 0
shmpages 1938 3874 27750 27750 0
dummy 0 0 0 0 0
numproc 40 200 200 200 2173
strace -o logfile.txt python parser.py
munmap(0x2b6ed1d4b000, 4096) = 0
stat("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=20, ...}) = 0
socket(PF_INET, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_IP) = 4
connect(4, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("8.8.8.8")}, 16) = 0
poll([{fd=4, events=POLLOUT}], 1, 0) = 1 ([{fd=4, revents=POLLOUT}])
sendto(4, "\343X\1\0\0\1\0\0\0\0\0\0\nblogsearch\6google\3c"..., 39, MSG_NOSIGNAL, NULL, 0) = 39
poll([{fd=4, events=POLLIN}], 1, 5000) = -1 EINTR (Interrupted system call)
—- SIGSEGV (Segmentation fault) # 0 (0) —-
+++ killed by SIGSEGV +++