Solaris
cgrep — a grep enhancement to show preceding lines
0Solaris grep has no way to printing the lines surrounding a match. Yet my most common use of grep is to locate particular strings in a log file, with the goal of looking at the log messages previous to them. There is a simple solution for this. And also, please note, I did not write any of the code linked here. Just posting it to help others find it.
Install sudo on Solaris 10 (intel, x86)
0Instructions on installing and configuring sudo on Solaris 10. It is really easy.
(more…)
Solaris troubleshooting
1Some quick notes that I will expand at some point. This is based on data requests Oracle Supported requested while troubleshooting a boot issue on a Sun V440.
(more…)
System uptime in Python
0Here is a short recipe to get system uptime in Python. Tested so far on Ubuntu linux and Solaris. Obviously won't work on Windows.
gist on Github for sys_uptime.py
import subprocess
def uptime():
raw = subprocess.check_output('uptime').replace(',','')
days = int(raw.split()[2])
if 'min' in raw:
hours = 0
minutes = int(raw[4])
else:
hours, minutes = map(int,raw.split()[4].split(':'))
totalsecs = days*24*60*60 + hours*60*60 + minutes*60
return totalsecs
print 'System uptime of %d seconds' % (uptime())
How to Configure <span class="caps">NTP</span> in Solaris 10
0This is a simple working configuration method posted in the comments of this page. The page is offline but I found it in Google Cache and verified that it works. Reposting it here for posterity.
Fixing sendmail error "[<span class="caps">ID</span> 702911 mail.crit] My unqualified host name unknown; sleeping for retry"
0This problem annoys the heck out of me, and apparently thousands of other Solaris admins. I can't imagine the reason someone thought sendmail should log this error every few minutes about the stupid hostname, but must have been a good one because the app sure is adamant about it.
How to Download Oracle 11gR2 from command line
Oracle doesn't give direct downloads to the Oracle software. You generally forced to go through a few web pages to login to your Oracle account, then accept a license agreement, then finally get the files. With remote servers you would be forced to download the file locally then push it to the server. Oracle 11 is upwards of 1 GB, so this isn't feasible. Better yet is to download directly to your server. That said, it is really quite simple — just use wget with authentication credentials.
On turning excellence in Python into epic mediocrity in <span class="caps">SQL</span>. Very successful mediocre <span class="caps">SQL</span>.
Today is a brute-force day. I needed to collect second-by-second data from a database over a 4-hour period. There were 2 queries that needed to be run, each just generating a single number for each second (counting events/sec). If I knew anything about SQL these could probably be done in exactly 2 queries. I don't know any useful SQL so I ran individual SQL queries for every single second. That's 28,800 total queries.
I didn't hand-write them, of course. I first wrote a python script to generate the queries and craft a simple SQL script. After generating my two SQL scripts (each 3 MB) and running them, I had 2 data files each containing 14,400 data points. Then I used my text editor, EditPadPro, to trim the whitespace and condense to a single column of numbers. Then I pasted into Excel.
Then I made a line chart from the two number sets which almost brought Excel to its knees, but it worked! It was cool but there was no way to zoom in on the smaller more interesting sections, plus the thing took several seconds to redraw after any scrolling. I ended up creating separate charts for each hour so the graphs render much faster. Now I am calculating some interesting max, mean, and mode numbers to reduce it all to useful summary numbers.
The last few hours were therefore a major triumph of brute force effort: writing a program to generate two other programs (the SQL queries) to generate the 28,800 data points. All because I only know very basic SQL queries.
It was a blast!
BONUS — my generator program understands natural language, so when I ran it I did 'elog_count.py today 01:00:00 to today 05:00:00 by second for "InformPeriodic" '. Then once again for 'InformValueChanged' for the other query.