the file <FILE_NAME>.PML was not closed cleanly during capture and is corrupt - virtual-machine

I'm using procmon to save logs while running some tests on VM. I'm using python and pytest but I think is irrelevant here.
For every test I'm running to start procmon with:
psexec.exe -accepteula -s -d -i 1 procmon.exe /AcceptEula /Quiet /BackingFile c:\temp\logs.pml
If a test failed, I'm terminating the procmon with:
psexec.exe -accepteula -s -d -i 1 procmon.exe /Terminate
and then I'm saving the snapshot of the VM.
To open the logs.pml to be readable, I'm running after I entered to the VM's snapshot:
procmon.exe \openlog c:\temp\logs.pml
But sometimes I get the error:
the file logs.PML was not closed cleanly during capture and is corrupt.
Error pic in the VM
Why do I get this error? I can see the procmon ran and then terminated by my code (I can enter to the VM and see the test running, executing the procmon, and terminating it).
How do I solve this problem?
Note: it happens sometimes, most of the time it works and creates for me the logs as readable PML files.

Related

rsync to remote location exits with code 12

I am trying to rsync a local folder to a remote location. This a command that I have run successfully a week ago, but now if i run:
rsync -vrtzu\
--chown=user:webadm
--delete
--exclude-from=.rsyncignore
FOLDER/
USER#REMOTE:/DESTINATION
Then I get the following error message:
zsh:1: no matches found: --usermap=*:USER
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(235) [sender=3.1.3]
make: *** [makefile:39: push] Error 12
The command is run from a makefile, hence the last line.
I am using a regular WSL2 Ubuntu shell, not zsh.
I am able to ssh into the remote location with USER#REMOTE.
I have also checked that both locations have rsync installed (same version).
Finally, there is plenty of disk space available on the remote location.
Any pointers? What should I be checking to improve my diagnostic?
Thanks in advance!
This can happen when the remote shell messes with the command. Not sure exactly why and what it does but it modifies escaping so that the file path becomes invalid.
In your case the shell outputs --usermap=*:USER at log in.
The solution is to change the remote (zsh) shell to bash using the chsh command
I'm pretty sure this is an rsync bug:
zsh:1: no matches found: --usermap=*:USER
It only happens the remote machine's default shell is zsh.
It was fixed somewhere between rsync 3.2.3 (where it's broken) and 3.2.5 (where the bug is gone).
You can verify this by passing -vv to rsync. This prints as one of the first output lines which command invocation rsync is doing on the remote server via SSH.
On a broken version, it prints e.g.:
... ssh ... rsync --server -vvnlogDtpRe.LsfxCIvu "--usermap=*:user" "--groupmap=*:webadm"
On a fixed version, it prints e.g.:
... ssh ... rsync --server -vvnlogDtpRe.LsfxCIvu "--usermap=\*:user" "--groupmap=\*:webadm"
As you can see, they inserted a \ to fix the string being interpreted by zsh.

Retrieving the output of SSH when launched via LSF

I'm using localhost.run to open tunnels, so I want to launch
ssh -R 80:localhost:8080 ssh.localhost.run
The only problem is that I launch it via LSF as part of a bash script.
I get the error
Pseudo-terminal will not be allocated because stdin is not a terminal.
that I solve by using the option
-T Disable pseudo-tty allocation.
My current command is
ssh -T -R 80:localhost:8080 ssh.localhost.run
and it is the last command of my bash script.
I have also tried using -tt with the same result (https://stackoverflow.com/a/7122115/5133167)
When I launch my script from my tty, I get the expected output (a message like Connect to http://user.localhost.run or https://user.localhost.run)
When I launch it through LSF (using bsub), I don't get any output from SSH (but get the output from the other commands).
I have also tried redirecting the output of ssh to a file: it works fine when launched from the command line but not when launched from LSF.

Getting "Server unexpectedly closed network connection" after executing a remote command with Plink

I am using Plink to execute remote command:
When using remote command (text file) error occurs:
FATAL ERROR: Server unexpectedly closed network connection
test.bat
"C:\Program Files (x86)\PuTTY\plink.exe" XX.XX.XX.XX -l userID -pw password -m "D:\FindingLog\test.txt"
test.txt
cd log
When I remove -m "D:\FindingLog\test.txt" in batch file, it works (successful login)
What's the problem?
The SSH session closes (and Plink with it) as soon as the command finishes. Normally the "command" is shell. As you have overridden this default "command" and yet you seem to want to run the shell nevertheless, you have to explicitly execute the shell yourself:
cd log
/bin/bash
Also as use of -m switch implies a non-interactive terminal, you probably want to force an interactive terminal back using -t switch.
See also How to prevent PuTTY shell from auto-exit after executing command from batch file in Windows?
Upgrading to plink 0.74 fixed this issue for me (from much older version 0.60).

'xterm-new': unknown terminal type

Replicating the error:
I am using iTerm2 on Macbook (OS X Yosemite)
I ssh into a remote instance and tried to run the clear command and this error is shown:
'xterm-new': unknown terminal type.
Not only for the clear command but the same error is displayed for several other commands and the command does not execute as expected.
The error occurs only when I use iTerm2 and not when I use the default Mac Terminal. So I am guessing this problem has something to do with iTerm2 and not the virtual machine.
How can I solve this problem with iTerm2?
As mikyra pointed out in the comments above, setting the environment variable TERM=xterm-256color solves the problem.
To summarize:
# Run the following commands on the local machine's bash prompt
echo "export TERM=xterm-256color" >> ~/.bashrc
source ~/.bashrc
ssh into remote machine and run the commands you like. The same xterm-new error should not occur now.

How to fail gitlab CI build?

I am trying to fail a build in gitlab CI and get email notification about it.
My build script is this:
echo "Listing files!"
ls -la
echo "##########################Preparing build##########################"
mkdir build
cd build
echo "Generating make files"
cmake -G "Unix Makefiles" -D CMAKE_BUILD_TYPE=Release -D CMAKE_VERBOSE_MAKEFILE=on ..
echo "##########################Building##########################"
make
I have commited the code that breaks build. However, instead of finishing, build seems to be stuck in "running" state after exiting make. Last line is:
make: *** [all] Error 2
I also get no notifications.
How can i diagnose what is happening?
Upd.: in runner, following is repeated in log:
Submitting build <..> to coordinator...response error: 500
In production.log and sideq.log of gitlab_ci, following is written:
ERROR: Error connecting to Redis on localhost:6379 (ECONNREFUSED)
Full message with stacktrace is here: pastebin.
I have the same problem, i can help you with a workaround but im trying to fully fix it.
1- most of the times he hangs but the jobs keeps on going and actually finishes it, you can see the processes inside the machine, example: in my case it compiles and in the end it uses docker to publish the build, so the process docker doesn't exist until he reaches that phase.
2- to workaround this issue you have to make the data persistent and "retry" the download over and over again until he downloads everything he needs.
PS: stating what kind of OS you are using always helps.