Zabbix Agent2 loadable plugin performance issue on Windows - windows

For my work purposes, I have to build a plugin for zabbix Agent2 that has to on Windows systems. For simplicity purposes I chose to go with a loadable plugin but more on that later.
I followed the guide at # https://www.zabbix.com/documentation/guidelines/en/plugins/loadable_plugins to build the example myip plugin on my Windows laptop and after linking it through an additionnal config file in the C:\Program Files\Zabbix Agent 2\zabbix_agent2.d\plugins.d directory, it works.
It works meaning that I can query the new item both with:
> zabbix_get -s localhost -k myip
> zabbix_agent -c zabbi_agent2.conf -t myip.
The only issue is the zabbix_agent2 process CPU usage sky rocks when I linked my loadable plugin, and restarted the agent.
I am talking about a usage of about 17-20% on my 8cores/1.99Ghz i7 laptop. That is just insane.
If I unlink the agent2 and the loadable plugin, the agent cpu usage comes back to normal (less than 1%).
After looking at the agent log file (zabbi_agent2.log), it is full of lines like
2022/11/10 09:22:16.817154 failed to read response for plugin Myip, failed to read type header, The handle is invalid.
When I run zabbix_agent -v -c zabbi_agent2.conf -t myip with the -v (verbose) option, I see the same error in the output multiple times before the actual value of the metric.
I suspect the high CPU usage is caused by this error happening and being logged too frequently.
After having read the source code of the plugin-support at https://git.zabbix.com/projects/AP/repos/plugin-support/browse/plugin/comms/connection.go (line 42), I recognized the line of code creating the error.
As there are builtin plugins for the agent2 too, it tried to recompile the agent2 on windows but was getting an even worse error while i have not even added my plugin yet.
I acutually wrote a post on that as well here (# https://www.zabbix.com/forum/zabbix-troubleshooting-and-problems/454191-error-during-zabbix-agent2-compilation-from-sources and Error during Windows Zabbix Agent2 compilation from sources)
Resources:
Go: dl.google.com/go/go1.19.3.windows-amd64.msi
Zabbix Agent2: https://cdn.zabbix.com/zabbix/binaries/stable/6.2/6.2.4/zabbix_agent2-6.2.4-windows-amd64-openssl.msi
I build the same plugin for the agent2 on linux both as a loadable and builtin plugin and it is working flawlessly so i think it really is a windows issue.

Related

Getting output from from VS WSL build events

Visual Studio has a relatively new way of doing Linux builds, using the local WSL system. This platform toolset is called WSL_1_0
What in a remote build was called "Remote Pre-Build Event" is now called "Wsl Pre-Build Event" (in the UI..still Remote whatever in msbuild, apparently) and it works basically the same, but with execution occurring in WSL on the local machine rather than on a linux machine.
Aaaand...any script output seems to be swallowed (vs. running on a remote machine where it was displayed in the build window):
1>Target RemotePreBuildEvent:
1> Invoking 'echo "me : stuff error 567 HELLO"', working directory: '/mnt/s/buildroot/CoreTech/ThirdPartyTools/Encryption/Rijndael/Project/Linux'
1>Target ClCompile:
1> Starting remote build
If I replace this with a script, it is executed..but the output is swallowed.
I've tried redirecting to stderr both within the script and within the command and it seems to change nothing. I've also adjusted Tools->Options->Project and Solutions->Build and Run output verbosity as high as I'm willing to (Normal) with no changes.
Anyone have any ideas on solving this?
I've also adjusted Tools->Options->Project and Solutions->Build and
Run output verbosity as high as I'm willing to (Normal) with no
changes.
Normally it's recommended to change the Verbosity to Detailed and higher to see more details. And this is the only option I know in latest VS2019 16.3.7 can control the behavior of output log.
So you can change it to Detailed to check if there's more info to be displayed in output window.(For some reason,my configuration fails for the wsl.exe, so I can't test it myself whether this option can work)
And if the echo info is still not shown, I guess this scenario is not be supported for now since it's quite a new feature. Just post your feedback in DC as the Give Us Feedback in this document suggests. The team there would look and consider about supporting that. May it makes some help :)

How do I get a custom Nagios plugin to work with NRPE?

I have a system with no internet access where I want to install some Nagios monitoring services/plugins. I installed NRPE (Nagios Remote Plugin Executor), and I can see commands defined in it, like check_users, check_load, check_zombie_procs, etc.
command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10
command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
...
I am able to run the commands like so:
/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 -c check_load
This produces an output like:
OK - load average: 0.01, 0.13, 0.12|load1=0.010;15.000;30.000;0; load5=0.130;10.000;25.000;0; load15=0.120;5.000;20.000;0;
or
WARNING – load average per CPU: 0.06, 0.07, 0.07|load1=0.059;0.150;0.300;0; load5=0.069;0.100;0.250;0; load15=0.073;0.050;0.200;0;
Now, I want to define/configure/install some more services to monitor. I found a collection of services here. So, say, I want to use the service defined here called check_hadoop_namenode.pl. How do I get it to work with NRPE?
I tried copying the file check_hadoop_namenode.pl into the same directory where other NRPE services are stored, i.e., /usr/lib/nagios/plugins. But it doesn't work:
$ /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 -c check_hadoop_namenode.pl
I figured this might be obvious because all other services in that directory are binaries, so I need a binary for check_hadoop_namenode.pl file as well. How do I make the binary for it?
I tried installing the plugins according to the description in the link. But it just tries to install some package dependencies, and throws error as it cannot access the internet (my system has no internet access, like I stated before). This error persists even when I install these dependencies manually in another system and copy them to the target system.
$ <In another system with internet access>
mkdir ~/repos
git clone https://github.com/harisekhon/nagios-plugins
cd nagios-plugins
sudo nano Makefile
# replace 'yum install' with 'yumdownloader --resolv --destdir ~/repos/'
# replace 'pip install' with 'pip download -d ~/repos/'
This downloaded 43 dependencies (and dependencies of dependencies, and so on) required to install the plugins.
How do I get it to work?
check_users, check_load or check_zombie_procs are defined on the client side in nrpe.cfg file. Default location are /usr/local/nagios/etc/nrpe.cfg or /etc/nagios/nrpe.cfg. As I read, you already found that file, so you can move to next step.
Put something like this to your nrpe.cfg:
command[check_hadoop_namenode]=/path/to/your/custom/script/check_hadoop_namenode.pl -optional -arguments
Then you need restart NRPE deamon service on client. Something like service nrpe restart.
Just for you information, these custom script doesn't must to be binaries, you can even use simple bash script.
And finally after that, you can call the check_hadoop_namenode command from Nagios server or via local NRPE deamon:
/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 -c check_hadoop_namenode

GNU ARM plugin for Eclipse under Windows - OpenOCD not starting debugging

I'm having problems trying to setup dev env for STM32F4 Discovery board in Windows.
I have installed all required files (GCC for ARM, Windows Build Tools, Eclipse Plugin) and I'm getting this error when trying to start OpenOCD debugging:
Missing mandatory configuration. Fill-in the 'Config options:' field in the Debugger tab.
This is my debug config screen:
And this is the error which I get when I try to start it (and build success message):
openocd must be told what kind of board it should talk to
http://gnuarmeclipse.github.io/debug/openocd/#create-the-debugger-configuration
the only field that usually requires attention is the OpenOCD Setup
Other options:, where you should add one or more configuration
scripts; for example, for the STM32F4DISCOVERY board, the field should
read -f board/stm32f4discovery.cfg

Headless testing display error

Background
I am running a set of selenium tests using a Maven and Jenkins with Testng. I had them working fine headlessly up until a week ago. Jenkins sits on the server accessible with port 8080. The tests also run fine through eclipse.
Software Versions
I have read lots about Firefox being incomparable with selenium so here is a list of software and versions that I am using.
Firefox: 39
Maven: 3.3.3
Java: 1.7.0_79
Selenium: 2.46 & 2.47(currently 2.47)
Jenkins: 1.622
Xvnc: 1.3.9
ubuntu 14
Error
After I run the tests and the fail I check the console through Jenkins. The error I am getting makes me think it's a problem with Xvnc and firefox but I can't pin point it. I get a NotConnectedException. The firefox console error has changed a few times here is a list of different errors the console has shown me.
Error: cannot open display: :87
firefox: Fatal IO error 11 (Resource temporarily unavailable) on X server :46.
firefox: Fatal IO error 2 (No such file or directory) on X server :78.
Research
I've been on bugzilla but cant find a conclusive answer to the problem.
I've also looked around SO but found no fixes.
Conclution
From what I have gathered it is something to do with Xvnc, Could running
sudo apt-get update
make changes to how Xvnc operates? I have updated the packages some time last week but our testers didn't check Jenkins properly when adding new tests and as such I've wasted and entire day trying to pin point when and what the problem is.
Question
What would cause Jenkins to return errors like this, how can I fix them and how can I prevent something doing this again?
EDIT 1
The display variable seems to be the issue, upon typing the command
echo $DISPLAY
There is no response just an empty line.
EDIT 2
running the command
export DISPLAY=:0.10
no gives the result
:0.10
when I echo $DISPLAY
I think the DISPLAY varibale is not functioning as expected and hence firefox is unable to connect to it. To know more about the $DISPLAY refer this link https://askubuntu.com/questions/432255/what-is-display-environment-variable
Try to run this command on the slave node where the job runs, this should give you the required setting for the tests to connect and run.
nohup /usr/bin/Xvfb :2 –screen 0 1024x768x24 > /dev/null 2>&1 &

Systemtap for production server

I want to use systemtap for extracting details of my linux production server from remote access. I have some of the doubts regarding this:
Whether is it necessary to have same kernel in both the linux production server and linux development server.If not then how to add the support for that?
What are the minimum requirements to be present in the production server? Whether is it necessary to compile the kernel of the production server with the debuginfo ?
How to enable users in some particular group to run the stap scripts?
The kernel running on the production server and linux development server do not need to be identical. The SystemTap Beginners Guide describes doing cross-compile where instrumentation for one kernel version is built on a machine currently running different kernel version. This is described in:
http://sourceware.org/systemtap/SystemTap_Beginners_Guide/cross-compiling.html
The production server just needs the systemtap-runtime package. The production server does not need the kernel-devel or kernel-debuginfo installed when using the cross compile method.
There are stapusr and stapdev groups that allow people to run scripts. stapusr allows one to run existing script in /lib/modules/uname -r/systemtap directory (probably what is wanted in the case of running cross-compiled systemtap scripts). stapdev allow one to compile a script.
The stapusr and stapdev groups are described in:
http://sourceware.org/systemtap/SystemTap_Beginners_Guide/using-usage.html
Another capability in systemtap >1.4 is remote execution:
development_host% stap --remote=user#deployment_host -e 'probe begin { exit() } '
where cross-compilation, module transfer, trace data transfer are all automagically done via an ssh transport, as long as the deployment_host has corresponding systemtap-runtime bits installed.

Resources