How to disable cephfs in ceph/rook? - rook-storage

I want to disable cephfs as I dont have that use case. Is there a way to disable it ? By default I see few cephfs pods are in running state when we create a ceph cluster
[root#rnasani-ctrl-master-node1 ~]# kubectl get pods -n test-storage-system
NAME READY STATUS RESTARTS AGE
csi-cephfsplugin-5h7gm 3/3 Running 0 9d
csi-cephfsplugin-5slz7 3/3 Running 0 9d
csi-cephfsplugin-ltgrr 3/3 Running 0 9d
csi-cephfsplugin-provisioner-767d5c9565-kjvbh 6/6 Running 0 9d
csi-cephfsplugin-provisioner-767d5c9565-thtwr 6/6 Running 0 9d
. . .
Having cephfs pods is waste of resources for my use case.

Related

Running fork, dup2 and exec from a C program in background

I'm developing a embedded C application (gather.out) for a controller that runs Debian 8 (Jessie). This application calls another program called gather. The gather program prints some data on screen when I run it alone on the terminal. I decided to use fork and dup2 to redirect the output to a output file that contains the gathered data, as follows:
pid_t pid=fork();
/* Child process */
if(pid==0)
{
// Open gather output file
int gather_file_fd=open(actual_filename, O_WRONLY | O_CREAT, 0777);
if(gather_file_fd==-1)
{
return 2;
}
// Make stdout of gather program as input of output gather file
int gather_file_fd_dup=dup2(gather_file_fd, STDOUT_FILENO);
// Run the gather program
int err;
err=execl("/usr/bin/gather","gather","-w",NULL);
if(err==-1)
{
return 2;
}
}
Everything goes fine when I run it from the terminal, manually. When I set the controller to run it as startup (I don't know exactly how the controller start the program on boot, but it does) my output file gets corrupted.
I don't know how to debug this problem but I was trying to see the TTY of the processes to have some idea about what's happening using ps ux | grep gather. When running manually:
# ps ux | grep gather
root 18014 49.4 0.3 219380 6240 pts/0 RLl+ 14:50 0:51 ./gather.out
root 18022 39.2 0.2 219304 5988 pts/0 RLl+ 14:52 0:01 gather -w
root 18026 0.0 0.0 2076 568 pts/22 S+ 14:52 0:00 grep gather
And running at startup:
# ps ux | grep gather
root 17859 80.5 0.3 219380 6240 ? RLl 14:42 0:33 /var/ftp/usrflash/Project/C Language/Background Programs/gather.out
root 17978 45.0 0.2 219304 5984 ? RLl 14:43 0:01 gather -w
root 17982 0.0 0.0 2076 532 pts/0 S+ 14:43 0:00 grep gather
From there I noticed that there is no TTY attached to the processes running the program at startup. Does it affect the way I redirect the output with fork, dup2 and execl?
Edit 1
The correct output file must be like this (produced by gather application, runing gather -w > /var/ftp/gather/test.txt on the terminal and start the data acquisition on controller's IDE):
Waiting to gather
0 0 0
0 0 0
0 0 0
...
Where each line 0 0 0 is the sampled signals from the controller and could be any value, the ... indicates that the file is very large. When I run the gather program on the terminal gather -w > /var/ftp/gather/test.txt &, start data acquisition on controller's IDE, the gather program suddenly stops when I hit enter on terminal:
# gather -w > /var/ftp/gather/test.txt &
[2] 22232
#
[2]+ Stopped gather -w > /var/ftp/gather/test.txt
#
And the output file prints just the header:
Waiting to gather
Starting the gather program in background using gather -w < /dev/null >& /var/ftp/gather/test.txt & as one of the comments' advices and starting the data acquisition on controller's IDE I got the following file output:
Waiting to gather
Waiting to gather
Waiting to gather
Waiting to gather
...
The number of lines on the file is much greater than the number of samples on sample counter watched by IDE. My guess lies on a bug in the gather program. Unfortunatly I don't have gather's source code because it's part of natively programs of the controller.

Problem with change PostgreSQL data drive

I want change drive where I keep my data of postgresql on VPS server with Ubuntu 18.04.
Now it's default:
data_directory = '/var/lib/postgresql/10/main'
on /dev/sda. I want keep this on /dev/sdb. I have created partition /dev/sdb1 properly.
I find tutorial: https://www.tutorialspoint.com/how-to-change-postgresql-data-folder-location-on-ubuntu-16-04
I did the same steps like above, means:
Stop postgresql process
Copy all data from /var/lib/postgresql to my second drive to /second_drive/postgresql_data
Change 'data_directory' in my postgresql.conf
Start postgresql - and here I have problem. DB doesn't starting. I don't remember error, and I can't check this now because my db have to working whole weekend.
Anyone has a idea what's causes problem? Something another to change too? I looking info in google, but all tuts looking like than above.
EDIT:
I remembered that the problem was with the permissions for postgres user.
I tried now again change the permissions for directory with data, but chown not working - I mean, terminal not return any error/message, but the permissions/ownership not change. I find info that's problem is because I tried change permissions on mounted drive, but it's not possible on NTFS drives. I'm confused about that. My current data is on /dev/md3 to /disk_ssd_3
I putting info from my linux below:
/etc/fstab - I don't know where is my /disk_ssd_3
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/md3 / ext4 errors=remount-ro 0 1
/dev/md2 /boot ext4 errors=remount-ro 0 1
/dev/nvme0n1p4 swap swap defaults 0 0
/dev/nvme1n1p4 swap swap defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
UUID=E368-416A /boot/efi vfat defaults 0 0
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 1.8T 0 disk
└─sda1 8:1 0 1.8T 0 part /disk_hdd_1
sdb 8:16 0 1.8T 0 disk
└─sdb1 8:17 0 1.8T 0 part /disk_hdd_2
nvme1n1 259:0 0 419.2G 0 disk
└─nvme1n1p1 259:6 0 419.2G 0 part /disk_ssd_3
nvme0n1 259:1 0 419.2G 0 disk
├─nvme0n1p1 259:2 0 511M 0 part /boot/efi
├─nvme0n1p2 259:3 0 511M 0 part
│ └─md2 9:2 0 511M 0 raid1 /boot
├─nvme0n1p3 259:4 0 417.7G 0 part
│ └─md3 9:3 0 417.7G 0 raid1 /
└─nvme0n1p4 259:5 0 511M 0 part [SWAP]

Nagios Tool, total running time for the tool

Is there any way to check for how long the NAGIOS TOOL runs? I mean when the tool started running and the time up till now.
Nagios is running in a remote machine, in which I have access (through ssh). I have both credentials for accessing the machine and credentials just to see the Stats from Nagios on this machine
I tried System->Process Info, but I do not have privileges to view such information.
Is there any other way, through terminal?
You can use nagiostats to check the uptime of a Nagios instance. See: https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/3/en/nagiostats.html
[nagios#lanman ~]# /usr/local/nagios/bin/nagiostats -c /usr/local/nagios/etc/nagios.cfg
Nagios Stats 3.0prealpha-05202006
Copyright (c) 2003-2007 Ethan Galstad (www.nagios.org)
Last Modified: 05-20-2006
License: GPL
CURRENT STATUS DATA
------------------------------------------------------
Status File: /usr/local/nagios/var/status.dat
Status File Age: 0d 0h 0m 9s
Status File Version: 3.0prealpha-05202006
Program Running Time: 0d 5h 20m 39s <------------
Nagios PID: 10119
Used/High/Total Command Buffers: 0 / 0 / 64
Used/High/Total Check Result Buffers: 0 / 7 / 512
...
Find the nagios.log file, it's likely in the var directory under the Nagios installation. Then..
grep "Nagios.*starting" nagios.log | tail -1
Grab the epoch time (first field), and convert it to local.
date -d #1580045430
Sun Jan 26 07:30:30 CST 2020
All in one, assuming the nagios.log is in the current directory.
date -d #$(grep "Nagios.*starting" nagios.log | tail -1 | awk '{print $1}' | sed 's/\[//;' | sed 's/\]//;')
Sun Jan 26 07:30:30 CST 2020

copy db file with adb pull results in 'permission denied' error

I just rooted my Nexus 5 using this method: http://www.phonearena.com/news/How-to-root-Google-Nexus-5_id49014
I also enabled USB debugging in the developer options.
Then I tried to pull a database file from my device using this command:
adb pull /data/data/path.to.package/databases/data /sdcard/test
I get permission denied error.
I don't have the debugged flag set in that app I tried to access. Is that the reason I can't access that file? If yes, are there any workarounds to access an apps files?
You can use run-as shell command to access private application data.
If you only want to copy database you can use this snippet, provided in
https://stackoverflow.com/a/31504263/998157
adb -d shell "run-as com.example.test cat /data/data/com.example.test/databases/data.db" > data.db
I had the same problem. My work around is to use adb shell and su. Next, copy the file to /sdcard/Download
Then, I can use adb pull to get the file.
Did you try adb remount after giving adb root?
This generic solution should work on all rooted devices:
adb shell "su -c cat /data/data/com.android.providers.contacts/databases/contacts2.db" > contacts2.d
The command connects as shell, then executes cat as root and collects the output into a local file.
In opposite to #guest-418 s solution, one does not have to dig for the user in question.
Plus If you get greedy and want all the db's at once (eg. for backup)
for i in `adb shell "su -c find /data -name '*.db'"`; do
mkdir -p ".`dirname $i`"
adb shell "su -c cat $i" > ".$i"
done
This adds a mysteryous question mark to the end of the filename, but it is still readable.
If you get could not copy and permissions are right disable selinux.
Check if selinux is enabled.
$ adb shell
$su
# getenforce
Enforcing
Selinux is enabled and blocking/enforcing.
Disable selinux
# setenforce 0
do your stuff and set selinux to enforcing.
# setenforce 1
I had just the same problem, here's how to deal with it:
adb shell to the device
su
ls -l and check current access rights on the file you need. You'll need that later.
go to the file needed and: chmod 777 file.ext. Note: now you have a temporary security issue. You've just allowed all the rights to everyone! Consider adding just R for users.
open another console and: adb pull /path/to/file.ext c:\pc\path\to\file.exe
Important: after you're done, revert the access rights back to the previous value (point 3)
Someone mentioned something similar earlier.
Thanks for the comments below.
This answer ended up working for me: https://stackoverflow.com/a/15559278/53001
Backup to a file, pull the backup, and then convert it to a tarball and extract it.
adb backup -f myAndroidBackup.ab com.corp.appName
dd if=myAndroidBackup.ab bs=1 skip=24 | python -c "import zlib,sys;sys.stdout.write(zlib.decompress(sys.stdin.read()))" | tar -xvf -
$ adb shell
$su
# getenforce
Enforcing
now try
adb shell
su
chmod 777 /path/to/yout_file
exit from shell
open new CMD and try adb pull /path/to/yout_file
It will work fine now.
you'll have security problems because of this any application will be able to access your database.
#guest-418 tips works well:
adb -d shell "run-as com.example.test cat /data/data/com.example.test/databases/data.db" > data.db
However, if you want to use a GUI, use Android Studio's Device File Explorer.
Launch Android Studio
Click on Device File Explorer at bottom right-side
Navigate to your app's file:
/data/data/path.to.package/databases/data
Right-mouse click select Save As and save to a local folder
I have been having Android Monitor hang on me lately on macOS. Device File Explorer works well for this purpose.
Create a folder in sdcard :
adb shell "su 0 mkdir /sdcard/com.test"
Move your files to the new folder :
adb shell "su 0 mv -F /data/data/com.test/files/ /sdcard/com.test/"
You can now use adb pull :
adb pull /sdcard/com.test
When executing adb commands, by default, a limited privileges user is used, the same kind of limited privilege user that is assigned to an app, and you have requested for all privelages to use all features of the device.
This kind of limited user helps protect your phone from malware, by restricting the access between apps, and the system. This is the reason you are unable to access app data and system data on an unrooted phone. The act of rooting means becoming user 0, the super user of the system, capable of any action, and is the highest privilege. Your apps however, are still secure in that they can not talk to eachother.
Now when accessing secure files, note that you do not want to change the permissions of the file when you access it, which may allow for vulnerabilities.
An option that you could use instead, is to make a copy of the file on the sdcard as root, modify that as a standard user, and then move it back into the filesystem as root, while preserving the file permissions of the original file.
Since I've updated to Android Oreo, I had to use this script to fix 'permission denied' issue.
This script on Mac OS X will copy your db file to Desktop. Just change it to match your ADB_PATH, DESTINATION_PATH and PACKAGE NAME.
#!/bin/sh
ADB_PATH="/Users/xyz/Library/Android/sdk/platform-tools"
PACKAGE_NAME="com.example.android"
DB_NAME="default.realm"
DESTINATION_PATH="/Users/xyz/Desktop/${DB_NAME}"
NOT_PRESENT="List of devices attached"
ADB_FOUND=`${ADB_PATH}/adb devices | tail -2 | head -1 | cut -f 1 | sed 's/ *$//g'`
if [[ ${ADB_FOUND} == ${NOT_PRESENT} ]]; then
echo "Make sure a device is connected"
else
${ADB_PATH}/adb exec-out run-as ${PACKAGE_NAME} cat files/${DB_NAME} > ${DESTINATION_PATH}
fi
This is a bit late, but installing adbd Insecure worked for me. It makes adb run in root mode on production ("secure") devices, which is what you likely have.
A paid version is also available on Google Play if you want to support the developer.
I had a similar problem to yours on windows as the following.
D:\ProgramFiles\Android> adb pull /data/local/tmp/com.packagename_dumped_1766.dex D:\ProgramFiles\Android\com.packagename_dumped_1766.dex
adb: error: failed to copy '/data/local/tmp/com.packagename_dumped_1766.dex' to 'D:\ProgramFiles\Android\com.packagename_dumped_1766.dex': remote Permission denied
My solution:
At first I also made an attempt to use cat as ansi_lumen answered, but I got into trouble about CR and LR (\r\n) characters.
And then I just had to change those file permisions by chmod and pulled again to this problem was solved without introducing other problems. After that, may
we need to restore their original permissions as Goran Devs answered.
So just pay a little attention.
TL;DR
My story:
Firstly, I used the cat to download all files from android to my windows,
#echo off
cd /d %~dp0
:: %~dp0 = D:\ProgramFiles\Android\
SET ThisBatDir=%~dp0
:: adb shell ls /data/local/tmp/com.packagename_dumped_* > %~dp0\dump_file_list.txt
FOR /f "delims=" %%a in ('adb shell ls /data/local/tmp/com.packagename_dumped_*') do call :processline %%a %%~nxa
goto :eof
:: https://stackoverflow.com/questions/232651/why-the-system-cannot-find-the-batch-label-specified-is-thrown-even-if-label-e
:processline
SET RemoteFullPath=%1
set FileName=%2
:: echo "%RemoteFullPath%|%ThisBatDir%|%FileName%"
call adb shell su -c cat %RemoteFullPath% > %ThisBatDir%%FileName%
goto :eof
:eof
However, those downloaded dex files were broken because of CR and LR (\r\n) characters on windows.
We can use hexdump to inspect its content in Hex+ASCII form (or Notepad++ with "View > Show Symbol > Show All Characters" checked). Note, the 5th and 6th byte (0d 0a)).
ssfang#MONITO ~
$ hexdump -C -n32 /cygdrive/d/ProgramFiles/Android/com.packagename_dumped_1448.dex # a bad dex
00000000 64 65 78 0d 0d 0a 30 33 35 00 f7 8e e4 b5 03 c6 |dex...035.......|
00000010 29 22 98 55 21 e9 70 49 fe c8 e4 cc fa 94 cd 63 |)".U!.pI.......c|
00000020
ssfang#MONITO ~
$ hexdump -C -n32 /cygdrive/d/ProgramFiles/Android/classes.dex # a normal dex
00000000 64 65 78 0a 30 33 35 00 b5 73 03 3a 0b 9d a2 47 |dex.035..s.:...G|
00000010 a8 78 a4 f0 bb e1 64 3f e5 b9 cb a0 bd 1b e2 71 |.x....d?.......q|
00000020
Versions
adb version // to check adb client version in your desktop
adb shell adbd --version // to check adbd's version in your Android. Please note that some users reported error with this if executed without root access.
D:\ProgramFiles\Android>adb version
Android Debug Bridge version 1.0.41
Version 29.0.6-6198805
Installed as D:\ProgramFiles\Android\Sdk\platform-tools\adb.exe
D:\ProgramFiles\Android>adb shell adb version
Android Debug Bridge version 1.0.32
Even if restarting adbd as root, it was still the shell user after .
D:\ProgramFiles\Android> adb root
restarting adbd as root
D:\ProgramFiles\Android> adb shell id
uid=2000(shell) gid=2000(shell) groups=1003(graphics),1004(input),1007(log),1011(adb),1015(sdcard_rw),1028(sdcard_r),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats) context=u:r:shell:s0
So I first viewed its file permision,
D:\ProgramFiles\Android> adb shell ls -l /data/local/tmp
-rwsr-sr-x shell shell 589588 2017-09-14 15:08 android_server
-rwsr-sr-x shell shell 1243456 2017-09-14 15:08 android_server64
-rw-rw-rw- shell shell 1536 2020-03-28 17:15 com.packagename.tar.gz
-rw-r----- root root 57344 2020-03-28 17:45 com.packagename_dumped_1766.dex
drwxrwxr-x shell shell 2018-08-12 09:48 device-explorer
-rwsrwsr-x shell shell 13592 2019-02-04 17:44 drizzleDumper
-rwxrwxrwx shell shell 5512504 2018-05-06 01:27 lldb-server
-rwxr-xr-x shell shell 12808 2020-03-26 22:16 mprop
then, changed its permision,
D:\ProgramFiles\Android> adb shell su -c chmod 777 /data/local/tmp/com.packagename_dumped_*
D:\ProgramFiles\Android> adb shell ls -l /data/local/tmp
-rwxrwxrwx root root 57344 2020-03-28 17:45 com.packagename_dumped_1766.dex
As a result, I made it.
D:\ProgramFiles\Android> adb pull /data/local/tmp/com.packagename_dumped_1766.dex D:\ProgramFiles\Android\com.packagename_dumped_1766.dex
/data/local/tmp/com.packagename_dumped_1766.de... 1 file pulled, 0 skipped. 3.6 MB/s (57344 bytes in 0.015s)
Now, jadx-gui-dev.exe or sh d2j-dex2jar.sh -f ~/path/to/apk_to_decompile.apk could properly enjoy them.
The pull command is:
adb pull source dest
When you write:
adb pull /data/data/path.to.package/databases/data /sdcard/test
It means that you'll pull from /data/data/path.to.package/databases/data and you'll copy it to /sdcard/test, but the destination MUST be a local directory. You may write C:\Users\YourName\temp instead.
For example:
adb pull /data/data/path.to.package/databases/data c:\Users\YourName\temp

On linux, how to check if port is in listen state without trying to connect

How do I check with C if a port on my local machine (if required by passing an IP or interface, too), is in listen state? I don't want to connect to this port for checking because I don't want to irritate the service behind this port.
I want to use this to add the missing net.tcp.listen item to Zabbix.
EDIT - THIS IS THE REAL ANSWER:
The correct way is to read the socket tables:
/proc/net/tcp
/proc/net/tcp6
They contain lines like:
sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
0: 00000000:1F40 00000000:0000 0A 00000000:00000000 00:00000000 00000000 101 0 4083927 1 f5d15240 750 0 0 2 -1
1: 00000000:2742 00000000:0000 0A 00000000:00000000 00:00000000 00000000 1002 0 6100 1 decd76c0 750 0 0 2 -1
and can easily parsed for listening sockets (dst:00000000:0000). An strace on netstat shows that netstat works the same way.
Just try to open the port for listening. You will get an error.
There is no way you can steal a port from another process, so this will be safe, and of course easy to implement as it requires no additional code other than proper error handling.
The correct way is to read the socket tables:
/proc/net/tcp
/proc/net/tcp6
They contain lines like:
sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
0: 00000000:1F40 00000000:0000 0A 00000000:00000000 00:00000000 00000000 101 0 4083927 1 f5d15240 750 0 0 2 -1
1: 00000000:2742 00000000:0000 0A 00000000:00000000 00:00000000 00000000 1002 0 6100 1 decd76c0 750 0 0 2 -1
and can easily parsed for listening sockets (dst:00000000:0000). An strace on netstat shows that netstat works the same way.
Something like netstat ?
`netstat -anp`
Will list all the ports and should do the trick.
Since this is open-source software, you can probably take some inspiration in it. And i believe it is written in C.
As per your query it seems to be that you want to check open port on your server, but on sure which command need to be run. No need to worries for example we try to found out if port 80 open on your server.
First login into server as root user
root#[~]# whoami
root
Now run following command.
root#[~]# netstat -anp | grep :80
It will give following output if port 80 open.
tcp 0 0 78.129.128.40:80 207.46.12.20:62746 TIME_WAIT -
tcp 0 0 78.129.128.40:80 74.53.3.132:47003 TIME_WAIT -
tcp 0 0 78.129.128.40:80 85.9.80.110:63325 FIN_WAIT2 -
And if port 80 blocked in your server you will not receive any output.
You can also use following URL to check open ports on your server.
http://www.yougetsignal.com/tools/open-ports/
Regards,
Gunjan
I don't know if you just want to see if your ports are open properly or if you want to integrate this into an application somehow. If yours is the prior case
nmap localhost
should handle it for you

Resources