One really cool feature about net-snmp is that it can monitor processes on a system. If snmpd notices that a process is no longer running, you can specify a script to be executed which can correct the problem. Lets take a look at some examples found here
At least one web server process must be running at all times:
proc httpd procfix httpd /etc/rc.d/init.d/httpd restart
There should never be more than 10 mail processes running:
proc sendmail 10 procfix sendmail /etc/rc.d/init.d/sendmail stop
There should be a single network management agent running (“There can be only one”):
proc snmpd 1 1
This can be an interesting use of Puppet, Chef, or CFengine, which are configuration management engines. Depending upon the type of host (webserver, mail server, etc.) you could set up and establish different types of snmpd.conf files for that environment. Granted, things like Solaris’ 10 SMF can automatically restart services, but this is a cool feature built into net-snmpd if you weren’t already aware that it was there! Secton 8 of the net-snmp README.Solaris file also has some other examples if you’re interested.
One other really cool feature about net-snmp is the ability to remotely execute Perl scripts by simply hitting a MIB. One example could be something like a “clean up disk space” script. Here’s an outtake from the README.Solaris file showing an example of the Perl script execution in action:
Net-SNMP may be compiled with Perl support by configuring like:
./configure -enable-embedded-perl …
Once you have compiled and installed net-snmp you can test the Perl capabilities of the final installation by doing the following:
Copy the perl_module.pl script found at
http://www.net-snmp.org/tutorial-5/toolkit/perl/index.html
to /usr/local/net-snmp and modify your /usr/local/share/snmp/snmpd.conf file to contain the entry:
perl do “/usr/local/net-snmp/perl_module.pl”;
then do:
/usr/local/bin/snmpwalk -v 2c -c whatever localhost .1.3.6.1.4.1.8072.999
It should return the following:
NET-SNMP-MIB::netSnmp.999.1.2.1 = STRING: “hello world”
If you are like me, you like to keep up with the latest Solaris happenings. For the latest putbacks into opensolaris, you can check out the genunix putback page:
To keep up with new ARC case submissions, you can keep an eye on the PSARC page:
If you would prefer to get e-mail notifications for putbacks and new PSARC cases, you can sign up on the opensolaris mailing list page.
I periodically need to look for a given string in one or more compressed log files. Taking the time (and resources) to decompress each file on the file system takes time, especially when I don’t plan to leave the file uncompressed. When these situations arise, I turn to my good friends gzcat and zgrep.
The zgrep utility allows you to look for a pattern in one or more compressed files. If you want to find the string “target port down” in a set of logs named sanlogs*.gz, you can do the following:
$ zgrep "target port down" sanlogs.gz
If zgrep finds the string, it will print it. Alternatively, you can use the gzcat utility to decompress the contents of a file prior to sending it to another tool for processing:
$ gzcat services.gz | tail -2
# 48557-49150 Unassigned
# 49151 IANA Reserved
Both tools are incredibly useful, and should be in every SysAdmins tool bag.
Brian Leonard wrote an excellent blog postabout how to use DTrace, how to show details about specific probes, and then using the source code in conjunction with his findings to understand exactly what was happening within that probe. if you’re starting to deep dive into DTrace, this is an excellent article for learning these crucial steps!
Ever want to immediatly serve content from a specific directory over HTTP, but didn’t want to bother messing with httpd.conf or other webserver configiurations?
If you’ve got Python installed, this is a snap. Execute python with the SimpleHTTPServer module, using port 8080 so there isn’t a need to elevate privs to root.
$ python -m SimpleHTTPServer 8080
Serving HTTP on 0.0.0.0 port 8080 ...
Sure enough, pointing a browser to the IP address :8080 of the box hits my home directory listing. Super easy, super fast, super simple!
I use this to serve content to my PS3. The PS3 doesn’t support NFS or CIFS, so to download content to the hard drive, the best method is by pulling it over HTTP with the embedded web brower. On my MacBook, I change into the directory containing whatever media I want to transfer, fire up HTTP, and suck it down to the hard drive on the PS3. Nice!