snmp
Archived posts from this Category
Archived posts from this Category
Posted by admin on 21 Oct 2008 | Tagged as: Databases, IT Stuff, Photography, Renewable Energy, Solaris, snmp
Postgres triggers are created in 2 stages, firstly you create the trigger function then you link the function to the trigger event. In this sample code a function that fires during before an INSERT event updates a column in the table where the data is being inserted. The function uses an internal (SQL92 compliant) string manipulation function to create the additional data that is required to complete the insert. The column has been defined as char (8), the data being manipulated is a postgres date type and must be cast to a text type. Note also that text types are indexed starting at a base of 1 (not 0 as with ‘C’ character arrays).
CREATE OR REPLACE FUNCTION set_initial_pass() RETURNS trigger AS $set_initial_pass$
DECLARE
yyyy char(4);
mm char(2);
dd char(2);
BEGIN
yyyy := substring(cast(NEW.dob as text) from 1 for 4);
mm := substring(cast(NEW.dob as text) from 6 for 2);
dd := substring(cast(NEW.dob as text) from 9 for 2);
NEW.initial_code := dd||mm||yyyy;
RETURN NEW;
END;
$set_initial_pass$
LANGUAGE 'plpgsql' VOLATILE COST 100;
ALTER FUNCTION set_initial_pass() OWNER TO script;
Now create the trigger and attach the function above.
CREATE TRIGGER set_initial_pass
BEFORE INSERT
ON person
FOR EACH ROW
EXECUTE PROCEDURE set_initial_pass();
This example was created using pgadmin III.
Posted by admin on 08 May 2008 | Tagged as: IT Stuff, snmp
snmp - the Simple Network Management Protocol is anything but as I discovered while trying to monitor status on remote devices. The story so far …
Some background on snmpwalk
snmpwalk is a very useful tool to explore what snmp information is available from an snmp enabled device. To use snmpwalk, on a commandline enter:
snmpwalk -Os -v [1|2c|3] -c community host [ OID ]-Os means print only last symbolic element of OID
-v is the snmp version identifier
-c is the snmp community
host is the ipaddress of the snmp agent you want to query
OID is an optional item which identifies a specific branch of the mib for the device. If given only the values under that branch will be printed.
You can use snmpwalk --help to get a full list of options for snmpwalk.
By default an snmp agent listens on UDP port 161 and traps are handled through UDP port 162. If the agent you want to query is not listening on UDP port 161 then you may need to specifiy the agent ip-address and port in the format host:port-number.
Turning snmp on in a Cisco ASA
#
# allow host #.#.#.# to poll through the ASA's outside interface for snmp
# community "public" using snmp version 2. Refers to the contents of the
# standard MIB-II which is sometimes referred to as RFC1213-MIB
snmp-server host outside #.#.#.# poll community public version 2c
#
# as far as I can see this is informational
snmp-server location MyServerRoom
#
# sets the text for mib object sysContact
snmp-server contact Me
#
# set the snmp community
snmp-server community public
#
# enables the specified snmp traps
snmp-server enable traps snmp authentication linkup linkdown coldstart