Purpose : I need to get ulimit value
Is there any way I can issue a shell command from jmx-console to extract java/jboss process's ulimit value.
Thank you.
Not in a standard setup. You would need a custom MBean, but I would not expose a simple shell call. Risky. You might look at some different libraries that expose limits like SIGAR.
Related
As part of rundeck task i'm trying to login to a global zone, use the command zoneadm list and trying to login to each of the local zone [to shut down various apps & to issue reboot] using the command /usr/sbin/zlogin and execute hostname command to ensure it did login to localzone
however this is not working
Is there a better way to do this? Please guide
Make sure that your job is dispatching to your remote node correctly, you can call the command on "Commands" (right panel) pointing to your node (referenced in the "Nodes" textbox) in that way you can discard possible path/user rights issue, take a look at this. Now, zlogin seems an interactive shell, and as you can see, you need to use it in the non-interactive mode.
How can I create a mongodb procedure that can be scheduled to run once every day, at a fix time, say sharp at midnight GMT?
This google group link says you cannot schedule a task in mongoDB, they have a Jira for this, but you can use Window Task Scheduler which is described in this link. Is this the only way to achieve it? Is this a good way to do it?
Quoting the comment by #Markus,
As written in a different answer, running MongoDB on Windows is a bad idea for various reasons. Under Linux, you could use crond to run a .js file easily. If your requirement is to run MongoDB and have a reliable scheduler, the right tool for the job is Linux.
This answer also mentions the way to solve this.
This is done on Windows the same way you do on Linux.
ONE: Make a script in JavaScript to manage the task. This can be done in other languages if you prefer. This is a JavaScript script to rotate logs.
use admin
db.runCommand( { logRotate : 1 } )
TWO: Create a task in Task Scheduler to run the script. This can be done with the GUI, the API, or in XML. I usually set it up in the GUI and export the XML to allow parameterization of the database server, password, port, and user.
THREE: Include the execution of the script in the task
$MONGO_HOME/Mongo localhost:27017 -u myMongoServiceAccount -p somepassword LogRotate.js
The same concept can be applied to index management, gathering database stats, or managing stale locks.
Does MongoDB create a file I can poll for in order to determine when prealloc is done? Right now I have a script to run rs.init(..config..), but I need to wait with triggering it until mongod is up and running.
Since tail -f | grep .. | xarg.. the log file is a bit of a flaky hack, I wondered if there is any other way to determine that mongod is done with prealloc?
We have the same problem for testing replica sets with the PHP driver. Here we use the mongo shell's ReplSetTest() functionality to get around this. You can see here how that works:
https://github.com/mongodb/mongo-php-driver/blob/master/tests/utils/myconfig.js#L9
However, I am not sure how well this works for non-test environments as the amount of options you can give are rather limited (such as, you can't set a data dir properly as things are hardcoded). All the functions and code for this is all in JavaScript at https://github.com/mongodb/mongo/blob/master/src/mongo/shell/replsettest.js — this should give you an overview how it works and allows you to rewrite it in your preferred language.
try to use inotify (i am not sure exactly), for example, if it is necessary to determine that the file is closed after writing:
[maverick#mutabor ~]$ pyinotify -e IN_CLOSE_WRITE /tmp/testfile
I am working on a exploit project which needs me to invoke a root shell from within the kernel. After searching through various documents and websites, I came to know that the only way to do that is to elevate the current process to root privileges and then execute instructions to invoke shell. This is because we cannot simply invoke a system call from kernel.
For the same, I have come across the call commit_creds (prepare_kernel_cred (0));, which can be used to grant root privilege to the process. However, I am using Red Hat Enterprise Linux 4.4 Base and it does not have the above call:
[dmazumd#bn19-62 ~]$ grep commit_cred /proc/kallsyms
[dmazumd#bn19-62 ~]$ grep _cred /proc/kallsyms
c0164655 T compute_creds
c01a7cdd t dummy_bprm_apply_creds.....
So, my question is, how to go about this?
I understand that the need is to set the uid of the process to zero which will provide it root privileges. AFAIK, the uid resides in struct_cred rather than struct_task now. And I am unaware if I can directly access these structures without the use of any API as mentioned above. Is there any other call to achieve the same? Or, is there any other approach?
PS: I am not asking for the exact answer to my question, any direction/help would be appreciated.
To clarify things: Your kernel does not need 'root privileges'. It is actually above that. What you need is a process which can have privileges.
You could start looking what execve does to launch a process and do that.
If you've already a shell running AND you're in kernel mode, you could simply modify the uid in the task_struct (shed.h).
Also, take a look here.
I could finally achieve root shell by first elevating the process to root status while inside kernel. This was achieved by using the call set_user(0) call which is defined inside /proc/kallsyms.
Once this is done, the process switches back to user space using iret and then spawns a shell. This shell has root privileges.
I am wondering if anyone has a Perl script (or can write one) to execute on multiple hosts at once via ssh, without any modules. I used to have something like this but cannot find it now and can't remember how it was done.
Are you looking for ClusterSSH? It's Perl, and it's used to run the same commands on several hosts at once, so this might be what you're looking for...
You might want to try using Expect.pm which is similar to #cnicutar's suggestion of calling an Expect script from Perl, except that you write it all in Perl. (This of course down not fit the requirement of "without any modules", but that requirement leads to bad Perl )
Learn how to install and use modules even when you don't have admin privileges on the host
Use Net::OpenSSH::Parallel
If you cannot use any additional modules from CPAN or any other source , all I can recommend you are:
1) Use Expect script and call it internally in your Perl script [Only if you are not willing to use Expect.pm module]
2) Use SSH keygen in all the servers to which you will connect to , so that password wont be necessary in the script. As mentioned by "cnicutar"
3) Use "remsh" if SSH usage is not that necessary.