Tuesday, July 8, 2014

Some useful Commands in Solaris 10

if you ever needed to create an empty file with certain size, then all you have to do is to use this command:

dd if=/dev/zero of=FILE_NAME bs=BLOCK_SIZE count=NUMBER_OF_BLOCKS

where FILE_NAME is the name of target file and NUMBER_OF_BLOCKS is number of blocks per file, the size of the file is going to be created based on this formula:

File size = NUMBER_OF_BLOCKS x BLOCK_SIZE

as an example:

dd if=/dev/zero of=test_for_download bs=1024 count=1048576


------------------------------------------------------------------------------------------------------------

if you ever need to create shortcut for a certain directory in Solaris, use ln command:

ln -s dir_to_link_to link_name

Wednesday, July 2, 2014

Enable Disk Monitor in CentOS 5.10

To enable disk monitoring in PRTG, first make sure that all disks/partitions are being included in the /etc/snmp/snmpd.conf using this format:

disk  PATH  [MIN=DEFDISKMINIMUMSPACE]

where PATH:  mount path to the disk in question.
and  MIN:  Disks with space below this value will have the Mib's errorFlag set

example:   

disk / 10000

after finishing restart snmp service using this command

service snmpd restart

to verify the configurations try snmpwalk:

snmpwalk -v 2c localhost -c <community string> .1.3.6.1.4.1.2021.9

Saturday, June 28, 2014

Disable " Setting hwclock time to system time, and broadcasting time" messages

in Extreme switches, a message "Setting hwclock time to system time, and broadcasting time" keeps appearing in log file, sometimes this message is annoying because it occupies space and it adds no new information to the switch.

to disable this switch execute the following command:

configure log filter "DefaultFilter" add exclude events "DM.Notice" match string hwclock

Monday, June 23, 2014

svc:/application/x11/xvnc-inetd:default is missing, inconsistent or invalid

I was facing some errors each time i was rebooting Solaris 10 box, the errors goes like this:

Jun 23 14:08:40 inetd[314]: Property 'name' of instance svc:/application/x11/xvnc-inetd:default is missing, inconsistent or invalid
Jun 23 14:08:40 inetd[314]: Property 'proto' of instance svc:/application/x11/xvnc-inetd:default is missing, inconsistent or invalid
Jun 23 14:08:40 inetd[314]: Invalid configuration for instance svc:/application/x11/xvnc-inetd:default, placing in maintenance

viewing the services using svcs command showed that the service svc:/application/x11/xvnc-inetd:default is in maintenance mode, by checking the file: /etc/services i could see that the service vnc-server is missing in the file, so just by adding the missing servic:

vnc-server      5900/tcp                        # Xvnc

and rebooting the box the error messages were gone.


Method "/lib/svc/method/fs-local" failed with exit status 95

this is quote from :

http://www.prasannatech.net/2010/08/solaris-filesystem-mount-error.html

" Yesterday I was working with my Solaris system, after reboot, I couldn't ssh into the system, the ssh command failed with the "Connection refused" error, after some research (by logging into the serial console of the server and rebooting the system again through the serial console), I found the below system error message.

svc:/system/filesystem/local:default: Method "/lib/svc/method/fs-local" failed with exit status 95

Then everything came to standstill till I figured out the solution.

Solution:

1. The possible reason for ssh "Connection Refused" may be due to the fact that some filesystem, whose entry is in /etc/vfstab would have failed to mount properly.

A typical vfstab entry looks like the below one.

$ cat /etc/vfstab
#device         device          mount           FS      fsck    mount   mount
#to mount       to fsck         point           type    pass    at boot options
#
fd      -       /dev/fd fd      -       no      -
/proc   -       /proc   proc    -       no      -
/dev/dsk/c0t2d0s1       -       -       swap    -       no      -
/dev/dsk/c0t2d0s0       /dev/rdsk/c0t2d0s0      /       ufs     1       no      logging
...
...

2. To find which entry was causing the problem, I checked the system log, the entries were as follows.

$ cat /var/svc/log/system-filesystem-local:default.log
"/var/svc/log/system-filesystem-local:default.log" 149 lines, 9256 characters
[ Dec  3 01:25:35 Rereading configuration. ]
[ Dec  3 01:25:52 Executing start method ("/lib/svc/method/fs-local") ]
[ Dec  3 01:25:52 Method "start" exited with status 0 ]
[ Dec  3 01:31:54 Executing start method ("/lib/svc/method/fs-local") ]
....
....
WARNING: /sbin/mountall -l failed: exit status 33
[ Aug 27 07:33:14 Method "start" exited with status 95 ]
[ Aug 27 07:35:37 Leaving maintenance because clear requested. ]
[ Aug 27 07:35:37 Enabled. ]
[ Aug 27 07:35:37 Executing start method ("/lib/svc/method/fs-local") ]
mount: /var/js/1/boot: No such file or directory
WARNING: /sbin/mountall -l failed: exit status 1
[ Aug 27 07:35:37 Method "start" exited with status 95 ]
[ Aug 27 07:37:19 Leaving maintenance because clear requested. ]
[ Aug 27 07:37:19 Enabled. ]
[ Aug 27 07:37:19 Executing start method ("/lib/svc/method/fs-local") ]
mount: /var/js/1/boot: No such file or directory
WARNING: /sbin/mountall -l failed: exit status 33
[ Aug 27 07:37:19 Method "start" exited with status 95 ]
svc:/system/filesystem/local:default: Method "/lib/svc/method/fs-local" failed with exit status 95

Looks like there was an entry /var/js/1/boot in /etc/vfstab which didn't mount because the filesystem was not present, hence the error.

3. After finding the root cause for the problem, I removed the line which mounted the /var/js/1/boot filesystem in /etc/vfstab and rebooted the system, now I could login through ssh.

Therefore when you get ssh "Connection refused" error, chances are that some filesystem whose entry is in /etc/vfstab would have failed to mount, in which case check the system log, remove the line causing the problem from /etc/vfstab and ssh should work fine. "

Thursday, June 19, 2014

run grep command over a number of files in Unix

if you ever need to run grep  command over multiple files then use this style:

find / -xdev -type f -print0 | xargs -0 grep -H "text_to_search_for"

What this actually does is make a list of every file on the system, and then for each file, execute grepwith the given arguments and the name of each file.

The -xdev argument tells find that it must ignore other filesystems - this is good for avoiding special filesystems such as /proc. However it will also ignore normal filesystems too - so if, for example, your /home folder is on a different partition, it won't be searched - you would need to say find / /home -xdev ....
-type f means search for files only, so directories, devices and other special files are ignored (it will still recurse into directories and execute grep on the files within - it just won't execute grep on the directory itself, which wouldn't work anyway). And the -H option to grep tells it to always print the filename in its output.
find accepts all sorts of options to filter the list of files. For example, -name '*.txt' processes only files ending in .txt. -size -2M means files that are smaller than 2 megabytes. -mtime -5 means files modified in the last five days. Join these together with -a for and and -o for or, and use '('parentheses ')' to group expressions (in quotes to prevent the shell from interpreting them). So for example:

find / -xdev '(' -type f -a -name '*.txt' -a -size -2M -a -mtime -5 ')' -print0 | xargs -0 grep -H "text_to_search_for"

Wednesday, June 18, 2014

Solaris Fault Management

Solaris Fault Management

The Solaris Fault Management Facility is designed to be integrated into the Service Management Facility to provide a self-healing capability to Solaris 10 systems.
The fmd daemon is responsible for monitoring several aspects of system health.
The fmadm config command shows the current configuration for fmd.
The Fault Manager logs can be viewed with fmdump -v and fmdump -e -v.
fmadm faulty will list any devices flagged as faulty.
fmstat shows statistics gathered by fmd.

Fault Management

With Solaris 10, Sun has implemented a daemon, fmd, to track and react to fault management. In addition to sending traditional syslog messages, the system sends binary telemetry events to fmd for correlation and analysis. Solaris 10 implements default fault management operations for several pieces of hardware in Sparc systems, including CPU, memory, and I/O bus events. Similar capabilities are being implemented for x64 systems.
Once the problem is defined, failing components may be offlined automatically without a system crash, or other corrective action may be taken by fmd. If a service dies as a result of the fault, the Service Management Facility (SMF) will attempt to restart it and any dependent processes.
The Fault Management Facility reports error messages in a well-defined and explicit format. Each error code is uniquely specified by a Universal Unique Identifier (UUID) related to a document on the Sun web site athttp://www.sun.com/msg/ .
Resources are uniquely identified by a Fault Managed Resource Identifier (FMRI). Each Field Replaceable Unit (FRU) has its own FMRI. FMRIs are associated with one of the following conditions:
  • ok: Present and available for use.
  • unknown: Not present or not usable, perhaps because it has been offlined or unconfigured.
  • degraded: Present and usable, but one or more problems have been identified.
  • faulted: Present but not usable; unrecoverable problems have been diagnosed and the resource has been disabled to prevent damage to the system.
The fmdump -V -u eventid command can be used to pull information on the type and location of the event. (The eventid is included in the text of the error message provided to syslog.) The -e option can be used to pull error log information rather than fault log information.
Statistical information on the performance of fmd can be viewed via the fmstatcommand. In particular, fmstat -m modulename provides information for a given module.
The fmadm command provides administrative support for the Fault Management Facility. It allows us to load and upload modules and view and update the resource cache. The most useful capabilities of fmadm are provided through the following subcommands:
  • config: Display the configuration of component modules.
  • faulty: Display faulted resources. With the -a option, list cached resource information. With the -i option, list persistent cache identifier information, instead of most recent state and UUID.
  • load /path/module: Load the module.
  • unload module: Unload module; the module name is the same as reported by fmadm config.
  • rotate logfile: Schedule rotation for the specified log file. Used with the logadm configuration file.