Home > Undocumented Commands > java netapp.cmds.jsh

java netapp.cmds.jsh

January 27th, 2009

There’s a little known hidden gem in the NetApp systems, a Java shell! We’re told that this is extremely dangerous and totally unsupported. Something as special as this obviously gets the hair on the back of my neck, and makes me want to see what I can break with it. So this is what happens when I play with the Java shell in the NetApp system!

Just a quick note, ^C does not break the current output, so if you “cat” a file, ^C will do nothing to the current output. However you can guarantee it will always crash out of the Java shell, so after all the output has been written to screen, it’ll crash out of the Java shell for you!

Normal NetApp rules, “?” gives us an output of all the available commands. As with normal NetApp rules, I’m sure there’s some hidden gems in here as well (checkout [cref netapp-jsh-more-fun]), but lets cover the basics before going digging too much!

We have the nice easy ability to browse around the filer, obviously this will only work properly with NFS and CIFS shares. The full path is also of course /vol/vol_name. This is tremendously powerful, I know we’ve got “ls” inside “priv set advanced”, but the Java shell adds the “-l” option so we can get the full long format, including file sizes and file permissions (UNIX style naturally).

jsh> cd /etc
jsh> cd log
jsh> pwd
jsh> ls -l
drwx——   42     0      12288 Jan 25 2009 01:11:20 autosupport
-rwx——    1     0     653909 Jan 25 2009 00:00:00 ems.0
-rwx——    1     0    2709697 Dec 21 2008 00:00:00 messages.5

Naturally I’ve snipped the above output, but you get the idea. This is very powerful for storage and sys admins.

cat” has parity with “rdfile“, so no extra options or functionality there. There is no piping of commands, or grep, or anything, so no extras here.

rm” gives us the ability to delete files. Unfortunately no wildcards allowed here, but you can chain multiple files to delete them all in one go. We unfortunately also don’t have the ability to remove directories, or at least not delete things recursively. I was trying to delete some profiles the other day with this, and it is just one file at a time. Still, better than nothing!

cp“, “mv“, really exactly what they say on the tin. Copy of Move files around. Again, nothing fancy, no fancy cloning or block level stuff, this is just a Java shell, so will copy files exactly as you’d expect an operating system to do so!

Now we get onto some cool stuff!

ps“, I’ve needed this so many times. Customer says the system has crashed or things run a bit slowly, but how the hell do you tell what the system is actually doing? A proper *nix style process display. The output is separated to Pri, Group, Name. I can only guess at these for the thread ID (as in what domain it runs under, kahuna and so on), the Group it is running under (I think only system or main), and then the actually process name. I don’t believe there’s any way of showing how long these have been running, or if they are using any processing intensely, but it does show us what’s going on.

Naturally there’s little advantage of having “ps” without having “kill“. Kill works as expected, “kill -1” and “kill -9” to terminate threads. Use the threadname here instead of a process ID. I’ve not played too much with this, as my poor little 250 doesn’t actually run much!

jsh> ps -l
Pri     Group   Name
10      system  Reference Handler
8       system  Finalizer
5       main    Callback Handler
5       main    ndmpmetafilefactory
5       main    Servlet Engine
5       main    InetSntp_Local_1315
5       main    InetSntp_123
5       main    TimeDaemon
5       main    jaf
5       main    jsh
jsh> kill -9 jsh

Well what did you expect would happen when you kill the java shell process?

gc” is the Java Garbage Collector. I’m no Java expert, so this is from reading about the Java shell. It’ll attempt to free up memory space and show the memory usage.

classpath“, “syspath“, these both output the system set paths for Java. You should be able to append to this if needed. When I get some time, I want to see if there is the possibility to include external java classes onto the filer. Simply drop in some new classes! Maybe I’m dreaming a little bit too much there ;)

Debug“, on or off, This is case sensetive, and I guess would give some good information if I wanted to debug the Java shell. Not yet I don’t.

threads“, this takes the “ps” running processes and gives us a lot more information on what is actually running. I can’t immediately see too much of use with this output. A quick snip output.

monitors“, “heap“, I’m honestly not sure of. Either I don’t know Java well enough, or this info is much more debugging level stuff. I think that heap shows the existing or available system handles and their relevant size, but that’s a wild stab to be honest. There’s a lot of info anyway!

version“, exactly what you’d expect from this command. Interestingly the version number is defined as a Release Candidate!

syncdb“, again I’m afraid I’m not sure. I would expect this to update some sort of database that the shell holds, perhaps for the heap stacks?

du“, including extensions “-s” or “-k”. This gives us disk usage. Be careful however, this command goes away and adds up all the contents, so it can take awhile, and remember you can’t ^C once you have started! Keep this simple and point at a specific (and preferably small) directory or set of files. Again, no wildcards allowed (which is a real shame for this command).

java_class“, this is where it could potentially get very very cool. This would give the theory that we can call external classes, ones that may exist within the “classpath” somewhere. I have no idea of the possibilities, or even how to start checking. Something for next time!

And finally you can use the Java shell to execute any normal NetApp command.

So that is a quick crash course in what is available within the Java shell. Out of the box there are a few useful tools, but the real potential is what we could do with this.

Remember, totally unsupported, probably very dangerous, but lots of fun trying!

Undocumented Commands , , , , , , , , , , ,

  1. Kai
    | #1

    nice article

  2. kait
    | #2

    Hi, can somebody help with rm command from jsh. How to delete corrupted file with spaces for example “aaa bbb ccc.ddd”? Over NFS it is impossible, I have to use java shell command rm, but ” or “” doesn’t work. Thanks.

  1. No trackbacks yet.

This site is not affiliated or sponsored in anyway by NetApp or any other company mentioned within.
%d bloggers like this: