ftrace leads to linux blocking and no response - ftrace

I am working on GPON ONT (Broadcom 68380(MIPS32), 256MB memory) Linux kernel 3.4.11rt, after type in echo function > current_tracer, the console no response.
ONT3#: cd /sys/kernel/debug/tracing
ONT3#: # echo 'rdpa*' > set_ftrace_filter
ONT3#: # echo 0 > tracing_on
ONT3#: # echo function > current_tracer <--- ONT stucked here
I run the above commands in Ubuntu16.04 everything is ok.
There is one similar question here (Title is "Ftrace on android freeze when turn on function trace, somebody help me"), but I already filtered with 'rdpa*' and narrow down the filter even with one function, system still blocked, the Magic SysRequest Key also no response.
detail log:
ONT3#:/ # mount -t debugfs nodev /sys/kernel/debug
ONT3#:/ # cd sys/kernel/debug/
ONT3#:/sys/kernel/debug # ls
bdi mips tracing usb
ONT3#:/sys/kernel/debug # ls -l
drwxr-xr-x 26 root root 0 Jan 1 00:00 bdi
drwxr-xr-x 3 root root 0 Jan 1 00:00 mips
drwxr-xr-x 5 root root 0 Jan 1 00:00 tracing
drwxr-xr-x 2 root root 0 Jan 1 00:00 usb
ONT3#:/sys/kernel/debug # cd tracing/
ONT3#:/sys/kernel/debug/tracing # ls -l
-r--r--r-- 1 root root 0 Jan 1 00:00 README
-r--r--r-- 1 root root 0 Jan 1 00:00 available_events
-r--r--r-- 1 root root 0 Jan 1 00:00 available_filter_functions
-r--r--r-- 1 root root 0 Jan 1 00:00 available_tracers
-rw-r--r-- 1 root root 0 Jan 1 00:00 buffer_size_kb
-r--r--r-- 1 root root 0 Jan 1 00:00 buffer_total_size_kb
-rw-r--r-- 1 root root 0 Jan 1 00:00 current_tracer
-r--r--r-- 1 root root 0 Jan 1 00:00 dyn_ftrace_total_info
-r--r--r-- 1 root root 0 Jan 1 00:00 enabled_functions
drwxr-xr-x 27 root root 0 Jan 1 00:00 events
-rw-r--r-- 1 root root 0 Jan 1 00:00 free_buffer
drwxr-xr-x 2 root root 0 Jan 1 00:00 options
drwxr-xr-x 4 root root 0 Jan 1 00:00 per_cpu
-r--r--r-- 1 root root 0 Jan 1 00:00 printk_formats
-r--r--r-- 1 root root 0 Jan 1 00:00 saved_cmdlines
-rw-r--r-- 1 root root 0 Jan 1 00:00 set_event
-rw-r--r-- 1 root root 0 Jan 1 00:00 set_ftrace_filter
-rw-r--r-- 1 root root 0 Jan 1 00:00 set_ftrace_notrace
-rw-r--r-- 1 root root 0 Jan 1 00:00 set_ftrace_pid
-r--r--r-- 1 root root 0 Jan 1 00:00 set_graph_function
-rw-r--r-- 1 root root 0 Jan 1 00:00 trace
-rw-r--r-- 1 root root 0 Jan 1 00:00 trace_clock
--w--w---- 1 root root 0 Jan 1 00:00 trace_marker
-rw-r--r-- 1 root root 0 Jan 1 00:00 trace_options
-r--r--r-- 1 root root 0 Jan 1 00:00 trace_pipe
-rw-r--r-- 1 root root 0 Jan 1 00:00 tracing_cpumask
-rw-r--r-- 1 root root 0 Jan 1 00:00 tracing_enabled
-rw-r--r-- 1 root root 0 Jan 1 00:00 tracing_on
-rw-r--r-- 1 root root 0 Jan 1 00:00 tracing_thresh
ONT3#:/sys/kernel/debug/tracing # cat current_tracer
nop
ONT3#:/sys/kernel/debug/tracing # echo function > current_tracer
What should I do to fix this issue? Please share your comments.
Thank you so much.

Related

Invalid value for "path" parameter: no file exists at

As mentioned at Terraform Resource: Connection Error while executing apply
I changed my code to the the below
provisioner "remote-exec" {
connection {
type = "ssh"
host = aws_eip.nat-eip.public_ip
user = "ubuntu"
private_key = file("/id_rsa.pem")
}
inline = [
"chmod +x /tmp/start_node.sh",
"sudo sed -i -e 's/\r$//' /tmp/start_node.sh", # Remove the spurious CR characters.
"sudo /tmp/start_node.sh",
]
}
But I still get the same error
Error: Invalid function argument
on explorer.tf line 60, in resource "aws_instance" "explorer":
60: private_key = file("/id_rsa.pem")
Invalid value for "path" parameter: no file exists at /id_rsa.pem;
this function works only with files that are distributed as part of the
configuration source code, so if this file will be created by a resource in
this configuration you must instead obtain this result from an attribute of
that resource.
ls -la ooutput
total 156
drwxr-xr-x 10 CORP\mayuresh CORP\domain users 4096 Jan 12 14:29 .
drwxr-xr-x 16 CORP\mayuresh CORP\domain users 4096 Jan 10 13:10 ..
drwxr-xr-x 12 CORP\mayuresh CORP\domain users 4096 Jan 12 09:49 byoc-terraform
drwxr-xr-x 2 CORP\mayuresh CORP\domain users 4096 Jan 11 11:57 controllers
-rw-r--r-- 1 CORP\mayuresh CORP\domain users 188 Jan 10 13:27 .env
-rw-r--r-- 1 CORP\mayuresh CORP\domain users 1582 Jan 10 17:12 fetchUserData.js
drwxr-xr-x 9 CORP\mayuresh CORP\domain users 4096 Jan 12 13:14 .git
-rw-r--r-- 1 CORP\mayuresh CORP\domain users 629 Jan 10 13:27 .gitignore
-rw-r--r-- 1 CORP\mayuresh CORP\domain users 107 Dec 30 06:49 .gitmodules
-rw-r--r-- 1 CORP\mayuresh CORP\domain users 1765 Jan 12 13:21 id_rsa.pem
-rw-r--r-- 1 CORP\mayuresh CORP\domain users 1488 Jan 10 13:27 index.js
drwxr-xr-x 3 CORP\mayuresh CORP\domain users 4096 Jan 10 13:27 models
drwxr-xr-x 221 CORP\mayuresh CORP\domain users 12288 Jan 10 13:30 node_modules
-rw-r--r-- 1 CORP\mayuresh CORP\domain users 1058 Jan 10 13:27 package.json
-rw-r--r-- 1 CORP\mayuresh CORP\domain users 78791 Jan 10 13:27 package-lock.json
drwxr-xr-x 2 CORP\mayuresh CORP\domain users 4096 Jan 10 13:27 routes
drwxr-xr-x 2 CORP\mayuresh CORP\domain users 4096 Jan 10 17:01 utils
drwxr-xr-x 2 CORP\mayuresh CORP\domain users 4096 Jan 10 13:27 VMCreationFiles```
Have you tried using the full path? Especially beneficial if you are using modules.
I.E:
private_key = file("${path.module}/id_rsa.pem")
Or I think even this will work
private_key = file("./id_rsa.pem")
I believe your existing code is looking for the file at the root of your filesystem.
Your path to the .pem is wrong. It looks like the file exists in your $HOME directory.
You can provide the absolute path of the id_rsa.pem file if that file is outside of path.module, path.root, path.cwd
To provide the absolute path
Fetch the full path of the file How to get full path of a file?
Paste the path in:
provisioner "remote-exec" {
connection {
type = "ssh"
host = aws_eip.nat-eip.public_ip
user = "ubuntu"
private_key = file("<Absolute path to .pem file e.g /home/ubuntu/id_rsa.pem>")
}

GCP's SSH terminal not working after stopping and starting vm instance

I am using gcp vm machine instance N1-standard 8V-30GB and N1-standard 4V-15GB
os-Debian
version - Debian GNU/Linux 10(buster)
this issue i am facing from last 1 month.
public access permission denied is one of message i am seeing while trying to access from cloud shell
I had run command chmod 777 <home directory> earlier.
I've tried to reproduce your steps and was able to solve this issue.
Please have a look at my steps below:
create VM instances:
gcloud compute instances create instance-1 --zone=europe-west3-a --machine-type=e2-medium --image=ubuntu-1804-bionic-v20200701 --image-project=ubuntu-os-cloud
gcloud compute instances create instance-2 --zone=europe-west3-a --machine-type=e2-medium --image=ubuntu-1804-bionic-v20200701 --image-project=ubuntu-os-cloud
change permissions recursively on my home directory at the VM instance instance-1:
instance-1:~$ chmod -R 777 ~
instance-1:~$ ls -la
...
drwxrwxrwx 2 username username 4096 Jul 15 07:50 .ssh
create snapshot of the VM instance instance-1 boot disk:
gcloud compute disks snapshot instance-1 --snapshot-names instance-1-snapshot --zone=europe-west3-a
create a new disk with the snapshot:
gcloud compute disks create instance-1-snapshot-disk --zone=europe-west3-a --source-snapshot=instance-1-snapshot
attach created disk instance-1-snapshot-disk to the VM instance instance-2:
instance-2:~$ ls -l /dev/ | grep sd
brw-rw---- 1 root disk 8, 0 Jul 15 07:39 sda
brw-rw---- 1 root disk 8, 1 Jul 15 07:39 sda1
brw-rw---- 1 root disk 8, 14 Jul 15 07:39 sda14
brw-rw---- 1 root disk 8, 15 Jul 15 07:39 sda15
instance-2:~$ mount | grep sda
/dev/sda1 on / type ext4 (rw,relatime)
/dev/sda15 on /boot/efi type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
then
gcloud compute instances attach-disk instance-2 --disk=instance-1-snapshot-disk --zone=europe-west3-a
after that
instance-2:~$ ls -l /dev/ | grep sd
brw-rw---- 1 root disk 8, 0 Jul 15 07:39 sda
brw-rw---- 1 root disk 8, 1 Jul 15 07:39 sda1
brw-rw---- 1 root disk 8, 14 Jul 15 07:39 sda14
brw-rw---- 1 root disk 8, 15 Jul 15 07:39 sda15
brw-rw---- 1 root disk 8, 16 Jul 15 08:04 sdb
brw-rw---- 1 root disk 8, 17 Jul 15 08:04 sdb1
brw-rw---- 1 root disk 8, 30 Jul 15 08:04 sdb14
brw-rw---- 1 root disk 8, 31 Jul 15 08:04 sdb15
instance-2:~$ sudo mkdir /mnt/instance-1-snapshot-disk
instance-2:~$ sudo mount /dev/sdb1 /mnt/instance-1-snapshot-disk
instance-2:~$ ls -la /mnt/instance-1-snapshot-disk
total 104
drwxr-xr-x 23 root root 4096 Jul 15 07:56 .
drwxr-xr-x 3 root root 4096 Jul 15 08:05 ..
drwxr-xr-x 2 root root 4096 Jul 1 19:14 bin
drwxr-xr-x 4 root root 4096 Jul 1 19:19 boot
drwxr-xr-x 4 root root 4096 Jul 1 19:11 dev
drwxr-xr-x 93 root root 4096 Jul 15 07:55 etc
drwxr-xr-x 4 root root 4096 Jul 15 07:50 home
lrwxrwxrwx 1 root root 30 Jul 1 19:18 initrd.img -> boot/initrd.img-5.3.0-1030-gcp
lrwxrwxrwx 1 root root 30 Jul 1 19:18 initrd.img.old -> boot/initrd.img-5.3.0-1030-gcp
drwxr-xr-x 22 root root 4096 Jul 1 19:17 lib
drwxr-xr-x 2 root root 4096 Jul 1 19:01 lib64
drwx------ 2 root root 16384 Jul 1 19:13 lost+found
drwxr-xr-x 2 root root 4096 Jul 1 19:01 media
drwxr-xr-x 2 root root 4096 Jul 1 19:01 mnt
drwxr-xr-x 2 root root 4096 Jul 1 19:01 opt
drwxr-xr-x 2 root root 4096 Apr 24 2018 proc
drwx------ 3 root root 4096 Jul 15 07:36 root
drwxr-xr-x 4 root root 4096 Jul 1 19:19 run
drwxr-xr-x 2 root root 4096 Jul 1 19:17 sbin
drwxr-xr-x 6 root root 4096 Jul 15 07:36 snap
drwxr-xr-x 2 root root 4096 Jul 1 19:01 srv
drwxr-xr-x 2 root root 4096 Apr 24 2018 sys
drwxrwxrwt 7 root root 4096 Jul 15 07:56 tmp
drwxr-xr-x 10 root root 4096 Jul 1 19:01 usr
drwxr-xr-x 13 root root 4096 Jul 1 19:12 var
lrwxrwxrwx 1 root root 27 Jul 1 19:18 vmlinuz -> boot/vmlinuz-5.3.0-1030-gcp
lrwxrwxrwx 1 root root 27 Jul 1 19:18 vmlinuz.old -> boot/vmlinuz-5.3.0-1030-gcp
change permissions:
.ssh directory: 700 drwx------
public key (.pub file): 644 -rw-r--r--
private key (id_rsa): 600 -rw-------
lastly your home directory should not be writeable by the group or others: 755 drwxr-xr-x
instance-2:~$ chmod -R 755 /mnt/instance-1-snapshot-disk/home/username/
instance-2:~$ chmod -R 700 /mnt/instance-1-snapshot-disk/home/username/.ssh/
instance-2:~$ chmod 644 /mnt/instance-1-snapshot-disk/home/username/.ssh/authorized_keys
unmount the disk when you finish:
instance-2:~$ sudo umount /mnt/instance-1-snapshot-disk/
detach disk instance-1-snapshot-disk from the VM instance instance-2:
gcloud compute instances detach-disk instance-2 --disk=instance-1-snapshot-disk --zone=europe-west3-a
create a new instance from the repaired disk:
gcloud compute instances create instance-3 --zone=europe-west3-a --machine-type=e2-medium --disk=name=instance-1-snapshot-disk
check SSH connection to at the VM instance instance-1.
In addition, please have a look at the documentation Troubleshooting SSH section Inspect the VM instance without shutting it down to find more details.
From owner's account i tried to access instance-1 but owner is also not able to connect to the instance-1.
owner of project got this pop-up on ssh window
[1]: https://i.stack.imgur.com/y2fzC.jpg
I observe that in fresh new created instance if i add add some file like git clone repo, after that if i restart it then i am able to connect SSH again.

how to compile mariadb to get libmysqlclient.so? (missing libmysqlclient.so in /usr/local/mysql/lib)

I wanted to move our database from mysql (community version) to mariadb with the further use of php7.1/apache2.4.25... So I have to compile mariadb in our new production environment. I compiled it with these options:
cmake -DCMAKE_CXX_FLAGS:STRING="-std=c++11" -DCONC_WITH_CURL=ON -DCONC_WITH_EXTERNAL_ZLIB=ON -DDISABLE_SHARED=OFF -DCONC_WITH_MYSQLCOMPAT:BOOL=ON -DPLUGIN_CLIENT_ED25519:STRING=DYNAMIC .
make all && make install
The mysql community version has a libmysqlclient.so in /usr/local/mysql/lib located. If I compile it with the options given above I only found these files in /usr/local/mysql/lib (MariaDB 10.2.6):
# ls -l /usr/local/mysql/lib/
total 3572
-rw-r--r-- 1 root root 2305518 Jul 4 08:14 libmariadbclient.a
lrwxrwxrwx 1 root root 15 Jul 4 08:31 libmariadb.so -> libmariadb.so.3
-rwxr-xr-x 1 root root 1297664 Jul 4 08:14 libmariadb.so.3
-rw-r--r-- 1 root root 48406 Jul 4 08:14 libmysqlservices.a
drwxr-xr-x 2 root root 4096 Jul 4 08:31 plugin
How can I get libmysqlclient.so? There isn't also any libmariadbclient.so just libmariadbclient.a ...
Thank you for further hints!
OK, now I found a solution.
I've just did a symbolic link to libmariadb.so and it now looks like the following:
ls -l /usr/local/mysql/lib/
total 3572
-rw-r--r-- 1 root root 2305518 Jul 4 16:21 libmariadbclient.a
lrwxrwxrwx 1 root root 15 Jul 4 16:39 libmariadb.so -> libmariadb.so.3
-rwxr-xr-x 1 root root 1297664 Jul 4 16:21 libmariadb.so.3
lrwxrwxrwx 1 root root 15 Jul 4 16:40 libmysqlclient_r.so -> libmariadb.so.3
lrwxrwxrwx 1 root root 15 Jul 4 16:40 libmysqlclient.so -> libmariadb.so.3
-rw-r--r-- 1 root root 48406 Jul 4 16:21 libmysqlservices.a
drwxr-xr-x 2 root root 4096 Jul 4 16:39 plugin
In this case PHP 7 would finally find the mysql libraries...

Select specific columns from a record using only 'sed' without using 'awk'

Here are some sample input I obtain from doing ls -l :
-rwxr-xr-x 1 root root 1779 Jan 10 2014 zcmp
-rwxr-xr-x 1 root root 5766 Jan 10 2014 zdiff
-rwxr-xr-x 1 root root 142 Jan 10 2014 zegrep
-rwxr-xr-x 1 root root 142 Jan 10 2014 zfgrep
-rwxr-xr-x 1 root root 2133 Jan 10 2014 zforce
-rwxr-xr-x 1 root root 5940 Jan 10 2014 zgrep
lrwxrwxrwx 1 root root 8 Dec 5 2015 ypdomainname -> hostname
I would like to print out the last column and 5th column using ONLY sed like this:
zcmp 1779
zdiff 5766
zegrep 142
zfgrep 142
zforce 2133
zgrep 5940
ypdomainname -> hostname 8
I'm trying to find a regex to match but have not succeeded. And I'm not allowed to use awk or cut either.
Thank you in advance.
Try this;
ls -l | sed -r 's/^(\S+\s+){5}(\S+\s+){3}/\1/' | sed 's/^\(.*\) \(.*\)$/\2\ \1/g'

Zero-byte files in /usr/local/bin after AMI captured

I am launching an EC2 instance using Ansible and capturing an AMI image. I have verified that these dependencies get installed correctly on the instance. For example, this is what I get on the EC2 instance just before AMI imaging:
ubuntu#ip-1-2-3-4:/usr/local/bin$ ansible --version
ansible 1.4.4
-rwxr-xr-x 1 root root 5907 Jan 31 22:20 ansible
-rwxr-xr-x 1 root root 9269 Jan 31 22:20 ansible-doc
-rwxr-xr-x 1 root root 29163 Jan 31 22:20 ansible-galaxy
-rwxr-xr-x 1 root root 10419 Jan 31 22:20 ansible-playbook
-rwxr-xr-x 1 root root 6916 Jan 31 22:20 ansible-pull
-rwxr-xr-x 1 root root 714 Jan 31 22:19 aws
-rwxr-xr-x 1 root root 1408 Jan 31 22:19 aws.cmd
-rwxr-xr-x 1 root root 897 Jan 31 22:19 aws_completer
-rwxr-xr-x 1 root root 1860 Jan 31 22:19 aws_zsh_completer.sh
The problem is that once I capture an AMI and launch a new instance, I all files in /usr/local/bin are zero-byte files!
-rwxr-xr-x 1 root root 0 Jan 31 22:20 ansible
-rwxr-xr-x 1 root root 0 Jan 31 22:20 ansible-doc
-rwxr-xr-x 1 root root 0 Jan 31 22:20 ansible-galaxy
-rwxr-xr-x 1 root root 0 Jan 31 22:20 ansible-playbook
-rwxr-xr-x 1 root root 0 Jan 31 22:20 ansible-pull
-rwxr-xr-x 1 root root 0 Jan 31 22:19 aws
-rwxr-xr-x 1 root root 0 Jan 31 22:19 aws.cmd
-rwxr-xr-x 1 root root 0 Jan 31 22:19 aws_completer
-rwxr-xr-x 1 root root 0 Jan 31 22:19 aws_zsh_completer.sh
Why are these files being zero'ed out when I create a new instance from the AMI?
This was a problem with Ansible, not with AWS. Turns out there's a documentation bug in Ansible 1.4.4 where the ec2_ami module does not shut down and reboot the instance by default (the docs claim it does!). This causes all sorts of problems with file system integrity.
The fix is to include no_reboot: no in the Ansible task.