Sponsored Content
Top Forums Shell Programming and Scripting changing month in Mmm format to mm FORMAT Post 302232159 by agn on Thursday 4th of September 2008 02:20:25 AM
Old 09-04-2008
Something like this could work:
Code:
awk -v mon=$mon 'BEGIN { months="janfebmaraprmayjunjulaugsepoctnovdec";}  END { print int(index(months, tolower(mon))/3) + 1 }'

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to print current month - 1 in string format

I need to get the current month -1 in string format, like Feb-2006. I am using k shell. Any help is appreciated. (3 Replies)
Discussion started by: mogli4
3 Replies

2. Shell Programming and Scripting

ddmmyyyy to dd-mmm-yy format?

Hi All, Can anyone tell me a simple way of converting a date in ddmmyyyy format to dd-mmm-yy format. For example 17022006 to 17-FEB-06 Thanks in advance Regards, Gaurav (11 Replies)
Discussion started by: gauravgoel
11 Replies

3. UNIX for Dummies Questions & Answers

Getting month and changing format

Hello, I would like to get todays moth and write it in this format: _06_ Any ideas? (7 Replies)
Discussion started by: marringi
7 Replies

4. UNIX for Dummies Questions & Answers

Changing from Excel date format to MySQL date format

I have a list of dates in the following format: mm/dd/yyyy and want to change these to the MySQL standard format: yyyy-mm-dd. The dates in the original file may or may not be zero padded, so April is sometimes "04" and other times simply "4". This is what I use to change the format: sed -i '' -e... (2 Replies)
Discussion started by: figaro
2 Replies

5. Shell Programming and Scripting

script for month conversion in numeric format

Hi Experts, How to convert months into numeric format with the help of some script: Suppose I want: " Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sept | Oct | Nov | Dec " to be converted as : " 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 " Thanks in... (2 Replies)
Discussion started by: rveri
2 Replies

6. UNIX for Dummies Questions & Answers

how to fetch month format files in a file

I have files like pra.01 sra.02 see.03 swc.03 sre.04 after dot it contain month format when ever user type "01" month i have to fetch what are 01 files to come (2 Replies)
Discussion started by: sgoud
2 Replies

7. Shell Programming and Scripting

perl one-liner to get yesterday's date in format dd-MMM-yy (i.e. 01-JAN-12)

I have the following perl one-liner to get yesterday's date, but I would like it in the form of dd-MMM-yy (for example: 01-JAN-12). Can someone alter the below code so I get the format I want? Also, could someone also give me a line for dd-Mmm-yy (for example 01-Jan-12)? Code: YEST=`perl -w... (3 Replies)
Discussion started by: thibodc
3 Replies

8. Shell Programming and Scripting

How to convert date format such as 7/18/2015 to the number of month

How to convert date format such as 7/18/2015 to the number of month from requesting date 'date' in sh scripting ? Let say I have output in my log.txt -> 7/18/2015. How I convert it to the full number of month starting from 'date' till 7/18/2015 in shell scripting ? Thanks in advance. (1 Reply)
Discussion started by: amerabest
1 Replies

9. Shell Programming and Scripting

How to get last 12 month date in YYYY.MM format?

I need the date format in YYYY.MM format and I am able to get current month date as well as previous month date with below command PM=`date +'%Y.%m' -d 'last month'` CM=`date +'%Y.%m' -d 'now'` but I need to get YYYY.MM date format for previous 12 months so could you please help me how I get... (2 Replies)
Discussion started by: Amit Joshi
2 Replies

10. UNIX for Advanced & Expert Users

How to convert mmm-yy to mm/dd/yyyy format in UNIX ?

How to convert mmm-yy to mm/dd/yyyy format in unix ? example: Jan-99 to 01/01/1999 Jan-00 to 01/01/2000 Jan-25 to 01/01/2025 Dec-99 to 01/12/1999 Dec-00 to 01/12/2000 Dec-25 to 01/12/2025 YY anything between 00-50 should be 2000-2050 YY anything between 51-99 should be 1951-1999 ... (2 Replies)
Discussion started by: gksenthilkumar
2 Replies
Mon::Client(3pm)					User Contributed Perl Documentation					  Mon::Client(3pm)

NAME
Mon::Client - Methods for interaction with Mon client SYNOPSIS
use Mon::Client; DESCRIPTION
Mon::Client is used to interact with "mon" clients. It supports a protocol-independent API for retrieving the status of the mon server, and performing certain operations, such as disableing hosts and service checks. METHODS
new Creates a new object. A hash can be supplied which sets the default values. An example which contains all of the variables that you can initialize: $c = new Mon::Client ( host => "monhost", port => 2583, username => "foo", password => "bar", ); password (pw) If pw is provided, sets the password. Otherwise, returns the currently set password. host (host) If host is provided, sets the mon host. Otherwise, returns the currently set mon host. port (portnum) If portnum is provided, sets the mon port number. Otherwise, returns the currently set port number. username (user) If user is provided, sets the user login. Otherwise, returns the currently set user login. prot If protocol is provided, sets the protocol, specified by a string which is of the form "1.2.3", where "1" is the major revision, "2" is the minor revision, and "3" is the sub-minor revision. If protocol is not provided, the currently set protocol is returned. protid ([protocol]) Returns true if client and server protocol match, false otherwise. Implicitly called by connect. If protocol is specified as an integer, supplies that protocol version to the server for verification. version Returns the protocol version of the remote server. error Returns the error string from set by the last method, or undef if there was no error. connected Returns 0 (not connected) or 1 (connected). connect (%args) Connects to the server. If host and port have not been set, uses the defaults. Returns undef on error. If $args{"skip_protid"} is true, skip protocol identification upon connect. disconnect Disconnects from the server. Return undef on error. login ( %hash ) %hash is optional, but if specified, should contain two keys, username and password. Performs the "login" command to authenticate the user to the server. Uses username and password if specified, otherwise uses the username and password previously set by those methods, respectively. checkauth ( command ) Checks to see if the specified command, as executed by the current user, is authorized by the server, without actually executing the command. Returns 1 (command is authorized) or 0 (command is not authorized). disable_watch ( watch ) Disables watch. disable_service ( watch, service ) Disables a service, as specified by watch and service. disable_host ( host ) Disables host. enable_watch ( watch ) Enables watch. enable_service ( watch, service ) Enables a service as specified by watch and service. enable_host ( host ) Enables host. set ( group, service, var, val ) Sets var in group,service to val. Returns undef on error. get ( group, service, var ) Gets variable var in group,service and returns it, or undef on error. quit Logs out of the server. This method should be followed by a call to the disconnect method. list_descriptions Returns a hash of service descriptions, indexed by watch and service. For example: %desc = $mon->list_descriptions; print "$desc{'watchname'}->{'servicename'} "; list_deps Lists dependency expressions and their components for all services. If there is no dependency for a particular service, then the value will be "NONE". %deps = $mon->list_deps; foreach $watch (keys %deps) { foreach $service (keys %{$deps{$watch}}) { my $sref = \%{$deps{$watch}->{$service}}; print "expr ($watch,$service) = $sref->{expression} "; print "components ($watch,$service) = @{$sref->{components}} "; } } list_group ( hostgroup ) Lists members of hostgroup. Returns an array of each member. list_watch Returns an array of all the defined watch groups and services. foreach $w ($mon->list_watch) { print "group=$w->[0] service=$w->[1] "; } list_opstatus ( [group1, service1], ... ) Returns a hash of per-service operational statuses, as indexed by watch and service. The list of anonymous arrays is optional, and if is not provided then the status of all groups and services will be queried. %s = $mon->list_opstatus; foreach $watch (keys %s) { foreach $service (keys %{$s{$watch}}) { foreach $var (keys %{$s{$watch}{$service}}) { print "$watch $service $var=$s{$watch}{$service}{$var} "; } } } list_failures Returns a hash in the same manner as list_opstatus, but only the services which are in a failure state. list_successes Returns a hash in the same manner as list_opstatus, but only the services which are in a success state. list_disabled Returns a hash of disabled watches, services, and hosts. %d = $mon->list_disabled; foreach $group (keys %{$d{"hosts"}}) { foreach $host (keys %{$d{"hosts"}{$group}}) { print "host $group/$host disabled "; } } foreach $watch (keys %{$d{"services"}}) { foreach $service (keys %{$d{"services"}{$watch}}) { print "service $watch/$service disabled "; } } for (keys %{$d{"watches"}}) { print "watch $_ disabled "; } list_alerthist Returns an array of hash references containing the alert history. @a = $mon->list_alerthist; for (@a) { print join (" ", $_->{"type"}, $_->{"watch"}, $_->{"service"}, $_->{"time"}, $_->{"alert"}, $_->{"args"}, $_->{"summary"}, " ", ); } list_dtlog Returns an array of hash references containing the downtime log. @a = $mon->list_dtlog for (@a) { print join (" ", $_->{"timeup"}, $_->{"group"}, $_->{"service"}, $_->{"failtime"}, $_->{"downtime"}, $_->{"interval"}, $_->{"summary"}, " ", ); } list_failurehist Returns an array of hash references containing the failure history. @f = $mon->list_failurehist; for (@f) { print join (" ", $_->{"watch"}, $_->{"service"}, $_->{"time"}, $_->{"summary"}, " ", ); } list_pids Returns an array of hash references containing the list of process IDs of currently active monitors run by the server. @p = $mon->list_pids; $server = shift @p; for (@p) { print join (" ", $_->{"watch"}, $_->{"service"}, $_->{"pid"}, " ", ); } list_state Lists the state of the scheduler. Returns a two-element array. The first element of the array is 0 if the scheduler is stopped, and 1 if the scheduler is currently running. The second element of the array returned is the string "scheduler running" if the scheduler is currently running, and if the scheduler is stopped, the second element is the time(2) that the scheduler was stopped. @s = $mon->list_state; if ($s[0] == 0) { print "scheduler stopped since " . localtime ($s[1]) . " "; } start Starts the scheduler. stop Stops the scheduler. reset Resets the server. reload ( what ) Causes the server to reload its configuration. what is an optional argument, and currently the only supported option is auth, which reloads the authorization file. term Terminates the server. set_maxkeep Sets the maximum number of history entries to store in memory. get_maxkeep Returns the maximum number of history entries to store in memory. test ( test, group, service [, exitval, period]) Schedules a service test to run immediately, or tests an alert for a given period. test must be monitor, alert, startupalert, or upalert. To test alerts, the exitval and period must be supplied. Periods are identified by their label in the mon config file. If there are no period tags, then the actual period string must be used, exactly as it is listed in the config file. test_config Tests the syntax of the configuration file. Returns a two-element array. The first element of the array is 0 if the syntax of the config file is invalid, and 1 if the syntax of the config file is OK. The second element of the array returned is the failure message, if the config file has invalid syntax, and the result code if the config file syntax is OK. This function returns undef if it cannot get a connection or a response from the mon server. Config file checking stops as soon as an error is found, so you will need to run this command more than once if you have multiple errors in your config file in order to find them all. @s = $mon->test_config; if ($s[0] == 0) { print "error in config file: " . $s[1] . " "; } ack ( group, service, text ) When group/service is in a failure state, acknowledges this with text, and disables all further alerts during this failure period. loadstate ( state ) Loads state. savestate ( state ) Saves state. servertime Returns the time on the server using the same output as the time(2) system call. send_trap ( %vars ) Sends a trap to a remote mon server. Here is an example: $mon->send_trap ( group => "remote-group", service => "remote-service", retval => 1, opstatus => "fail", summary => "hosta hostb hostc", detail => "hosta hostb and hostc are unresponsive", ); retval must be a nonnegative integer. opstatus must be one of fail, ok, coldstart, warmstart, linkdown, unknown, timeout, untested. Returns undef on error. perl v5.14.2 2012-04-27 Mon::Client(3pm)
All times are GMT -4. The time now is 11:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy