Dumped on 2019-10-24

Index of database - lanview2


Schema public

standard public schema


Table: public.alarm_messages

Riasztási üzenetek táblája.

public.alarm_messages Structure
F-Key Name Type Description
public.service_types.service_type_id service_type_id bigint PRIMARY KEY

Melyik szervíz típushoz/csoporthoz tartozik a riasztási üzenet.
status notifswitch PRIMARY KEY

Milyen állapothoz tartozik a riasztási üzenet.
text_id bigint NOT NULL DEFAULT nextval('public.text_id_sequ'::regclass)

Index - Schema public


Table: public.alarm_service_vars

public.alarm_service_vars Structure
F-Key Name Type Description
alarm_service_var_id bigserial PRIMARY KEY
public.alarms.alarm_id alarm_id bigint UNIQUE#1 NOT NULL
service_var_id bigint UNIQUE#1 NOT NULL
service_var_value text
var_state notifswitch
state_msg text
raw_value text

Index - Schema public


Table: public.alarms

Riasztási események táblája

public.alarms Structure
F-Key Name Type Description
alarm_id bigserial PRIMARY KEY
public.host_services.host_service_id host_service_id bigint NOT NULL

A riasztást kiváltó szervíz azonosítója
public.host_services.host_service_id daemon_id bigint
first_status notifswitch NOT NULL

A riasztás keletkezésekori állapot
max_status notifswitch NOT NULL

A riasztás ideje alatti legsújosabb állapot.
last_status notifswitch NOT NULL

Az utolsó statusz a riastás vége elött
begin_time timestamp without time zone NOT NULL DEFAULT now()

A riasztás kezdetánek az időpontja
event_note text

A risztást létrehozó üzenete, ha van
public.alarms.alarm_id superior_alarm_id bigint

Ha egy függő szervíz váltotta ki a riasztást, és a felsőbb szintű szolgáltatás is roasztási állpotban van, akkor annak a riasztásnak az azonosítója.
end_time timestamp without time zone

A riasztás végének az időpontja

Tables referencing this one via Foreign Key Constraints:

alarms_begin_time_index begin_time alarms_end_time_index end_time alarms_host_service_id host_service_id

Index - Schema public


Table: public.app_errs

Aplication errors log table Program hiba esetén jön létre (C++ Qt alkalmazás/szerver) egy cError* típusu kizárás generálásakor, ha a program képes a rekordot létrehozni. A rekord a cError objektum alapján kerül kitöltésre.

public.app_errs Structure
F-Key Name Type Description
applog_id bigserial PRIMARY KEY

Unique ID for app_errs
date_of timestamp without time zone NOT NULL DEFAULT now()

Record timestamp
app_name text

Aplication name
node_id bigint

Host azonosító, vagy NULL ha nem ismert,
pid bigint

Aplication process PID number
app_ver text

Aplication version identifier
lib_ver text

liblv2 version identifier
public.users.user_id user_id bigint
public.services.service_id service_id bigint
func_name text

Function full name.
src_name text

Code source name.
src_line integer

Code source line number.
err_code integer

Error code
err_name text

Error symbolic code
err_subcode bigint

Error sub code, or integer parameter
err_syscode integer
err_submsg text
thread_name text

Aplication thread identifier (optional)
sql_err_code text
sql_err_type integer
sql_driver_text text
sql_db_text text
sql_query text
sql_bounds text
data_line integer
data_pos integer
data_msg text
data_name text
acknowledged boolean DEFAULT false
back_stack text

Tables referencing this one via Foreign Key Constraints:

app_errs_date_of_index date_of

Index - Schema public


Table: public.app_memos

public.app_memos Structure
F-Key Name Type Description
app_memo_id bigserial PRIMARY KEY
date_of timestamp without time zone NOT NULL DEFAULT now()
app_name text
pid bigint
thread_name text
app_ver text
lib_ver text
func_name text
src_name text
src_line integer
node_id bigint
public.host_services.host_service_id host_service_id bigint
public.users.user_id user_id bigint
importance notifswitch DEFAULT 'unknown'::public.notifswitch
memo text NOT NULL
acknowledged boolean DEFAULT false
app_memos_date_of_index date_of

Index - Schema public


Table: public.arp_logs

Az arps tábla változásainag a napló táblája.

public.arp_logs Structure
F-Key Name Type Description
arp_log_id bigserial PRIMARY KEY
reason reasons NOT NULL
date_of timestamp without time zone NOT NULL DEFAULT now()
ipaddress inet
hwaddress_new macaddr
hwaddress_old macaddr
set_type_old settype NOT NULL
public.host_services.host_service_id host_service_id_old bigint
first_time_old timestamp without time zone
last_time_old timestamp without time zone
acknowledged boolean DEFAULT false
arp_logs_date_of_index date_of

Index - Schema public


Table: public.arps

Az ARP tábla (vagy DHCP konfig) lekérdezések eredményét tartalmazó tábla. Az adatmanipulációs műveleteket nem közvetlenül, hanem a kezelő függvényeken keresztül kell elvégezni, hogy létrejöjjenek a log rekordok is: replace_arp(), arp_remove() és refresh_arps().

public.arps Structure
F-Key Name Type Description
ipaddress inet PRIMARY KEY

A MAC-hoz detektált ip cím, egyedi kulcs.
hwaddress macaddr NOT NULL

Az ethernet cím, nem egyedi kulcs.
set_type settype NOT NULL
public.host_services.host_service_id host_service_id bigint
first_time timestamp without time zone NOT NULL DEFAULT now()

A rekord létrehozásának az ideje, ill. az első detektálás ideje.
last_time timestamp without time zone NOT NULL DEFAULT now()

Az legutóbbi detektálás ideje.
arp_note text

 

public.arps Constraints
Name Constraint
arps_check_mac CHECK ((NOT ((hwaddress = '00:00:00:00:00:00'::macaddr) OR (hwaddress = 'ff:ff:ff:ff:ff:ff'::macaddr))))
arps_first_time_index first_time arps_hwaddress_index hwaddress arps_last_time_index last_time

Index - Schema public


View: public.db_errors

public.db_errors Structure
F-Key Name Type Description
date_of timestamp without time zone
reapeat bigint
error_name text
error_type errtype
error_note text
user_id bigint
table_name text
trigger_op text
err_subcode bigint
err_msg text
func_name text
SELECT db_errs.date_of
,
    db_errs.reapeat
,
    errors.error_name
,
    errors.error_type
,
    errors.error_note
,
    db_errs.user_id
,
    db_errs.table_name
,
    db_errs.trigger_op
,
    db_errs.err_subcode
,
    db_errs.err_msg
,
    db_errs.func_name
   
FROM (db_errs
     
  JOIN errors 
 USING (error_id)
);

Index - Schema public


Table: public.db_errs

Adatbázis műveletek közben keletkező hiba események táblája. A rekord az erroer(...) függvénnyel hozható létre, függetlenül az aktuális tranzakciótól

public.db_errs Structure
F-Key Name Type Description
dblog_id bigserial PRIMARY KEY
date_of timestamp without time zone NOT NULL DEFAULT now()

Az esemény bekövetkeztének az időpontja
public.errors.error_id error_id bigint NOT NULL

A hiba azonosító
public.users.user_id user_id bigint

A hiba bekövetkezésekor az aktuális kapcsolathoz tartozó felhasználó azonosítója
table_name text

A hib a eseményhez kapcsolódó tábla neve.
trigger_op text

Ha a hiba egy TRIGGER függvényben keletkezett, akko a triggert kiváltó esemény neve.
err_subcode bigint

Másodlagos hiba kód, vagy numerikus hiba paraméter.
err_msg text

Másodlagos hiba üzenet, vagy szöveges hiba paraméter.
func_name text

Az aktuális függvény neve, ahol a hiba történt.
reapeat bigint

Ha kétszer nyugtázatlan azonos rekord keletkezne, akkor csak ez a számláló inkrementálódik.
date_of_last timestamp without time zone NOT NULL DEFAULT now()

Ha reapeat értéke 0, akkor azonos date_of-al, reapeat inkrementálásakor az aktuális idő kerül a mezőbe.
acknowledged boolean DEFAULT false
db_errs_date_of_index date_of db_errs_date_of_last_index date_of_last

Index - Schema public


Table: public.dyn_addr_ranges

public.dyn_addr_ranges Structure
F-Key Name Type Description
dyn_addr_range_id bigserial PRIMARY KEY
dyn_addr_range_note text
exclude boolean UNIQUE#1 UNIQUE#2 DEFAULT false
begin_address inet UNIQUE#1 NOT NULL
end_address inet UNIQUE#2 NOT NULL
public.subnets.subnet_id subnet_id bigint
public.host_services.host_service_id host_service_id bigint
last_time timestamp without time zone DEFAULT now()
flag boolean DEFAULT false

Index - Schema public


Table: public.dyn_ipaddress_logs

public.dyn_ipaddress_logs Structure
F-Key Name Type Description
dyn_ipaddress_log_id bigserial PRIMARY KEY
date_of timestamp without time zone NOT NULL DEFAULT now()
ipaddress_new inet
ipaddress_old inet
set_type settype NOT NULL
public.interfaces.port_id port_id bigint NOT NULL
acknowledged boolean DEFAULT false
dyn_ipaddress_logs_date_of_index date_of

Index - Schema public


Table: public.enum_vals

Enumerációs értékek megjelenítését segítő tábla.

public.enum_vals Structure
F-Key Name Type Description
enum_val_id bigserial PRIMARY KEY
enum_val_name text

Az enumerációs típus egy lehetséges értéke
enum_val_note text

Az enumerációs értékhez tartozó leírás, megjelenítednó szöveg
enum_type_name text NOT NULL

Az enumerációs típusnak a neve
bg_color text
fg_color text
font_family text
font_attr fontattr[]
text_id bigint NOT NULL DEFAULT nextval('public.text_id_sequ'::regclass)
icon text

Index - Schema public


Table: public.errors

Adatbázis műveletek közben keletkező hiba típusok táblája.

public.errors Structure
F-Key Name Type Description
error_id bigserial PRIMARY KEY

Hiba típus ID.
error_name text UNIQUE NOT NULL

Hiba típus név.
error_note text

Hiba típus leírása, hiba üzenet szövege.
error_type errtype NOT NULL

Hiba sújossága.
text_id bigint NOT NULL DEFAULT nextval('public.text_id_sequ'::regclass)

Tables referencing this one via Foreign Key Constraints:

Index - Schema public


Table: public.field_attrs

public.field_attrs Structure
F-Key Name Type Description
field_attr_id bigserial PRIMARY KEY
table_name text UNIQUE#1 NOT NULL
field_name text UNIQUE#1 NOT NULL
attrs fieldattr[] NOT NULL

Index - Schema public


Table: public.fkey_types

The table defining the type of foreign keys (for non property ties)

public.fkey_types Structure
F-Key Name Type Description
fkey_type_id bigserial PRIMARY KEY
table_schema text UNIQUE#1 NOT NULL DEFAULT 'public'::text

The name of the foreign key scheme
table_name text UNIQUE#1 NOT NULL

The name of the foreign key table
column_name text UNIQUE#1 NOT NULL

The name of the foreign key, or enum type name if type is text
unusual_fkeys_type unusualfkeytype NOT NULL DEFAULT 'owner'::public.unusualfkeytype

The remote key type

Index - Schema public


Table: public.graph_vars

public.graph_vars Structure
F-Key Name Type Description
graph_var_id bigserial PRIMARY KEY
graph_var_note text
public.graphs.graph_id graph_id bigint NOT NULL
public.service_vars.service_var_id service_var_id bigint NOT NULL
draw_type drawtype NOT NULL DEFAULT 'LINE'::public.drawtype
sequence_number integer NOT NULL
features text
deleted boolean NOT NULL DEFAULT false

Index - Schema public


Table: public.graphs

public.graphs Structure
F-Key Name Type Description
graph_id bigserial PRIMARY KEY
graph_name text UNIQUE
graph_note text
graph_title text
public.rrd_beats.rrd_beat_id rrd_beat_id bigint NOT NULL
features text
deleted boolean NOT NULL DEFAULT false

Tables referencing this one via Foreign Key Constraints:

Index - Schema public


Table: public.group_users

Group members table

public.group_users Structure
F-Key Name Type Description
group_user_id bigserial PRIMARY KEY
public.groups.group_id group_id bigint UNIQUE#1

Group ID
public.users.user_id user_id bigint UNIQUE#1

User ID

Index - Schema public


Table: public.groups

User groups

public.groups Structure
F-Key Name Type Description
group_id bigserial PRIMARY KEY

Group ID
group_name text UNIQUE NOT NULL

Group name
group_note text
group_rights rights DEFAULT 'viewer'::public.rights

User rights
public.place_groups.place_group_id place_group_id bigint

Zone
features text

Tables referencing this one via Foreign Key Constraints:

Index - Schema public


Table: public.host_service_logs

Host szervízek státusz változásainak a log táblája

public.host_service_logs Structure
F-Key Name Type Description
host_service_log_id bigserial PRIMARY KEY
public.host_services.host_service_id host_service_id bigint
date_of timestamp without time zone NOT NULL DEFAULT now()
old_state notifswitch NOT NULL
old_soft_state notifswitch NOT NULL
old_hard_state notifswitch NOT NULL
new_state notifswitch NOT NULL
new_soft_state notifswitch NOT NULL
new_hard_state notifswitch NOT NULL
event_note text
superior_alarm_id bigint
noalarm boolean NOT NULL
public.alarms.alarm_id alarm_id bigint
alarm_do reasons NOT NULL DEFAULT 'unknown'::public.reasons
host_service_logs_alarm_id alarm_id host_service_logs_date_of_index date_of host_service_logs_superior_alarm_id superior_alarm_id

Index - Schema public


Table: public.host_service_noalarms

public.host_service_noalarms Structure
F-Key Name Type Description
host_service_noalarm_id bigserial PRIMARY KEY
date_of timestamp without time zone DEFAULT now()
public.host_services.host_service_id host_service_id bigint
noalarm_flag noalarmtype NOT NULL
noalarm_from timestamp without time zone
noalarm_to timestamp without time zone
noalarm_flag_old noalarmtype NOT NULL
noalarm_from_old timestamp without time zone
noalarm_to_old timestamp without time zone
public.users.user_id user_id bigint
msg text

Index - Schema public


Table: public.host_services

A szolgáltatás-node összerendelések, ill. a konkrét szolgáltatások vagy ellenörzés utasítások táblája, és azok állpota.

public.host_services Structure
F-Key Name Type Description
host_service_id bigserial PRIMARY KEY

Egyedi azonosító
node_id bigint NOT NULL

A node ill. host azonosítója, amin a szolgáltatás, vagy az ellenörzés fut.
public.services.service_id service_id bigint NOT NULL

A szolgáltatást, vagy az ellenörzés típusát azonosító ID
port_id bigint

Opcionális port azonosító, ha a szolgáltatás ill. ellenörzés egy porthoz rendelt.
host_service_note text

Megjegyzés / leírás.
public.services.service_id prime_service_id bigint NOT NULL DEFAULT '-1'::integer

Az ellenőrzés elsődleges módszerét azonosító, szervíz típus ID
public.services.service_id proto_service_id bigint NOT NULL DEFAULT '-1'::integer

Az ellenőrzés módszerének opcionális további azonosítása (protokol), szervíz típus ID
delegate_host_state boolean NOT NULL DEFAULT false

Értéke igaz, ha a szolgáltatás állapotát örökli a node is.
check_cmd text

Egy opcionális parancs.
features text

További paraméterek. Ld.: services.features . Ha értéke nem NULL, akkor fellülbírálja a service_id -hez tartozó services.features értékét
disabled boolean NOT NULL DEFAULT false
public.host_services.host_service_id superior_host_service_id bigint

Szülő szolgáltatás. Az ellenörzés a szülőn keresztül hajtódik végre, ill. az végzi.
max_check_attempts integer

Hibás eredmények maximális száma, a riasztás kiadása elött.
normal_check_interval interval

Ellenörzések ütemezése másodpercben, ha nincs hiba.
retry_check_interval interval

Ellenörzések ütemezése, hiba esetén a riasztás kiadásáig.
public.timeperiods.timeperiod_id timeperiod_id bigint

Az ellenörzések időtartománya.
flapping_interval interval
flapping_max_change integer
noalarm_flag noalarmtype NOT NULL DEFAULT 'off'::public.noalarmtype

A riasztás tiltásának az állapota
noalarm_from timestamp without time zone

Ha a tiltáshoz kezdő időpont tartozik, akkor a tiltás kezdete.
noalarm_to timestamp without time zone

Ha a tiltáshoz záró időpont tartozik, akkor a tiltás vége.
offline_group_ids bigint[]
online_group_ids bigint[]
host_service_state notifswitch NOT NULL DEFAULT 'unknown'::public.notifswitch

A szolgáltatás állapota, álltalában azonos a hard_state-val, kiegészítve a recovered, és flapping állapottal.
soft_state notifswitch NOT NULL DEFAULT 'unknown'::public.notifswitch

A szolgálltatás utolsó ellenörzés szerinti állapota.
hard_state notifswitch NOT NULL DEFAULT 'unknown'::public.notifswitch

A szolgálltatás elfogadott állapota.
state_msg text

Az aktuális állapothoz tartozó opcionális állapot üzenet
check_attempts integer NOT NULL

Hiba számláló.
last_changed timestamp without time zone

Utolsó állapot változás időpontja.
last_touched timestamp without time zone

Utolsó ellenözzés időpontja
public.alarms.alarm_id act_alarm_log_id bigint

Riasztási állapot esetén az aktuális riasztás log rekord ID-je
public.alarms.alarm_id last_alarm_log_id bigint

Az utolsó riasztás log rekord ID-je
deleted boolean NOT NULL DEFAULT false
last_noalarm_msg text
heartbeat_time interval
flag boolean DEFAULT false

 

public.host_services Constraints
Name Constraint
no_self_superior CHECK ((host_service_id <> superior_host_service_id))

Tables referencing this one via Foreign Key Constraints:

host_services_act_alarm_log_id act_alarm_log_id host_services_last_alarm_log_id last_alarm_log_id host_services_last_touched last_touched host_services_node_id node_id host_services_service_id service_id host_services_superior_index superior_host_service_id

Index - Schema public


Table: public.iftypes

Network Interfaces (ports) típus leíró rekord.

public.iftypes Structure
F-Key Name Type Description
iftype_id bigserial PRIMARY KEY

Unique ID for interface's type
iftype_name text UNIQUE NOT NULL

Interface type's name
iftype_note text

Interface type's noteiption
iftype_iana_id integer NOT NULL DEFAULT 1

Protocoll Types id assigned by IANA
iftype_link_type linktype NOT NULL DEFAULT 'unknown'::public.linktype

A porton értelmezhető link típusa
iftype_obj_type portobjtype NOT NULL DEFAULT 'unknown'::public.portobjtype

A portot reprezentáló API objektum típusa.
preferred boolean DEFAULT false

Ha az iana id alapján keresünk, csak az 'f' érték esetén van találat a rekordra.
iana_id_link integer

Elavult ID esetén a helyette használandü iana ID-t tartalmazza
if_name_prefix text

Egy opcionális prefix az interfész nevekhez

Tables referencing this one via Foreign Key Constraints:

Index - Schema public


Table: public.images

Bináris adatokat, tipikusan képeket tartalmazó tábla

public.images Structure
F-Key Name Type Description
image_id bigserial PRIMARY KEY

A kép ill bináris adathamaz egyedi azonosítója
image_name text UNIQUE NOT NULL

A kép ill bináris adathamaz egyedi neve
image_note text

A kép ill bináris adathamaz opcionális megjegyzés, leírás
image_type imagetype NOT NULL

A kép ill bináris adathamaz típusa, a kezelt kép formátumok, vagy BIN
image_sub_type text

Bináris adathamaz esetén (image_type = BIN) egy opcionális típus azonosító string
image_data bytea NOT NULL

A kép ill bináris adathamaz.
image_hash bytea NOT NULL

A kép ill bináris adathamaz SHA512 HASH. NULL esetén a trigger függvény autómatikusan meggenerálja
usabilityes usability[] NOT NULL DEFAULT '{}'::public.usability[]

Tables referencing this one via Foreign Key Constraints:

Index - Schema public


Table: public.import_templates

Az importban mentett makrók és egyébb minták táblája.

public.import_templates Structure
F-Key Name Type Description
import_template_id bigserial PRIMARY KEY

Egyedi rekord azonosító.
template_name text UNIQUE#1 NOT NULL

A minta vagy makró neve
template_type templatetype UNIQUE#1 NOT NULL

A template típusa (macros, patchs,...)
template_note text

Opcionális megjegyzés
template_text text NOT NULL

A makró vagy minta tartalma.

Index - Schema public


Table: public.imports

Az import számára küldött feldolgozandó források táblája.

public.imports Structure
F-Key Name Type Description
import_id bigserial PRIMARY KEY

Egyedi rekord azonosító.
public.host_services.host_service_id target_id bigint
date_of timestamp without time zone NOT NULL DEFAULT now()

A rekord létrehozásának az időpontja.
public.users.user_id user_id bigint NOT NULL

Felhasználói azonosító, aki a feldolgozást kezdeményezte.
public.nodes.node_id node_id bigint NOT NULL

A munkaállomás azonosítója, ahonnan a feldolgozást kezdeményezték.
app_name text

Az applikáció neve, ahonnan a feldogozást kezdeményezték.
import_text text NOT NULL

A feldolgozandó szöveg.
exec_state execstate NOT NULL DEFAULT 'wait'::public.execstate

A feldolgozás állapota.
pid bigint

A feldolgozást végző import példány PID-je.
started timestamp without time zone

A feldolgozás megkezdésének az időpontja.
ended timestamp without time zone

A feldolgozás befejezésének az időpontja.
result_msg text

Az import válasza a feldolgozásra (hibaüzenet, megjegyzés, stb.).
public.app_errs.applog_id applog_id bigint

Ha feldolgozáskor hiba rekord készült, akkor annak az azonosítója.
out_msg text
exp_msg text

Index - Schema public


Table: public.interfaces

Network Interfaces Table

public.interfaces Structure
F-Key Name Type Description
port_id bigint PRIMARY KEY DEFAULT nextval('public.nports_port_id_seq'::regclass)
port_name text UNIQUE#1 NOT NULL
port_note text
port_tag text
public.iftypes.iftype_id iftype_id bigint
node_id bigint UNIQUE#1 NOT NULL
port_index integer

SNMP port id, vagy port index, SNMP eszköz esetén az eszközön bellül egyedinek kell lennie.
deleted boolean DEFAULT false
flag boolean DEFAULT false
hwaddress macaddr
port_ostat ifstatus NOT NULL DEFAULT 'unknown'::public.ifstatus
port_astat ifstatus NOT NULL DEFAULT 'unknown'::public.ifstatus
public.interfaces.port_id port_staple_id bigint

Trönkölt vagy bridzselt port esetén a trönk ill. a bridzs port ID-je
public.iftypes.iftype_id dualface_type bigint

Dualface port esetén a másik típus azonosító.
ifdescr text
last_changed timestamp without time zone
port_stat notifswitch NOT NULL DEFAULT 'unknown'::public.notifswitch
last_touched timestamp without time zone

Table public.interfaces Inherits nports,

 

public.interfaces Constraints
Name Constraint
interfaces_check_mac CHECK ((NOT ((hwaddress = '00:00:00:00:00:00'::macaddr) OR (hwaddress = 'ff:ff:ff:ff:ff:ff'::macaddr))))

Tables referencing this one via Foreign Key Constraints:

interfaces_node_id_index node_id

Index - Schema public


View: public.ip_address_cols

public.ip_address_cols Structure
F-Key Name Type Description
address inet
ip_address_type addresstype
port_id2full_name text
SELECT ipa.address
,
    ipa.ip_address_type
,
    port_id2full_name
(ipa.port_id) AS port_id2full_name
   
FROM ip_addresses ipa
  
WHERE (
     (ipa.address IS NOT NULL)
   AND (1 <> 
           (
            SELECT count
                 (*) AS count
           
              FROM ip_addresses ict
          
             WHERE (ict.address = ipa.address)
           )
     )
);

Index - Schema public


Table: public.ip_address_logs

public.ip_address_logs Structure
F-Key Name Type Description
ip_addres_log_id bigserial PRIMARY KEY
date_of timestamp without time zone NOT NULL DEFAULT now()
reason reasons
message text
public.host_services.host_service_id daemon_id bigint
public.ip_addresses.ip_address_id ip_address_id bigint
address_new inet
ip_address_type_new addresstype
public.interfaces.port_id port_id bigint
address_old inet
ip_address_type_old addresstype
ip_address_logs_date_of_index date_of

Index - Schema public


Table: public.ip_addresses

IP címek

public.ip_addresses Structure
F-Key Name Type Description
ip_address_id bigserial PRIMARY KEY
ip_address_note text
address inet

Az IP cím (nem tartomány)
ip_address_type addresstype NOT NULL

A cím típusa
preferred integer

Cím keresésnél egy opcionális sorrendet definiál, a kisebb érték az preferált.
public.subnets.subnet_id subnet_id bigint
public.interfaces.port_id port_id bigint NOT NULL

A tulajdonos port, melyhez a cím tartozik
flag boolean DEFAULT false

Tables referencing this one via Foreign Key Constraints:

ip_addresses_port_id_index port_id

Index - Schema public


Table: public.languages

public.languages Structure
F-Key Name Type Description
language_id serial PRIMARY KEY
language_name text UNIQUE NOT NULL
lang_id integer UNIQUE#3 NOT NULL

Qt enum QLocale::Language
country_id integer UNIQUE#3 NOT NULL

Qt enum QLocale::Country
country_a2 character varying(2) UNIQUE#1 UNIQUE#2 NOT NULL

ISO Alpha-2
lang_2 character varying(2) UNIQUE#1 NOT NULL

ISO 639-1
lang_3 character varying(3) UNIQUE#2 NOT NULL

ISO 639-5
public.images.image_id flag_image bigint
public.languages.language_id next_id integer

Tables referencing this one via Foreign Key Constraints:

Index - Schema public


View: public.lldp_links

Symmetric View Table for LLDP links

public.lldp_links Structure
F-Key Name Type Description
lldp_link_id bigint
port_id1 bigint
port_id2 bigint
first_time timestamp without time zone
last_time timestamp without time zone
SELECT lldp_links_table.lldp_link_id
,
    lldp_links_table.port_id1
,
    lldp_links_table.port_id2
,
    lldp_links_table.first_time
,
    lldp_links_table.last_time
   
FROM lldp_links_table

UNION
 
SELECT lldp_links_table.lldp_link_id
,
    lldp_links_table.port_id2 AS port_id1
,
    lldp_links_table.port_id1 AS port_id2
,
    lldp_links_table.first_time
,
    lldp_links_table.last_time
   
FROM lldp_links_table;

Index - Schema public


View: public.lldp_links_shape

Symmetric View Table for lldp links with shape

public.lldp_links_shape Structure
F-Key Name Type Description
lldp_link_id bigint
port_id1 bigint
node_id1 bigint
node_name1 text
port_name1 text
port_index1 integer
port_full_name1 text
port_id2 bigint
node_id2 bigint
node_name2 text
port_name2 text
port_index2 integer
port_full_name2 text
first_time timestamp without time zone
last_time timestamp without time zone
SELECT lldp_links.lldp_link_id
,
    lldp_links.port_id1
,
    n1.node_id AS node_id1
,
    n1.node_name AS node_name1
,
    p1.port_name AS port_name1
,
    p1.port_index AS port_index1
,
    
(
     (n1.node_name || ':'::text) || p1.port_name
) AS port_full_name1
,
    lldp_links.port_id2
,
    n2.node_id AS node_id2
,
    n2.node_name AS node_name2
,
    p2.port_name AS port_name2
,
    p2.port_index AS port_index2
,
    
(
     (n2.node_name || ':'::text) || p2.port_name
) AS port_full_name2
,
    lldp_links.first_time
,
    lldp_links.last_time
   
FROM (
     (lldp_links
     
        JOIN (nports p1
     
              JOIN patchs n1 
             USING (node_id)
           )
          ON (
                 (p1.port_id = lldp_links.port_id1)
           )
     )
     
  JOIN (nports p2
     
        JOIN patchs n2 
       USING (node_id)
     )
    ON (
           (p2.port_id = lldp_links.port_id2)
     )
);

Index - Schema public


Table: public.lldp_links_table

public.lldp_links_table Structure
F-Key Name Type Description
lldp_link_id bigserial PRIMARY KEY
public.interfaces.port_id port_id1 bigint UNIQUE NOT NULL
public.interfaces.port_id port_id2 bigint UNIQUE NOT NULL
first_time timestamp without time zone NOT NULL DEFAULT now()
last_time timestamp without time zone NOT NULL DEFAULT now()

Index - Schema public


View: public.lldp_named_links

Symmetric View Table for lldp links with name fields

public.lldp_named_links Structure
F-Key Name Type Description
lldp_link_id bigint
port_id1 bigint
node_name1 text
port_name1 text
port_id2 bigint
node_name2 text
port_name2 text
first_time timestamp without time zone
last_time timestamp without time zone
SELECT lldp_links.lldp_link_id
,
    lldp_links.port_id1
,
    n1.node_name AS node_name1
,
    p1.port_name AS port_name1
,
    lldp_links.port_id2
,
    n2.node_name AS node_name2
,
    p2.port_name AS port_name2
,
    lldp_links.first_time
,
    lldp_links.last_time
   
FROM (
     (lldp_links
     
        JOIN (nports p1
     
              JOIN patchs n1 
             USING (node_id)
           )
          ON (
                 (p1.port_id = lldp_links.port_id1)
           )
     )
     
  JOIN (nports p2
     
        JOIN patchs n2 
       USING (node_id)
     )
    ON (
           (p2.port_id = lldp_links.port_id2)
     )
);

Index - Schema public


Table: public.localizations

public.localizations Structure
F-Key Name Type Description
text_id bigint PRIMARY KEY
table_for_text tablefortext NOT NULL
public.languages.language_id language_id integer PRIMARY KEY
texts text[] NOT NULL
localization_texts_text_id_index text_id, table_for_text

Index - Schema public


View: public.log_links

Symmetric View Table for logical links

public.log_links Structure
F-Key Name Type Description
log_link_id bigint
port_id1 bigint
port_id2 bigint
log_link_note text
link_type linktype
phs_link_chain bigint[]
share_result portshare
SELECT log_links_table.log_link_id
,
    log_links_table.port_id1
,
    log_links_table.port_id2
,
    log_links_table.log_link_note
,
    log_links_table.link_type
,
    log_links_table.phs_link_chain
,
    log_links_table.share_result
   
FROM log_links_table

UNION
 
SELECT log_links_table.log_link_id
,
    log_links_table.port_id2 AS port_id1
,
    log_links_table.port_id1 AS port_id2
,
    log_links_table.log_link_note
,
    log_links_table.link_type
,
    log_links_table.phs_link_chain
,
    log_links_table.share_result
   
FROM log_links_table;

Index - Schema public


View: public.log_links_shape

Symmetric View Table for logical links with shape

public.log_links_shape Structure
F-Key Name Type Description
log_link_id bigint
port_id1 bigint
node_id1 bigint
node_name1 text
port_name1 text
port_index1 integer
port_full_name1 text
port_id2 bigint
node_id2 bigint
node_name2 text
port_name2 text
port_index2 integer
port_full_name2 text
log_link_note text
link_type linktype
phs_link_chain bigint[]
share_result portshare
SELECT log_links.log_link_id
,
    log_links.port_id1
,
    n1.node_id AS node_id1
,
    n1.node_name AS node_name1
,
    p1.port_name AS port_name1
,
    p1.port_index AS port_index1
,
    
(
     (n1.node_name || ':'::text) || p1.port_name
) AS port_full_name1
,
    log_links.port_id2
,
    n2.node_id AS node_id2
,
    n2.node_name AS node_name2
,
    p2.port_name AS port_name2
,
    p2.port_index AS port_index2
,
    
(
     (n2.node_name || ':'::text) || p2.port_name
) AS port_full_name2
,
    log_links.log_link_note
,
    log_links.link_type
,
    log_links.phs_link_chain
,
    log_links.share_result
   
FROM (
     (log_links
     
        JOIN (nports p1
     
              JOIN patchs n1 
             USING (node_id)
           )
          ON (
                 (p1.port_id = log_links.port_id1)
           )
     )
     
  JOIN (nports p2
     
        JOIN patchs n2 
       USING (node_id)
     )
    ON (
           (p2.port_id = log_links.port_id2)
     )
);

Index - Schema public


Table: public.log_links_table

Logical Links Table

public.log_links_table Structure
F-Key Name Type Description
log_link_id bigserial PRIMARY KEY

Unique ID for logical links
port_id1 bigint UNIQUE NOT NULL

Interface's ID which connects to logical links
port_id2 bigint UNIQUE NOT NULL

Interface's ID which connects to logical links
log_link_note text

noteiption
link_type linktype NOT NULL
phs_link_chain bigint[] NOT NULL

Physical links chain.
share_result portshare NOT NULL DEFAULT ''::public.portshare

Ha az útvonalban megsoztás van, megadja az összeköttetés milyenségét

Index - Schema public


View: public.log_named_links

Symmetric View Table for logical links with name fields

public.log_named_links Structure
F-Key Name Type Description
log_link_id bigint
port_id1 bigint
node_name1 text
port_name1 text
port_id2 bigint
node_name2 text
port_name2 text
log_link_note text
link_type linktype
phs_link_chain bigint[]
share_result portshare
SELECT log_links.log_link_id
,
    log_links.port_id1
,
    n1.node_name AS node_name1
,
    p1.port_name AS port_name1
,
    log_links.port_id2
,
    n2.node_name AS node_name2
,
    p2.port_name AS port_name2
,
    log_links.log_link_note
,
    log_links.link_type
,
    log_links.phs_link_chain
,
    log_links.share_result
   
FROM (
     (log_links
     
        JOIN (nports p1
     
              JOIN patchs n1 
             USING (node_id)
           )
          ON (
                 (p1.port_id = log_links.port_id1)
           )
     )
     
  JOIN (nports p2
     
        JOIN patchs n2 
       USING (node_id)
     )
    ON (
           (p2.port_id = log_links.port_id2)
     )
);

Index - Schema public


Table: public.mactab

Port címtábla lekérdezések eredményét tartalmazó tábla. Az adatmanipulációs műveletek a függvényeket keresztűl lehet elvégezni : replace_mactab()

public.mactab Structure
F-Key Name Type Description
hwaddress macaddr PRIMARY KEY
public.interfaces.port_id port_id bigint NOT NULL
mactab_state mactabstate[] DEFAULT '{}'::public.mactabstate[]
first_time timestamp without time zone DEFAULT now()
last_time timestamp without time zone DEFAULT now()
state_updated_time timestamp without time zone DEFAULT now()
set_type settype NOT NULL DEFAULT 'manual'::public.settype

 

public.mactab Constraints
Name Constraint
mactab_check_mac CHECK ((NOT ((hwaddress = '00:00:00:00:00:00'::macaddr) OR (hwaddress = 'ff:ff:ff:ff:ff:ff'::macaddr))))
mactab_first_time_index first_time mactab_last_time_index last_time mactab_port_id_index port_id mactab_state_updated_time_index state_updated_time

Index - Schema public


Table: public.mactab_logs

Port cím tábla rekordok változása

public.mactab_logs Structure
F-Key Name Type Description
mactab_log_id bigserial PRIMARY KEY
hwaddress macaddr NOT NULL

A változáshoz tartozó MAC
reason reasons NOT NULL

A változás típusa: move A MAC egy másik port címtáblájában jelent meg modify Állpotváltozás remove A bejegyzés törölve lett. expired A MAC nem jelent meg egyik címtáblában sem egy megadott ideje, ezért törölve lett.
be_void boolean NOT NULL DEFAULT false

Nem releváns log rekord, nem valós mozgás eredménye.
date_of timestamp without time zone NOT NULL DEFAULT now()

A bejegyzés időpontja
public.interfaces.port_id port_id_old bigint

Az eredeti portmac bejegyzéshez tartozó port_id érték, vagy NULL
mactab_state_old mactabstate[]
first_time_old timestamp without time zone NOT NULL
last_time_old timestamp without time zone NOT NULL
set_type_old settype NOT NULL
public.interfaces.port_id port_id_new bigint
mactab_state_new mactabstate[]
set_type_new settype
acknowledged boolean DEFAULT false
mactab_logs_date_of_index date_of mactab_logs_hwaddress_index hwaddress

Index - Schema public


View: public.mactab_logs_shape

public.mactab_logs_shape Structure
F-Key Name Type Description
mactab_log_id bigint
hwaddress macaddr
node_by_mac text
reason reasons
be_void boolean
date_of timestamp without time zone
port_id_old bigint
port_name_old text
first_time_old timestamp without time zone
last_time_old timestamp without time zone
set_type_old settype
port_id_new bigint
port_name_new text
acknowledged boolean
SELECT mactab_logs.mactab_log_id
,
    mactab_logs.hwaddress
,
    mac2node_name
(mactab_logs.hwaddress) AS node_by_mac
,
    mactab_logs.reason
,
    mactab_logs.be_void
,
    mactab_logs.date_of
,
    mactab_logs.port_id_old
,
    port_id2full_name
(mactab_logs.port_id_old) AS port_name_old
,
    mactab_logs.first_time_old
,
    mactab_logs.last_time_old
,
    mactab_logs.set_type_old
,
    mactab_logs.port_id_new
,
    port_id2full_name
(mactab_logs.port_id_new) AS port_name_new
,
    mactab_logs.acknowledged
   
FROM mactab_logs;

Index - Schema public


View: public.mactab_shape

public.mactab_shape Structure
F-Key Name Type Description
node_id bigint
node_name text
port_id bigint
port_name text
port_index integer
hwaddress macaddr
mactab_state mactabstate[]
first_time timestamp without time zone
last_time timestamp without time zone
state_updated_time timestamp without time zone
set_type settype
r_node_name text
r_port_name text
ipaddrs_by_arp text[]
ipaddrs_by_rif text[]
SELECT n.node_id
,
    n.node_name
,
    t.port_id
,
    p.port_name
,
    p.port_index
,
    t.hwaddress
,
    t.mactab_state
,
    t.first_time
,
    t.last_time
,
    t.state_updated_time
,
    t.set_type
,
    r.node_name AS r_node_name
,
    port_id2name
(i.port_id) AS r_port_name
,
    ARRAY
(
SELECT (arps.ipaddress)::text AS ipaddress
           
  FROM arps
          
 WHERE (arps.hwaddress = t.hwaddress)
) AS ipaddrs_by_arp
,
    ARRAY
(
SELECT (ip_addresses.address)::text AS address
           
  FROM ip_addresses
          
 WHERE (ip_addresses.port_id = i.port_id)
) AS ipaddrs_by_rif
   
FROM (
     (
           (
                 (mactab t
     
                    JOIN nports p 
                   USING (port_id)
                 )
     
              JOIN nodes n 
             USING (node_id)
           )
     
   LEFT JOIN interfaces i 
       USING (hwaddress)
     )
     
LEFT JOIN nodes r 
    ON (
           (r.node_id = i.node_id)
     )
);

Index - Schema public


Table: public.menu_items

GUI menü elemek definíciója

public.menu_items Structure
F-Key Name Type Description
menu_item_id bigserial PRIMARY KEY

Menü elem egyedi azonosító
menu_item_name text UNIQUE#1 NOT NULL

Applikáción bellül egyedi név
app_name text UNIQUE#1 UNIQUE#2 NOT NULL

Aplikáció név, melyhez a menü elem tartozik.
public.menu_items.menu_item_id upper_menu_item_id bigint UNIQUE#2

Al menű esetén az elemet tartalmazó felsőbb szintű menü elem azonosítója.
item_sequence_number integer UNIQUE#2

A sorrendet meghatározó szám
features text

Járulékos paraméterek (a menü elem típusát határozza meg): ":shape=<név>:", ":exec=<név>:", ":own=<név>:", ...
menu_rights rights NOT NULL DEFAULT 'none'::public.rights

Milyen minimális jogosutságnál jelenik meg az elem. Ha ez a végrajtandó elemnél ilyen paraméter nem létezik.
text_id bigint NOT NULL DEFAULT nextval('public.text_id_sequ'::regclass)
menu_item_type menuitemtype NOT NULL DEFAULT 'menu'::public.menuitemtype
menu_param text
menu_item_note text

 

public.menu_items Constraints
Name Constraint
check_type_and_param CHECK ((((menu_item_type = 'menu'::menuitemtype) AND (menu_param IS NULL)) OR ((menu_item_type <> 'menu'::menuitemtype) AND (menu_param IS NOT NULL))))

Tables referencing this one via Foreign Key Constraints:

Index - Schema public


View: public.named_host_services

public.named_host_services Structure
F-Key Name Type Description
host_service_id bigint
node_id bigint
node_name text
service_id bigint
service_name text
port_id bigint
host_service_note text
prime_service_id bigint
pri_service_name text
proto_service_id bigint
pro_service_name text
delegate_host_state boolean
check_cmd text
features text
s_features text
pri_features text
pro_features text
disabled boolean
s_disabled boolean
superior_host_service_id bigint
superior_host_service_name text
max_check_attempts integer
normal_check_interval interval
retry_check_interval interval
timeperiod_id bigint
flapping_interval interval
flapping_max_change integer
noalarm_flag noalarmtype
noalarm_from timestamp without time zone
noalarm_to timestamp without time zone
offline_group_ids bigint[]
online_group_ids bigint[]
host_service_state notifswitch
soft_state notifswitch
hard_state notifswitch
state_msg text
check_attempts integer
last_changed timestamp without time zone
last_touched timestamp without time zone
act_alarm_log_id bigint
last_alarm_log_id bigint
deleted boolean
last_noalarm_msg text
heartbeat_time interval
SELECT hs.host_service_id
,
    hs.node_id
,
    n.node_name
,
    hs.service_id
,
    s.service_name
,
    hs.port_id
,
    hs.host_service_note
,
    hs.prime_service_id
,
    pri.service_name AS pri_service_name
,
    hs.proto_service_id
,
    pro.service_name AS pro_service_name
,
    hs.delegate_host_state
,
    COALESCE
(hs.check_cmd
     , s.check_cmd
     , pri.check_cmd
     , pro.check_cmd
) AS check_cmd
,
    hs.features
,
    s.features AS s_features
,
    pri.features AS pri_features
,
    pro.features AS pro_features
,
    hs.disabled
,
    s.disabled AS s_disabled
,
    hs.superior_host_service_id
,
    host_service_id2name
(hs.superior_host_service_id) AS superior_host_service_name
,
    COALESCE
(hs.max_check_attempts
     , s.max_check_attempts
     , pri.max_check_attempts
     , pro.max_check_attempts
) AS max_check_attempts
,
    COALESCE
(hs.normal_check_interval
     , s.normal_check_interval
     , pri.normal_check_interval
     , pro.normal_check_interval
) AS normal_check_interval
,
    COALESCE
(hs.retry_check_interval
     , s.retry_check_interval
     , pri.retry_check_interval
     , pro.retry_check_interval
) AS retry_check_interval
,
    COALESCE
(hs.timeperiod_id
     , s.timeperiod_id
     , pri.timeperiod_id
     , pro.timeperiod_id
) AS timeperiod_id
,
    COALESCE
(hs.flapping_interval
     , s.flapping_interval
     , pri.flapping_interval
     , pro.flapping_interval
) AS flapping_interval
,
    COALESCE
(hs.flapping_max_change
     , s.flapping_max_change
     , pri.flapping_max_change
     , pro.flapping_max_change
) AS flapping_max_change
,
    hs.noalarm_flag
,
    hs.noalarm_from
,
    hs.noalarm_to
,
    COALESCE
(hs.offline_group_ids
     , s.offline_group_ids
     , pri.offline_group_ids
     , pro.offline_group_ids
) AS offline_group_ids
,
    COALESCE
(hs.online_group_ids
     , s.online_group_ids
     , pri.online_group_ids
     , pro.online_group_ids
) AS online_group_ids
,
    hs.host_service_state
,
    hs.soft_state
,
    hs.hard_state
,
    hs.state_msg
,
    hs.check_attempts
,
    hs.last_changed
,
    hs.last_touched
,
    hs.act_alarm_log_id
,
    hs.last_alarm_log_id
,
    hs.deleted
,
    hs.last_noalarm_msg
,
    COALESCE
(hs.heartbeat_time
     , s.heartbeat_time
     , pri.heartbeat_time
     , pro.heartbeat_time
) AS heartbeat_time
   
FROM (
     (
           (
                 (host_services hs
     
                    JOIN nodes n 
                   USING (node_id)
                 )
     
              JOIN services s 
             USING (service_id)
           )
     
        JOIN services pri 
          ON (
                 (pri.service_id = hs.prime_service_id)
           )
     )
     
  JOIN services pro 
    ON (
           (pro.service_id = hs.proto_service_id)
     )
);

Index - Schema public


View: public.named_port_vlans

public.named_port_vlans Structure
F-Key Name Type Description
port_vlan_id bigint
node_id bigint
node_name text
port_id bigint
port_name text
vlan_id bigint
vlan_name text
vlan_type vlantype
SELECT port_vlans.port_vlan_id
,
    nports.node_id
,
    nodes.node_name
,
    port_vlans.port_id
,
    nports.port_name
,
    port_vlans.vlan_id
,
    vlans.vlan_name
,
    port_vlans.vlan_type
   
FROM (
     (
           (port_vlans
     
              JOIN vlans 
             USING (vlan_id)
           )
     
        JOIN nports 
       USING (port_id)
     )
     
  JOIN nodes 
 USING (node_id)
);

Index - Schema public


Table: public.node_params

Node extra paraméter értékek.

public.node_params Structure
F-Key Name Type Description
node_param_id bigserial PRIMARY KEY

A paraméter érték egyedi azonosítója.
node_param_name text UNIQUE#1 NOT NULL

Paraméter neve.
node_param_note text

Megjegyzés.
node_id bigint UNIQUE#1 NOT NULL

A tulajdonos node rekordjának az azonosítója.
public.param_types.param_type_id param_type_id bigint NOT NULL

A paraméter adat típusát definiáló param_types rekord azonosítója.
param_value text

A parméter érték.
flag boolean DEFAULT false

Index - Schema public


View: public.node_port_vlans

public.node_port_vlans Structure
F-Key Name Type Description
node_id bigint
port_id bigint
port_name text
port_index integer
vlan_id bigint
vlan_name text
vlan_note text
vlan_type vlantype
SELECT nports.node_id
,
    port_vlans.port_id
,
    nports.port_name
,
    nports.port_index
,
    port_vlans.vlan_id
,
    vlans.vlan_name
,
    vlans.vlan_note
,
    port_vlans.vlan_type
   
FROM (
     (port_vlans
     
        JOIN nports 
       USING (port_id)
     )
     
  JOIN vlans 
 USING (vlan_id)
);

Index - Schema public


Table: public.nodes

Passzív vagy aktív hálózati elemek táblája

public.nodes Structure
F-Key Name Type Description
node_id bigint PRIMARY KEY DEFAULT nextval('public.patchs_node_id_seq'::regclass)
node_name text UNIQUE NOT NULL
node_note text
node_type nodetype[]

Típus azonosítók. ha NULL, akkor a trigger f. {node}-ra állítja.
public.places.place_id place_id bigint
features text
deleted boolean NOT NULL DEFAULT false
inventory_number text
serial_number text
model_number text
model_name text
location point
node_stat notifswitch NOT NULL DEFAULT 'unknown'::public.notifswitch

Az eszköz állapota.
os_name text

Operating system or firmware name
os_version text

Operating system or firmware version

Table public.nodes Inherits patchs,

Tables referencing this one via Foreign Key Constraints:

Index - Schema public


Table: public.nports

Passzív portok táblája, az összes port típus őse

public.nports Structure
F-Key Name Type Description
port_id bigserial PRIMARY KEY

Egyedi port azonosító, az összes port típusra (leszármazottra) egyedi
port_name text UNIQUE#1 NOT NULL

A port neve, csak egy nodon bellül (azonos node_id) kell egyedinek lennie
port_note text

Description for network port
port_tag text

Opcionális cimke ill. név.
public.iftypes.iftype_id iftype_id bigint

A típus leíró rekord azonosítója.
node_id bigint UNIQUE#1 NOT NULL

Csomópont azonosító, idegen kulcs a tulajdonos nodes vagy bármelyi leszármazottja rekordjára
port_index integer

Opcionális port index. Egyes leszármazottaknál kötelező, ha meg van adva, akkor a port_name -hez hasonlóan egyedinek kell lennie.
deleted boolean DEFAULT false

Ha igaz, akkor a port logikailag törölve lett.
flag boolean DEFAULT false
nports_node_id_index node_id

Index - Schema public


View: public.online_alarm_acks

On-line nyugtázott, még aktív riasztások

public.online_alarm_acks Structure
F-Key Name Type Description
online_alarm_ack_id bigint
host_service_id bigint
host_service_name text
node_name text
place_name text
place_id bigint
superior_alarm_id bigint
begin_time timestamp without time zone
first_status notifswitch
max_status notifswitch
last_status notifswitch
event_note text
msg text
online_user_ids bigint[]
notice_user_ids bigint[]
view_user_ids bigint[]
ack_user_ids bigint[]
ack_user_note text
 WITH oaa AS 
(
         
SELECT e.alarm_id
     ,
            e.online_user_ids
     ,
            
     (
      SELECT array_agg
           (user_events.user_id) AS array_agg
                   
        FROM user_events
                  
       WHERE (
                 (user_events.alarm_id = e.alarm_id)
               AND (user_events.user_id = ANY 
                       (e.online_user_ids)
                 )
               AND (user_events.event_type = 'notice'::usereventtype)
               AND (user_events.event_state = 'happened'::usereventstate)
           )
     ) AS notice_user_ids
     ,
            
     (
      SELECT array_agg
           (user_events.user_id) AS array_agg
                   
        FROM user_events
                  
       WHERE (
                 (user_events.alarm_id = e.alarm_id)
               AND (user_events.user_id = ANY 
                       (e.online_user_ids)
                 )
               AND (user_events.event_type = 'view'::usereventtype)
           )
     ) AS view_user_ids
     ,
            
     (
      SELECT array_agg
           (user_events.user_id) AS array_agg
                   
        FROM user_events
                  
       WHERE (
                 (user_events.alarm_id = e.alarm_id)
               AND (user_events.event_type = 'acknowledge'::usereventtype)
           )
     ) AS ack_user_ids
           
  FROM online_alarms e
        
)
 
SELECT oaa.alarm_id AS online_alarm_ack_id
,
    alarms.host_service_id
,
    host_service_id2name
(alarms.host_service_id) AS host_service_name
,
    n.node_name
,
    p.place_name
,
    n.place_id
,
    alarms.superior_alarm_id
,
    alarms.begin_time
,
    alarms.first_status
,
    alarms.max_status
,
    alarms.last_status
,
    alarms.event_note
,
    alarm_message
(alarms.host_service_id
     , alarms.max_status
) AS msg
,
    oaa.online_user_ids
,
    oaa.notice_user_ids
,
    oaa.view_user_ids
,
    oaa.ack_user_ids
,
    
(
SELECT string_agg
     (user_events.user_event_note
           ,'\n'::text
     ) AS string_agg
           
  FROM user_events
          
 WHERE (
           (user_events.alarm_id = oaa.alarm_id)
         AND (user_events.event_type = 'acknowledge'::usereventtype)
     )
) AS ack_user_note
   
FROM (
     (
           (
                 (
                       (oaa
     
                          JOIN alarms 
                         USING (alarm_id)
                       )
     
                    JOIN host_services h 
                   USING (host_service_id)
                 )
     
              JOIN services s 
             USING (service_id)
           )
     
        JOIN nodes n 
       USING (node_id)
     )
     
  JOIN places p 
 USING (place_id)
)
  
WHERE (
     (alarms.end_time IS NULL)
   AND (0 < array_length
           (oaa.ack_user_ids
                 , 1
           )
     )
);

Index - Schema public


View: public.online_alarm_unacks

public.online_alarm_unacks Structure
F-Key Name Type Description
online_alarm_unack_id bigint
host_service_id bigint
host_service_name text
node_name text
place_name text
place_id bigint
superior_alarm_id bigint
begin_time timestamp without time zone
end_time timestamp without time zone
first_status notifswitch
max_status notifswitch
last_status notifswitch
event_note text
msg text
online_user_ids bigint[]
notice_user_ids bigint[]
view_user_ids bigint[]
SELECT online_alarms.alarm_id AS online_alarm_unack_id
,
    alarms.host_service_id
,
    host_service_id2name
(alarms.host_service_id) AS host_service_name
,
    n.node_name
,
    p.place_name
,
    n.place_id
,
    alarms.superior_alarm_id
,
    alarms.begin_time
,
    alarms.end_time
,
    alarms.first_status
,
    alarms.max_status
,
    alarms.last_status
,
    alarms.event_note
,
    alarm_message
(alarms.host_service_id
     , alarms.max_status
) AS msg
,
    online_alarms.online_user_ids
,
    
(
SELECT array_agg
     (user_events.user_id) AS array_agg
           
  FROM user_events
          
 WHERE (
           (user_events.alarm_id = alarms.alarm_id)
         AND (user_events.event_type = 'notice'::usereventtype)
         AND (user_events.user_id = ANY 
                 (online_alarms.online_user_ids)
           )
         AND (user_events.event_state = 'happened'::usereventstate)
     )
) AS notice_user_ids
,
    
(
SELECT array_agg
     (user_events.user_id) AS array_agg
           
  FROM user_events
          
 WHERE (
           (user_events.alarm_id = alarms.alarm_id)
         AND (user_events.event_type = 'view'::usereventtype)
         AND (user_events.user_id = ANY 
                 (online_alarms.online_user_ids)
           )
     )
) AS view_user_ids
   
FROM (
     (
           (
                 (
                       (online_alarms
     
                          JOIN alarms 
                         USING (alarm_id)
                       )
     
                    JOIN host_services h 
                   USING (host_service_id)
                 )
     
              JOIN services s 
             USING (service_id)
           )
     
        JOIN nodes n 
       USING (node_id)
     )
     
  JOIN places p 
 USING (place_id)
)
  
WHERE (0 = 
     (
      SELECT count
           (*) AS count
           
        FROM user_events
          
       WHERE (
                 (user_events.alarm_id = alarms.alarm_id)
               AND (user_events.event_type = 'acknowledge'::usereventtype)
           )
     )
);

Index - Schema public


View: public.online_alarms

public.online_alarms Structure
F-Key Name Type Description
alarm_id bigint
online_user_ids bigint[]
SELECT user_events.alarm_id
,
    array_agg
(user_events.user_id) AS online_user_ids
   
FROM (user_events
     
  JOIN alarms 
 USING (alarm_id)
)
  
WHERE (
     (user_events.event_type = 'notice'::usereventtype)
   AND (user_events.event_state <> 'dropped'::usereventstate)
)
  
GROUP BY user_events.alarm_id
, alarms.begin_time
  
ORDER BY alarms.begin_time;

Index - Schema public


View: public.online_alarms_noack

On-line nem nyugtázott riasztások

public.online_alarms_noack Structure
F-Key Name Type Description
online_alarm_id bigint
host_service_id bigint
host_service_name text
node_name text
place_name text
place_id bigint
superior_alarm_id bigint
begin_time timestamp without time zone
end_time timestamp without time zone
first_status notifswitch
max_status notifswitch
last_status notifswitch
msg text
online_user_ids bigint[]
notice_user_ids bigint[]
view_user_ids bigint[]
 WITH a AS 
(
         
SELECT a_1.alarm_id
     ,
            a_1.host_service_id
     ,
            a_1.daemon_id
     ,
            a_1.first_status
     ,
            a_1.max_status
     ,
            a_1.last_status
     ,
            a_1.begin_time
     ,
            a_1.event_note
     ,
            a_1.superior_alarm_id
     ,
            a_1.end_time
     ,
            ARRAY
     (
      SELECT user_events.user_id
                   
        FROM user_events
                  
       WHERE (
                 (user_events.alarm_id = a_1.alarm_id)
               AND (user_events.event_type = 'notice'::usereventtype)
               AND (user_events.event_state <> 'dropped'::usereventstate)
           )
     ) AS online_user_ids
           
  FROM alarms a_1
          
 WHERE (
           (0 = 
                 (
                  SELECT count
                       (*) AS count
                   
                    FROM user_events
                  
                   WHERE (
                             (user_events.alarm_id = a_1.alarm_id)
                           AND (user_events.event_type = 'acknowledge'::usereventtype)
                       )
                 )
           )
         AND COALESCE
           (
                 (
                       (a_1.end_time + 
                             (
                                   (
                                    SELECT sys_params.param_value
                   
                                      FROM sys_params
                  
                                     WHERE (sys_params.sys_param_name = 'user_notice_timeout'::text)
                                   )
                             )::interval
                       ) > now
                       ()
                 )
                 , true
           )
     )
        
)
 
SELECT a.alarm_id AS online_alarm_id
,
    a.host_service_id
,
    host_service_id2name
(a.host_service_id) AS host_service_name
,
    n.node_name
,
    p.place_name
,
    n.place_id
,
    a.superior_alarm_id
,
    a.begin_time
,
    a.end_time
,
    a.first_status
,
    a.max_status
,
    a.last_status
,
    alarm_message
(a.host_service_id
     , a.max_status
) AS msg
,
    a.online_user_ids
,
    
(
SELECT array_agg
     (user_events.user_id) AS array_agg
           
  FROM user_events
          
 WHERE (
           (user_events.alarm_id = a.alarm_id)
         AND (user_events.event_type = 'notice'::usereventtype)
         AND (user_events.event_state = 'happened'::usereventstate)
     )
) AS notice_user_ids
,
    
(
SELECT array_agg
     (user_events.user_id) AS array_agg
           
  FROM user_events
          
 WHERE (
           (user_events.alarm_id = a.alarm_id)
         AND (user_events.event_type = 'view'::usereventtype)
     )
) AS view_user_ids
   
FROM (
     (
           (
                 (a
     
                    JOIN host_services h 
                   USING (host_service_id)
                 )
     
              JOIN services s 
             USING (service_id)
           )
     
        JOIN nodes n 
       USING (node_id)
     )
     
  JOIN places p 
 USING (place_id)
)
  
WHERE (0 < array_length
     (a.online_user_ids
           , 1
     )
);

Index - Schema public


Table: public.ouis

Organizational Unique Identifier

public.ouis Structure
F-Key Name Type Description
oui macaddr PRIMARY KEY
oui_name text NOT NULL
oui_note text

Index - Schema public


Table: public.param_types

Paraméterek deklarálása (név, típus, dimenzió)

public.param_types Structure
F-Key Name Type Description
param_type_id bigserial PRIMARY KEY

A paraméter típus leíró egyedi azonosítója.
param_type_name text UNIQUE NOT NULL

A paraméter típus neve.
param_type_note text

A paraméterhez egy magyarázó szöveg
param_type_type paramtype NOT NULL

Típus azonosító
param_type_dim text

Egy opcionális dimenzió

Tables referencing this one via Foreign Key Constraints:

Index - Schema public


View: public.patchable_ports

public.patchable_ports Structure
F-Key Name Type Description
patchable_port_id bigint
port_name text
port_note text
port_tag text
iftype_id bigint
node_id bigint
port_index integer
deleted boolean
SELECT nports.port_id AS patchable_port_id
,
    nports.port_name
,
    nports.port_note
,
    nports.port_tag
,
    nports.iftype_id
,
    nports.node_id
,
    nports.port_index
,
    nports.deleted
   
FROM (nports
     
  JOIN iftypes 
 USING (iftype_id)
)
  
WHERE (iftypes.iftype_link_type = ANY 
     (ARRAY['ptp'::linktype
           ,'bus'::linktype
           ,'patch'::linktype]
     )
);

Index - Schema public


Table: public.patchs

Patch panel/csatlakozók/kapcsolódási pont tábla

public.patchs Structure
F-Key Name Type Description
node_id bigserial PRIMARY KEY

Unique ID for node. Az összes leszármazottra és az ősre is egyedi.
node_name text UNIQUE NOT NULL

Unique Name of the node. Az összes leszármazottra és az ősre is egyedi.
node_note text

Descrition of the node
node_type nodetype[]

A hálózati elem típusa, a patch típusú rekord esetén mindíg "patch", a trigger állítja be.
public.places.place_id place_id bigint

Az eszköz helyét azonosító "opcionális" távoli kulcs. Alapértelmezett hely a 'unknown'.
features text
deleted boolean NOT NULL DEFAULT false
inventory_number text
serial_number text
model_number text
model_name text
location point

Tables referencing this one via Foreign Key Constraints:

Index - Schema public


View: public.phs_links

Symmetric View Table for physical links

public.phs_links Structure
F-Key Name Type Description
phs_link_id bigint
port_id1 bigint
port_id2 bigint
phs_link_type1 phslinktype
phs_link_type2 phslinktype
phs_link_note text
port_shared portshare
link_type linktype
create_time timestamp without time zone
create_user_id bigint
modify_time timestamp without time zone
modify_user_id bigint
forward boolean
SELECT phs_links_table.phs_link_id
,
    phs_links_table.port_id1
,
    phs_links_table.port_id2
,
    phs_links_table.phs_link_type1
,
    phs_links_table.phs_link_type2
,
    phs_links_table.phs_link_note
,
    phs_links_table.port_shared
,
    phs_links_table.link_type
,
    phs_links_table.create_time
,
    phs_links_table.create_user_id
,
    phs_links_table.modify_time
,
    phs_links_table.modify_user_id
,
    true AS forward
   
FROM phs_links_table

UNION
 
SELECT phs_links_table.phs_link_id
,
    phs_links_table.port_id2 AS port_id1
,
    phs_links_table.port_id1 AS port_id2
,
    phs_links_table.phs_link_type2 AS phs_link_type1
,
    phs_links_table.phs_link_type1 AS phs_link_type2
,
    phs_links_table.phs_link_note
,
    phs_links_table.port_shared
,
    phs_links_table.link_type
,
    phs_links_table.create_time
,
    phs_links_table.create_user_id
,
    phs_links_table.modify_time
,
    phs_links_table.modify_user_id
,
    false AS forward
   
FROM phs_links_table;

Index - Schema public


View: public.phs_links_shape

public.phs_links_shape Structure
F-Key Name Type Description
phs_link_id bigint
port_id1 bigint
node_id1 bigint
node_name1 text
port_name1 text
port_index1 integer
port_tag1 text
port_full_name1 text
phs_link_type1 phslinktype
port_shared1 text
port_id2 bigint
node_id2 bigint
node_name2 text
port_name2 text
port_index2 integer
port_tag2 text
port_full_name2 text
phs_link_type2 phslinktype
port_shared2 text
phs_link_note text
link_type linktype
create_time timestamp without time zone
create_user_id bigint
modify_time timestamp without time zone
modify_user_id bigint
forward boolean
SELECT phs_links.phs_link_id
,
    phs_links.port_id1
,
    n1.node_id AS node_id1
,
    n1.node_name AS node_name1
,
        CASE
            WHEN 
(phs_links.phs_link_type1 = 'Front'::phslinktype) THEN 
(p1.port_name || shared_cable
     (phs_links.port_id1
           ,' / '::text
     )
)
            ELSE p1.port_name
        END AS port_name1
,
    p1.port_index AS port_index1
,
    p1.port_tag AS port_tag1
,
    
(
     (n1.node_name || ':'::text) || p1.port_name
) AS port_full_name1
,
    phs_links.phs_link_type1
,
        CASE
            WHEN 
(phs_links.phs_link_type1 = 'Front'::phslinktype) THEN 
(phs_links.port_shared)::text
            WHEN 
(phs_links.phs_link_type1 = 'Back'::phslinktype) THEN shared_cable_back
(phs_links.port_id1)
            ELSE ''::text
        END AS port_shared1
,
    phs_links.port_id2
,
    n2.node_id AS node_id2
,
    n2.node_name AS node_name2
,
        CASE
            WHEN 
(phs_links.phs_link_type2 = 'Front'::phslinktype) THEN 
(p2.port_name || shared_cable
     (phs_links.port_id2
           ,' / '::text
     )
)
            ELSE p2.port_name
        END AS port_name2
,
    p2.port_index AS port_index2
,
    p2.port_tag AS port_tag2
,
    
(
     (n2.node_name || ':'::text) || p2.port_name
) AS port_full_name2
,
    phs_links.phs_link_type2
,
        CASE
            WHEN 
(phs_links.phs_link_type2 = 'Front'::phslinktype) THEN 
(phs_links.port_shared)::text
            WHEN 
(phs_links.phs_link_type2 = 'Back'::phslinktype) THEN shared_cable_back
(phs_links.port_id2)
            ELSE ''::text
        END AS port_shared2
,
    phs_links.phs_link_note
,
    phs_links.link_type
,
    phs_links.create_time
,
    phs_links.create_user_id
,
    phs_links.modify_time
,
    phs_links.modify_user_id
,
    phs_links.forward
   
FROM (
     (phs_links
     
        JOIN (nports p1
     
              JOIN patchs n1 
             USING (node_id)
           )
          ON (
                 (p1.port_id = phs_links.port_id1)
           )
     )
     
  JOIN (nports p2
     
        JOIN patchs n2 
       USING (node_id)
     )
    ON (
           (p2.port_id = phs_links.port_id2)
     )
);

Index - Schema public


Table: public.phs_links_table

Phisical Links Table

public.phs_links_table Structure
F-Key Name Type Description
phs_link_id bigserial PRIMARY KEY

Unique ID for phisical links
port_id1 bigint UNIQUE#1 NOT NULL

Port's ID(1) which connects to physical link
port_id2 bigint UNIQUE#2 NOT NULL

Port's ID(2) which connects to physical link
phs_link_type1 phslinktype UNIQUE#1 NOT NULL

Link típusa(1), végpont 'Term', patch panel előlap 'Front', vagy hátlap 'Back'
phs_link_type2 phslinktype UNIQUE#2 NOT NULL

Link típusa(2), végpont 'Term', patch panel előlap 'Front', vagy hátlap 'Back'
phs_link_note text

noteiption
port_shared portshare UNIQUE#1 UNIQUE#2 NOT NULL DEFAULT ''::public.portshare

Mindíg a 'Front' patch portra vonatkozik, ha mindkettő 'Back' patch port, akkor csak '' lehet, vagyis a megosztás tiltott
link_type linktype NOT NULL
create_time timestamp without time zone NOT NULL DEFAULT now()

Time setting up the physical link
public.users.user_id create_user_id bigint

User ID for who set this physical link
modify_time timestamp without time zone NOT NULL DEFAULT now()

Time modified the physical link
public.users.user_id modify_user_id bigint

User ID for who modified the physical link
forward boolean DEFAULT true

értéke mindíg true, a phs_link VIEW táblában van jelentősége, ott a plussz (reverse) soroknál false.
phs_links_table_port_id1_index port_id1 phs_links_table_port_id2_index port_id2

Index - Schema public


View: public.phs_named_links

Symmetric View Table for physical links with name fields

public.phs_named_links Structure
F-Key Name Type Description
phs_link_id bigint
port_id1 bigint
node_name1 text
port_name1 text
phs_link_type1 phslinktype
port_id2 bigint
node_name2 text
port_name2 text
phs_link_type2 phslinktype
phs_link_note text
port_shared portshare
link_type linktype
create_time timestamp without time zone
create_user_id bigint
modify_time timestamp without time zone
modify_user_id bigint
forward boolean
SELECT phs_links.phs_link_id
,
    phs_links.port_id1
,
    n1.node_name AS node_name1
,
    p1.port_name AS port_name1
,
    phs_links.phs_link_type1
,
    phs_links.port_id2
,
    n2.node_name AS node_name2
,
    p2.port_name AS port_name2
,
    phs_links.phs_link_type2
,
    phs_links.phs_link_note
,
    phs_links.port_shared
,
    phs_links.link_type
,
    phs_links.create_time
,
    phs_links.create_user_id
,
    phs_links.modify_time
,
    phs_links.modify_user_id
,
    phs_links.forward
   
FROM (
     (phs_links
     
        JOIN (nports p1
     
              JOIN patchs n1 
             USING (node_id)
           )
          ON (
                 (p1.port_id = phs_links.port_id1)
           )
     )
     
  JOIN (nports p2
     
        JOIN patchs n2 
       USING (node_id)
     )
    ON (
           (p2.port_id = phs_links.port_id2)
     )
);

Index - Schema public


Table: public.place_group_places

public.place_group_places Structure
F-Key Name Type Description
place_group_place_id bigserial PRIMARY KEY
public.place_groups.place_group_id place_group_id bigint UNIQUE#1
public.places.place_id place_id bigint UNIQUE#1
place_group_places_place_group_id_index place_group_id place_group_places_place_id_index place_id

Index - Schema public


Table: public.place_groups

Helyiségek, helyek csoportjai. Zónák.

public.place_groups Structure
F-Key Name Type Description
place_group_id bigserial PRIMARY KEY

Csoport azososítója ID
place_group_name text UNIQUE NOT NULL

Csoport azososító neve
place_group_note text

Megjegyzés
place_group_type placegrouptype DEFAULT 'group'::public.placegrouptype

Tables referencing this one via Foreign Key Constraints:

Index - Schema public


Table: public.places

Helyiségek, helyek leírói a térképen ill. alaprajzon

public.places Structure
F-Key Name Type Description
place_id bigserial PRIMARY KEY

A térkép ill. alaprajz azososítója ID
place_name text UNIQUE NOT NULL

A térkép ill. alaprajz azososítója név
place_note text
place_type placetype DEFAULT 'real'::public.placetype
public.places.place_id parent_id bigint

A térkép ill. alaprajz szülő, ha nincs szülő, akkor NULL
public.images.image_id image_id bigint

Opcionális térkép/alaprajz kép ID
frame polygon

Határoló poligon/pozició a szülőn
tels text[]

Telefonszámok a helyiségben

Tables referencing this one via Foreign Key Constraints:

Index - Schema public


View: public.port_in_mactab

public.port_in_mactab Structure
F-Key Name Type Description
port_id bigint
node_id bigint
port_name text
port_full_name text
mactab_port_id bigint
mactab_port_full_name text
mactab_state mactabstate[]
first_time timestamp without time zone
last_time timestamp without time zone
set_type settype
SELECT i.port_id
,
    n.node_id
,
    i.port_name
,
    
(
     (n.node_name || ':'::text) || i.port_name
) AS port_full_name
,
    m.port_id AS mactab_port_id
,
    port_id2full_name
(m.port_id) AS mactab_port_full_name
,
    m.mactab_state
,
    m.first_time
,
    m.last_time
,
    m.set_type
   
FROM (
     (mactab m
     
        JOIN interfaces i 
       USING (hwaddress)
     )
     
  JOIN nodes n 
 USING (node_id)
);

Index - Schema public


Table: public.port_params

port extra paraméter értékek.

public.port_params Structure
F-Key Name Type Description
port_param_id bigserial PRIMARY KEY

A paraméter érték egyedi azonosítója.
port_param_name text UNIQUE#1 NOT NULL

Paraméter neve.
port_param_note text

Megjegyzés.
port_id bigint UNIQUE#1 NOT NULL

A tulajdonos port rekordjának az azonosítója.
public.param_types.param_type_id param_type_id bigint NOT NULL

A paraméter adat típusát definiáló param_types rekord azonosítója.
param_value text

A parméter érték.
flag boolean DEFAULT false

Index - Schema public


Table: public.port_vlan_logs

public.port_vlan_logs Structure
F-Key Name Type Description
port_vlan_log_id bigserial PRIMARY KEY
date_of timestamp without time zone NOT NULL DEFAULT now()
reason reasons NOT NULL
port_id bigint NOT NULL
public.vlans.vlan_id vlan_id bigint NOT NULL
old_type vlantype NOT NULL
first_time_old timestamp without time zone
last_time_old timestamp without time zone
new_type vlantype
acknowledged boolean DEFAULT false
port_vlan_logs_date_of_index date_of port_vlan_logs_port_id port_id port_vlan_logs_vlan_id vlan_id

Index - Schema public


Table: public.port_vlans

port és vlan összerendelések táblája

public.port_vlans Structure
F-Key Name Type Description
port_vlan_id bigserial PRIMARY KEY
port_id bigint UNIQUE#1
public.vlans.vlan_id vlan_id bigint UNIQUE#1
first_time timestamp without time zone DEFAULT now()
last_time timestamp without time zone DEFAULT now()
vlan_type vlantype NOT NULL DEFAULT 'untagged'::public.vlantype
set_type settype NOT NULL DEFAULT 'manual'::public.settype
flag boolean DEFAULT false
port_vlans_port_id_index port_id

Index - Schema public


View: public.portvars

public.portvars Structure
F-Key Name Type Description
portvar_id bigint
service_var_name text
service_var_note text
service_var_type_id bigint
host_service_id bigint
port_id bigint
delegate_port_state boolean
service_var_value text
var_state notifswitch
last_time timestamp without time zone
features text
raw_value text
delegate_service_state boolean
state_msg text
disabled boolean
SELECT sv.service_var_id AS portvar_id
,
    sv.service_var_name
,
    sv.service_var_note
,
    sv.service_var_type_id
,
    sv.host_service_id
,
    hs.port_id
,
    sv.delegate_port_state
,
    sv.service_var_value
,
    sv.var_state
,
    sv.last_time
,
    sv.features
,
    sv.raw_value
,
    sv.delegate_service_state
,
    sv.state_msg
,
    sv.disabled
   
FROM (service_vars sv
     
  JOIN host_services hs 
 USING (host_service_id)
)
  
WHERE (
     (NOT sv.deleted)
   AND (NOT hs.deleted)
   AND (hs.port_id IS NOT NULL)
);

Index - Schema public


Table: public.pports

Patch panel/ csatlakozók port tábla

public.pports Structure
F-Key Name Type Description
port_id bigint PRIMARY KEY DEFAULT nextval('public.nports_port_id_seq'::regclass)

Egyedi azonosító,az ősre és annak összes leszármazottjára is.
port_name text UNIQUE#2 NOT NULL

Egy eszközön belül (azonos node_id) egyedi név.
port_note text
port_tag text
public.iftypes.iftype_id iftype_id bigint
public.patchs.node_id node_id bigint UNIQUE#1 UNIQUE#2 NOT NULL
port_index integer UNIQUE#1

A port sorszáma a panelon, csatlakozón.
deleted boolean DEFAULT false
flag boolean DEFAULT false
shared_cable portshare NOT NULL DEFAULT ''::public.portshare

Ha az UTP fali kábel megosztva van bekötve. Hátlapon!
public.pports.port_id shared_port_id bigint

Melyik másik porttal van megosztva a fali kábel bekötése. Hátlapon! Az "A" ill. "AA" megosztások esetén NULL, a többi erre mutat.

Table public.pports Inherits nports,

Tables referencing this one via Foreign Key Constraints:

pports_node_id_index node_id

Index - Schema public


Table: public.query_parsers

public.query_parsers Structure
F-Key Name Type Description
query_parser_id bigserial PRIMARY KEY
query_parser_note text
public.services.service_id service_id bigint NOT NULL
parse_type parsertype DEFAULT 'parse'::public.parsertype
item_sequence_number integer NOT NULL
regexp_attr regexpattr[] DEFAULT '{exactmatch}'::regexpattr[]
regular_expression text NOT NULL
import_expression text NOT NULL

 

public.query_parsers Constraints
Name Constraint
check_expression CHECK ((((parse_type = 'parse'::parsertype) AND (regular_expression IS NOT NULL)) OR ((parse_type <> 'parse'::parsertype) AND (regular_expression IS NULL))))

Index - Schema public


Table: public.rrd_beats

public.rrd_beats Structure
F-Key Name Type Description
rrd_beat_id bigserial PRIMARY KEY
rrd_beat_name text UNIQUE NOT NULL
rrd_beat_note text
step interval NOT NULL
heartbeat interval NOT NULL
daily_step integer
daily_size integer
daily_aggregates aggregatetype[] NOT NULL DEFAULT ARRAY[]::public.aggregatetype[]
weekly_step integer
weekly_size integer
weekly_aggregates aggregatetype[] NOT NULL DEFAULT ARRAY[]::public.aggregatetype[]
monthly_step integer
monthly_size integer
monthly_aggregates aggregatetype[] NOT NULL DEFAULT ARRAY[]::public.aggregatetype[]
yearly_step integer
yearly_size integer
yearly_aggregates aggregatetype[] NOT NULL DEFAULT ARRAY[]::public.aggregatetype[]
features text
deleted boolean NOT NULL DEFAULT false

 

public.rrd_beats Constraints
Name Constraint
rrd_beats_check CHECK ((heartbeat > step))
rrd_beats_check1 CHECK (((daily_aggregates = ARRAY[]::aggregatetype[]) = (daily_step IS NULL)))
rrd_beats_check2 CHECK (((weekly_aggregates = ARRAY[]::aggregatetype[]) = (weekly_step IS NULL)))
rrd_beats_check3 CHECK (((monthly_aggregates = ARRAY[]::aggregatetype[]) = (monthly_step IS NULL)))
rrd_beats_check4 CHECK (((yearly_aggregates = ARRAY[]::aggregatetype[]) = (yearly_step IS NULL)))
rrd_beats_daily_size_check CHECK ((daily_size > 0))
rrd_beats_daily_step_check CHECK ((daily_step > 0))
rrd_beats_monthly_size_check CHECK ((monthly_size > 0))
rrd_beats_monthly_step_check CHECK ((monthly_step > 0))
rrd_beats_step_check CHECK ((date_part('epoch'::text, step) > (10)::double precision))
rrd_beats_weekly_size_check CHECK ((weekly_size > 0))
rrd_beats_weekly_step_check CHECK ((weekly_step > 0))
rrd_beats_yearly_size_check CHECK ((yearly_size > 0))
rrd_beats_yearly_step_check CHECK ((yearly_step > 0))

Tables referencing this one via Foreign Key Constraints:

Index - Schema public


Table: public.selects

public.selects Structure
F-Key Name Type Description
select_id bigserial PRIMARY KEY
select_type text UNIQUE#1 NOT NULL
select_note text
precedence integer UNIQUE#1 NOT NULL
pattern text NOT NULL
pattern_type patterntype NOT NULL
choice text NOT NULL
features text
selects_select_type_index select_type

Index - Schema public


Table: public.service_rrd_vars

public.service_rrd_vars Structure
F-Key Name Type Description
service_var_id bigint PRIMARY KEY DEFAULT nextval('service_vars_service_var_id_seq'::regclass)
service_var_name text UNIQUE#1 NOT NULL
service_var_note text
public.service_var_types.service_var_type_id service_var_type_id bigint NOT NULL
public.host_services.host_service_id host_service_id bigint UNIQUE#1 NOT NULL
service_var_value text
var_state notifswitch DEFAULT 'unknown'::notifswitch
last_time timestamp without time zone
features text
deleted boolean NOT NULL DEFAULT false
raw_value text
delegate_service_state boolean NOT NULL DEFAULT false
state_msg text
delegate_port_state boolean NOT NULL DEFAULT false
disabled boolean NOT NULL DEFAULT false
flag boolean NOT NULL DEFAULT false
rarefaction integer DEFAULT 1
public.host_services.host_service_id rrdhelper_id bigint
public.rrd_beats.rrd_beat_id rrd_beat_id bigint
rrd_disabled boolean NOT NULL DEFAULT false

Table public.service_rrd_vars Inherits service_vars,

 

public.service_rrd_vars Constraints
Name Constraint
service_rrd_vars_check CHECK ((rrd_disabled OR ((rrdhelper_id IS NOT NULL) AND (rrd_beat_id IS NOT NULL))))

Index - Schema public


Table: public.service_types

A service objektumok csoportosítását teszi lehetővé, egy rekord csak egy csoportba tartozhat./ Ez mire kellett ? Lehet, hogy törölni kéne.

public.service_types Structure
F-Key Name Type Description
service_type_id bigserial PRIMARY KEY

service csoport ill. típus azonosító.
service_type_name text UNIQUE

service csoport ill. típus név.
service_type_note text

Megjegyzés.

Tables referencing this one via Foreign Key Constraints:

Index - Schema public


Table: public.service_var_types

public.service_var_types Structure
F-Key Name Type Description
service_var_type_id bigserial PRIMARY KEY
service_var_type_name text UNIQUE NOT NULL
service_var_type_note text
public.param_types.param_type_id param_type_id bigint NOT NULL
service_var_type servicevartype
plausibility_type filtertype
plausibility_param1 text
plausibility_param2 text
warning_type filtertype
warning_param1 text
warning_param2 text
critical_type filtertype
critical_param1 text
critical_param2 text
features text
deleted boolean NOT NULL DEFAULT false
plausibility_inverse boolean NOT NULL DEFAULT false
warning_inverse boolean NOT NULL DEFAULT false
critical_inverse boolean NOT NULL DEFAULT false
public.param_types.param_type_id raw_param_type_id bigint NOT NULL

A host_service_vars.raw_value adat típusa, ami nem feltétlenül azonos a változó típusával.
raw_to_rrd boolean

Tables referencing this one via Foreign Key Constraints:

Index - Schema public


Table: public.service_vars

public.service_vars Structure
F-Key Name Type Description
service_var_id bigserial PRIMARY KEY
service_var_name text UNIQUE#1 NOT NULL
service_var_note text
public.service_var_types.service_var_type_id service_var_type_id bigint NOT NULL
public.host_services.host_service_id host_service_id bigint UNIQUE#1 NOT NULL
service_var_value text
var_state notifswitch DEFAULT 'unknown'::public.notifswitch
last_time timestamp without time zone
features text
deleted boolean NOT NULL DEFAULT false
raw_value text
delegate_service_state boolean NOT NULL DEFAULT false
state_msg text
delegate_port_state boolean NOT NULL DEFAULT false
disabled boolean NOT NULL DEFAULT false
flag boolean NOT NULL DEFAULT false
rarefaction integer DEFAULT 1

Tables referencing this one via Foreign Key Constraints:

service_vars_host_service_id_index host_service_id

Index - Schema public


Table: public.services

Services table

public.services Structure
F-Key Name Type Description
service_id bigserial PRIMARY KEY

ID egyedi azonosító
service_name text UNIQUE NOT NULL

Szervice name (egyedi)
service_note text

Megjegyzés
public.service_types.service_type_id service_type_id bigint DEFAULT '-1'::integer
port integer

Default (TCP, UDP, ...) port number. or NULL
superior_service_mask text
check_cmd text

Default check command
features text DEFAULT ':'::text

Default paraméter lista (szeparátor a kettőspont, paraméter szeparátor az '=', első és utolsó karakter a szeparátor):\n timing custom Belső időzítés (alapértelmezett) timed Időzített thread Saját szál timed,thread Időzített saját szállal passive Valamilyen lekérdezés (superior) járulékos eredményeként van állpota, vagy csak az alárendelteket indítja, önálló tevékenység nélkül. polling Egyszeri futás process Az szolgáltatás ellenörzése egy program, paraméterek: respawn A programot újra kell indítani, ha kilép. A kilépés nem hiba.\n continue A program normál körülmények között nem lép ki, csak ha leállítják, vagy hiba van. (default) polling A programot egyszer kell inditani, elvégzi a dolgát és kilép. Nincs időzítés vagy újraindítás timed A programot időzitve kell indítani (periódikusan) carried A program önállóan állítja a statusát, a fenzi opciókkal együtt adható meg. superior Alárendelteket ellenörző eljárásokat hív <üres> Alárendelt viszony,autómatikus method custom saját/ismeretlen (alapérte,mezett) nagios Egy Nagios plugin munin Egy Munin plugin qparser query parser parser Parser szülö, ha a parser önálló szálban fut. carried Önálló (csak akkor kell adminisztrállni, ha kiakadt) ifType A szolgáltatás hierarhia mely port típus linkjével azonos (paraméter: interface típus neve) disabled service_name = icontsrv , csak a host_services rekordban, a szolgáltatás (riasztás) tiltva. reversed service_name = icontsrv , csak a host_services rekordban, a port fordított bekötését jelzi. serial Serial port paraméterei pl.: "serial=19200 7E1 No" logrot Log az stderr-re, log fájlt a superior kezeli. Log fájl rotálása (par1: max méret, par2: arhiv [db]) lognull A superior az stderr és stdout-ot a null-ba irányítja. A szolgáltatás önállóan loggol. tcp Alternatív TCP port megadása, paraméter a port száma udp Alternatív UDP port megadása, paraméter a port száma
disabled boolean NOT NULL DEFAULT false
max_check_attempts integer

Hibás eredmények maximális száma, a riasztás kiadása elött. Alapértelmezett érték.
normal_check_interval interval

Ellenörzések ütemezése, ha nincs hiba. Alapértelmezett érték.
retry_check_interval interval

Ellenörzések ütemezése, hiba esetén a riasztás kiadásáig. Alapértelmezett érték.
public.timeperiods.timeperiod_id timeperiod_id bigint NOT NULL
flapping_interval interval NOT NULL DEFAULT '00:30:00'::interval
flapping_max_change integer NOT NULL DEFAULT 15
deleted boolean NOT NULL DEFAULT false
offline_group_ids bigint[]
online_group_ids bigint[]
heartbeat_time interval

Tables referencing this one via Foreign Key Constraints:

Index - Schema public


Table: public.snmpdevices

public.snmpdevices Structure
F-Key Name Type Description
node_id bigint PRIMARY KEY DEFAULT nextval('public.patchs_node_id_seq'::regclass)
node_name text UNIQUE NOT NULL
node_note text
node_type nodetype[]
public.places.place_id place_id bigint
features text
deleted boolean NOT NULL DEFAULT false
inventory_number text
serial_number text
model_number text
model_name text
location point
node_stat notifswitch NOT NULL DEFAULT 'unknown'::public.notifswitch
os_name text
os_version text
community_rd text NOT NULL DEFAULT 'public'::text
community_wr text
snmp_ver snmpver NOT NULL DEFAULT '2c'::public.snmpver
sysdescr text
sysobjectid text
sysuptime bigint
syscontact text
sysname text
syslocation text
sysservices smallint
vendorname text

Table public.snmpdevices Inherits nodes,

Index - Schema public


Table: public.subnets

Alhálózatok táblája.

public.subnets Structure
F-Key Name Type Description
subnet_id bigserial PRIMARY KEY

Alhálózat egyedi azonosító.
subnet_name text UNIQUE NOT NULL

Az alhálózat egyedi neve.
subnet_note text

Az alhálózat leírása, ill. megjegyzés
netaddr cidr NOT NULL

A hálózati cím és maszk.
public.vlans.vlan_id vlan_id bigint

A VLAN azonosítója, ha az alhálózat VLAN-hoz rendelhető.
subnet_type subnettype NOT NULL DEFAULT 'primary'::public.subnettype

Az alhálózat típusa.

Tables referencing this one via Foreign Key Constraints:

Index - Schema public


Table: public.sys_params

public.sys_params Structure
F-Key Name Type Description
sys_param_id bigserial PRIMARY KEY
sys_param_name text UNIQUE NOT NULL
sys_param_note text
public.param_types.param_type_id param_type_id bigint NOT NULL
param_value text

Index - Schema public


Table: public.table_shape_fields

Tábla shape oszlop leíró tábla

public.table_shape_fields Structure
F-Key Name Type Description
table_shape_field_id bigserial PRIMARY KEY

Egyedi azonosító ID
table_shape_field_name text UNIQUE#1 NOT NULL

Column name.
table_shape_field_note text

A mező dialog box-ban megjelenő neve
public.table_shapes.table_shape_id table_shape_id bigint UNIQUE#1 NOT NULL

Távoli kulcs a tulajdonos rekordra.
field_sequence_number integer NOT NULL

A mező sorrendje a táblázatban / dialog boxban
ord_types ordtype[]

A mező rendezési lehetőségei
ord_init_type ordtype DEFAULT 'no'::public.ordtype

Opcionális, a mező érték szerinti rendezés alap beállítása.
ord_init_sequence_number integer

Opcionális, a mező érték szerinti rendezés alap sorrendje.
field_flags fieldflag[] DEFAULT '{}'::public.fieldflag[]

A mező fleg-ek
default_value text

Egy opcionális default érték.
features text

További paraméterek.
view_rights rights

Minimális jogosultsági szint a mező megtekintéséhez, NULL esetén a táblánál magadottak az érvényesek
edit_rights rights

Minimális jogosultsági szint a mező szerkestéséhez, NULL esetén a táblánál magadottak az érvényesek
flag boolean DEFAULT false
text_id bigint NOT NULL DEFAULT nextval('public.text_id_sequ'::regclass)
table_field_name text NOT NULL

Table field name (using of query).
icon text

Column header icon name

Index - Schema public


Table: public.table_shapes

Tábla megjelenítő lírók (Qt GUI) táblája

public.table_shapes Structure
F-Key Name Type Description
table_shape_id bigserial PRIMARY KEY

Egyedi azonosító ID
table_shape_name text UNIQUE NOT NULL

A shape neve, egyedi azonosító
table_shape_note text

A shape leírása ill. megjegyzés.
table_shape_type tableshapetype[] DEFAULT '{simple}'::public.tableshapetype[]

A megjelenítés típusa.
table_name text NOT NULL

A shape álltal megjelenítendő tábla neve
schema_name text NOT NULL DEFAULT 'public'::text
table_inherit_type tableinherittype DEFAULT 'no'::public.tableinherittype
inherit_table_names text[]
refine text

Egy opcionális feltétel, ha a táblának csak egy részhalmaza kell (WHERE clause)
features text

További paraméterek.
right_shape_ids bigint[]

A jobb oldali, gyerek, vagy csoport táblákat megjelenítő leírókra mutatnak az elemei
auto_refresh interval
view_rights rights DEFAULT 'viewer'::public.rights

Minimális jogosultsági szint a táblába megtekintéséhez
edit_rights rights DEFAULT 'operator'::public.rights

Minimális jogosultsági szint a tábábla szerkesztéséhez
insert_rights rights DEFAULT 'operator'::public.rights

Minimális jogosultsági szint a táblába való beszúráshoz
remove_rights rights DEFAULT 'admin'::public.rights

Minimális jogosultsági szint a tábából való törléshez
style_sheet text
text_id bigint NOT NULL DEFAULT nextval('public.text_id_sequ'::regclass)

Tables referencing this one via Foreign Key Constraints:

Index - Schema public


Table: public.timeperiod_tpows

Time periods and tpows kapcsoló tábla

public.timeperiod_tpows Structure
F-Key Name Type Description
timeperiod_tpow_id bigserial PRIMARY KEY
public.tpows.tpow_id tpow_id bigint UNIQUE#1

Unique ID
public.timeperiods.timeperiod_id timeperiod_id bigint UNIQUE#1

Unique ID

Index - Schema public


Table: public.timeperiods

Time periods

public.timeperiods Structure
F-Key Name Type Description
timeperiod_id bigserial PRIMARY KEY

Unique ID
timeperiod_name text UNIQUE NOT NULL

Unique name for time periods
timeperiod_note text

Tables referencing this one via Foreign Key Constraints:

Index - Schema public


Table: public.tpows

One time period of week

public.tpows Structure
F-Key Name Type Description
tpow_id bigserial PRIMARY KEY

Unique ID
tpow_name text UNIQUE NOT NULL

Unique name for time intervall of week
tpow_note text
dow dayofweek NOT NULL

Day of week
begin_time time without time zone NOT NULL DEFAULT '00:00:00'::time without time zone

Begin time
end_time time without time zone NOT NULL DEFAULT '24:00:00'::time without time zone

End time

Tables referencing this one via Foreign Key Constraints:

Index - Schema public


Table: public.unusual_fkeys

Az öröklödéshez kapcsolódó távoli kulcsok definíciói

public.unusual_fkeys Structure
F-Key Name Type Description
unusual_fkey_id bigserial PRIMARY KEY
table_schema text UNIQUE#1 NOT NULL DEFAULT 'public'::text

A tábla séma neve, melyben a hivatkozó mezőt definiáljuk
table_name text UNIQUE#1 NOT NULL

A tábla neve, melyben a hivatkozó mezőt definiáljuk
column_name text UNIQUE#1 NOT NULL

A hivatkozó/mutató mező neve
unusual_fkeys_type unusualfkeytype NOT NULL DEFAULT 'property'::public.unusualfkeytype

A hivatkozás típusa
f_table_schema text NOT NULL DEFAULT 'public'::text

A hivatkozott tábla elsődleges kulcsmezóje, ill. a hivatkozott mező
f_table_name text NOT NULL

A hivatkozott tábla neve
f_column_name text NOT NULL
f_inherited_tables text[]

Azon leszármazott táblák nevei, melyekre még vonatkozhat a hivatkozás (a séma név azonos)

Index - Schema public


Table: public.user_events

public.user_events Structure
F-Key Name Type Description
user_event_id bigserial PRIMARY KEY
created timestamp without time zone NOT NULL DEFAULT now()
happened timestamp without time zone
public.users.user_id user_id bigint UNIQUE#1 NOT NULL
public.alarms.alarm_id alarm_id bigint UNIQUE#1 NOT NULL
event_type usereventtype UNIQUE#1 NOT NULL
event_state usereventstate DEFAULT 'necessary'::public.usereventstate
user_event_note text
user_events_alarm_id_event_type_index alarm_id, event_type user_events_created_index created user_events_happened_index happened

Index - Schema public


Table: public.users

Users and contact table

public.users Structure
F-Key Name Type Description
user_id bigserial PRIMARY KEY
user_name text UNIQUE NOT NULL
user_note text
passwd text
domain_users text[]
first_name text
last_name text
language text
tels text[]
addresses text[]
public.places.place_id place_id bigint
expired date
enabled boolean DEFAULT true
features text
public.timeperiods.timeperiod_id host_notif_period bigint
public.timeperiods.timeperiod_id serv_notif_period bigint
host_notif_switchs notifswitch[] NOT NULL DEFAULT '{unreachable,down,recovered,unknown,critical}'::public.notifswitch[]
serv_notif_switchs notifswitch[] NOT NULL DEFAULT '{unreachable,down,recovered,unknown,critical}'::public.notifswitch[]
host_notif_cmd text
serv_notif_cmd text

Tables referencing this one via Foreign Key Constraints:

Index - Schema public


View: public.vlan_list_by_host

public.vlan_list_by_host Structure
F-Key Name Type Description
node_id bigint
vlan_id bigint
node_name text
vlan_name text
vlan_note text
vlan_stat boolean
SELECT DISTINCT nports.node_id
,
    port_vlans.vlan_id
,
    nodes.node_name
,
    vlans.vlan_name
,
    vlans.vlan_note
,
    vlans.vlan_stat
   
FROM (
     (
           (port_vlans
     
              JOIN nports 
             USING (port_id)
           )
     
        JOIN vlans 
       USING (vlan_id)
     )
     
  JOIN nodes 
 USING (node_id)
);

Index - Schema public


Table: public.vlans

VLANs Table

public.vlans Structure
F-Key Name Type Description
vlan_id bigint PRIMARY KEY

Unique ID for vlans. (802,1q ID)
vlan_name text UNIQUE NOT NULL

Name of VLAN
vlan_note text

Description for VLAN
vlan_stat boolean NOT NULL DEFAULT true

State of VLAN (On/Off)
flag boolean DEFAULT false

Tables referencing this one via Foreign Key Constraints:

Index - Schema public


Function: public.add_member_to_all_group()

Returns: trigger

Language: PLPERL

Létrehoz egy kapcsoló tábla rekordot, egy group ás tag között (ha az INSERT-ben valamelyik szabály nem teljesül, akkor nem csinál semmit). Vagyis egy megadott objektumot betesz egy megadott csoportba Paraméterek (sorrendben): $table tábla név, A kapcsoló tábla neve, $midname a member azonosító (id) neve a kapcsoló, és a member táblában (feltételezzük, hogy azonos), $gidname a group azonosító (id) neve a kapcsoló táblában, $gid a group azonisítója (id)

    ($table, $midname, $gidname, $gid) = @{$_TD->{args}};
    $mid = $_TD->{new}->{$midname};
    spi_exec_query("INSERT INTO $table ($gidname, $midname) VALUES ( $gid, $mid) ON CONFLICT DO NOTHING");
    return;

Function: public.alarm_id2name(bigint)

Returns: text

Language: PLPGSQL

DECLARE
    rname TEXT;
BEGIN
    IF $1 IS NULL THEN
        return NULL;
    END IF;
    SELECT alarm_message(host_service_id, max_status) INTO rname FROM alarms WHERE alarm_id = $1;
    IF NOT FOUND THEN
        rname := 'not found'; 
    END IF;
    RETURN rname || ' / #' || $1;
END;

Function: public.alarm_message(st bigint, sid public.notifswitch)

Returns: text

Language: PLPGSQL

DECLARE
    msg         text DEFAULT NULL;
    hs          host_services;
    s           services;
    n           nodes;
    pl          places;
    lid		integer;
    tid         bigint DEFAULT NULL;         -- text id
BEGIN
    SELECT * INTO hs FROM host_services WHERE host_service_id = sid;
    IF NOT FOUND THEN
        RETURN '#' || sid::text || ' deleted or invalid service is ' || st::text;
    END IF;
    
    SELECT * INTO s FROM services WHERE service_id = hs.service_id;
    IF NOT FOUND THEN
        s.service_name := 'unknown';
    ELSE
        SELECT text_id INTO tid FROM alarm_messages WHERE service_type_id = s.service_type_id AND status = st;
    END IF;
    -- RAISE INFO 'text_id = %', tid;
    IF tid IS NOT NULL THEN
	lid = get_language_id();
	-- RAISE INFO 'Get text, lid = %', lid;
        SELECT texts[1] INTO msg FROM localizations WHERE text_id = tid AND table_for_text = 'alarm_messages' AND language_id = lid;
        IF NOT FOUND THEN
            -- RAISE INFO 'localization (%) text (%) not found', lid, tid;
            msg := COALESCE(
                (SELECT texts[1] FROM localizations WHERE text_id = tid AND table_for_text = 'alarm_messages' AND language_id = get_int_sys_param('default_language')),
                (SELECT texts[1] FROM localizations WHERE text_id = tid AND table_for_text = 'alarm_messages' AND language_id = get_int_sys_param('failower_language')));
        END IF;
    END IF;
    IF msg IS NULL THEN
	-- RAISE INFO 'localization text not found, set default';
        -- msg := '$hs.name is $st';
        RETURN host_service_id2name(sid) || ' is ' || st;
    END IF;

    msg := replace(msg, '$st', st::text);
    IF msg LIKE '%$hs.%' THEN 
        IF msg LIKE '%$hs.name%' THEN
            msg := replace(msg, '$hs.name',  host_service_id2name(sid));
        END IF;
        msg := replace(msg, '$hs.note',  COALESCE(hs.host_service_note, ''));
    END IF;

    IF msg LIKE '%$s.%' THEN 
        msg := replace(msg, '$s.name',   s.service_name);
        msg := replace(msg, '$s.note',   COALESCE(s.service_note, ''));
    END IF;

    IF msg LIKE '%$n.%' OR msg LIKE '%$pl.%' THEN
        SELECT * INTO n FROM nodes WHERE node_id = hs.node_id;
        IF NOT FOUND THEN
            msg := replace(msg, '$n.name',     'unknown');
            msg := replace(msg, '$n.note',     '');
            msg := replace(msg, '$pl.name',    'unknown');
            msg := replace(msg, '$pl.note',    '');
            RETURN msg;
        END IF;
        IF msg LIKE '%$n.%' THEN
            msg := replace(msg, '$n.name',     n.node_name);
            msg := replace(msg, '$n.note',     COALESCE(n.node_note, ''));
        END IF;
        IF msg LIKE '%$pl.%' THEN
            SELECT * INTO pl FROM placess WHERE place_id = n.place_id;
            IF NOT FOUND THEN
                msg := replace(msg, '$pl.name','unknown');
                msg := replace(msg, '$pl.note','');
            ELSE
                msg := replace(msg, '$pl.name',pl.place_name);
                msg := replace(msg, '$pl.note',COALESCE(pl.place_note, ''));
            END IF;
        END IF;
    END IF;
    RETURN msg;
END

Function: public.alarm_notice()

Returns: trigger

Language: PLPGSQL

DECLARE
    sup_alarm_pending boolean := false;
BEGIN
    IF NEW.host_service_id <> 0                 -- is not ticket alarm
    AND NEW.superior_alarm_id IS NOT NULL THEN  -- sup. alarm is exists
        IF (SELECT end_time FROM alarms WHERE alarm_id = NEW.superior_alarm_id) IS NULL THEN
            sup_alarm_pending := true;  -- no events
        END IF;
    END IF; 
    IF NOT sup_alarm_pending THEN
        -- on-line events
        UPDATE user_events SET event_state = 'dropped'
            WHERE alarm_id IN ( SELECT alarm_id FROM alarms WHERE host_service_id = NEW.host_service_id)
                AND event_state = 'necessary';

        WITH uids AS (
            SELECT DISTINCT user_id
                FROM group_users
                WHERE group_id = ANY (
                    SELECT unnest(COALESCE(hs.online_group_ids, s.online_group_ids))
                        FROM host_services AS hs JOIN services AS s USING(service_id)
                        WHERE host_service_id = NEW.host_service_id)
        ) INSERT INTO user_events(user_id, alarm_id, event_type) SELECT user_id, NEW.alarm_id, 'notice'::usereventtype FROM uids;
        -- off-line events
        WITH uids AS (
            SELECT DISTINCT user_id
                FROM group_users
                WHERE group_id = ANY (
                    SELECT unnest(COALESCE(hs.offline_group_ids, s.offline_group_ids))
                        FROM host_services AS hs JOIN services AS s USING(service_id)
                        WHERE host_service_id = NEW.host_service_id)
        ) INSERT INTO user_events(user_id, alarm_id, event_type) SELECT user_id, NEW.alarm_id, 'sendmail'::usereventtype FROM uids;
    END IF;
    -- save actual value for connecting service variables 
    INSERT INTO alarm_service_vars(alarm_id, service_var_id, service_var_value, var_state, state_msg, raw_value)
        SELECT NEW.alarm_id, service_var_id, service_var_value, var_state, state_msg, raw_value FROM service_vars WHERE host_service_id = NEW.host_service_id;
    -- notify
    IF NOT sup_alarm_pending THEN
        NOTIFY alarm;
    END IF;
    RETURN NEW;
END;

Function: public.app_err_id2name(bigint)

Returns: text

Language: PLPGSQL

DECLARE
    name TEXT;
BEGIN
    IF $1 IS NULL THEN
        return NULL;
    END IF;
    SELECT app_name || ':' || err_name INTO name
        FROM app_errs
        WHERE applog_id = $1;
    IF NOT FOUND THEN
        PERFORM error('IdNotFound', $1, 'applog_id', 'app_err_id2name()', 'app_errs');
    END IF;
    RETURN name;
END;

Function: public.armor(bytea)

Returns: text

Language: C

pg_armor

Function: public.armor(bytea, text[], text[])

Returns: text

Language: C

pg_armor

Function: public.arp_remove(re public.arps, a public.reasons)

Returns: void

Language: PLPGSQL

Törli a megadott rekordot az arps táblából. Paraméterek a A törlendő rekord. re A log rekordba irandó ok, alapértelmezetten ez a "remove". Nincs visszatérési érték.

BEGIN
    INSERT INTO
        arp_logs(reason, ipaddress,  hwaddress_old, set_type_old, host_service_id_old, first_time_old, last_time_old)
        VALUES(  re,     a.ipaddress,a.hwaddress,   a.set_type,   a.host_service_id,   a.first_time,   a.last_time);
    DELETE FROM arps WHERE ipaddress = a.ipaddress;
END;

Function: public.cast_to_bigint(text, bigint)

Returns: bigint

Language: PLPGSQL

BEGIN
    RETURN cast($1 as bigint);
EXCEPTION
    WHEN invalid_text_representation THEN
        RETURN $2;
END;

Function: public.cast_to_boolean(text, boolean)

Returns: boolean

Language: PLPGSQL

BEGIN
    RETURN COALESCE(cast($1 as boolean), $2);
EXCEPTION
    WHEN invalid_text_representation THEN
        RETURN $2;
END;

Function: public.cast_to_cidr(text, cidr)

Returns: cidr

Language: PLPGSQL

BEGIN
    RETURN COALESCE(cast($1 as cidr), $2);
EXCEPTION
    WHEN invalid_text_representation THEN
        RETURN $2;
END;

Function: public.cast_to_date(text, date)

Returns: date

Language: PLPGSQL

BEGIN
    RETURN COALESCE(cast($1 as date), $2);
EXCEPTION
    WHEN invalid_datetime_format THEN
        RETURN $2;
END;

Function: public.cast_to_datetime(text, timestamp without time zone)

Returns: timestamp without time zone

Language: PLPGSQL

BEGIN
    RETURN COALESCE(cast($1 as timestamp), $2);
EXCEPTION
    WHEN invalid_datetime_format THEN
        RETURN $2;
END;

Function: public.cast_to_double(text, double precision)

Returns: double precision

Language: PLPGSQL

BEGIN
    RETURN cast($1 as double precision);
EXCEPTION
    WHEN invalid_text_representation THEN
        RETURN $2;
END;

Function: public.cast_to_inet(text, inet)

Returns: inet

Language: PLPGSQL

BEGIN
    RETURN COALESCE(cast($1 as inet), $2);
EXCEPTION
    WHEN invalid_text_representation THEN
        RETURN $2;
END;

Function: public.cast_to_integer(text, bigint)

Returns: bigint

Language: PLPGSQL

BEGIN
    RETURN COALESCE(cast($1 as bigint), $2);
EXCEPTION
    WHEN invalid_text_representation THEN
        RETURN $2;
END;

Function: public.cast_to_interval(text, interval)

Returns: interval

Language: PLPGSQL

BEGIN
    RETURN COALESCE(cast($1 as interval), $2);
EXCEPTION
    WHEN invalid_datetime_format THEN
        RETURN $2;
END;

Function: public.cast_to_mac(text, macaddr)

Returns: macaddr

Language: PLPGSQL

BEGIN
    RETURN COALESCE(cast($1 as macaddr), $2);
EXCEPTION
    WHEN invalid_text_representation THEN
        RETURN $2;
END;

Function: public.cast_to_point(text, point)

Returns: point

Language: PLPGSQL

BEGIN
    RETURN COALESCE(cast($1 as point), $2);
EXCEPTION
    WHEN invalid_text_representation THEN
        RETURN $2;
END;

Function: public.cast_to_real(text, double precision)

Returns: double precision

Language: PLPGSQL

BEGIN
    RETURN COALESCE(cast($1 as double precision), $2);
EXCEPTION
    WHEN invalid_text_representation THEN
        RETURN $2;
END;

Function: public.cast_to_time(text, time without time zone)

Returns: time without time zone

Language: PLPGSQL

BEGIN
    RETURN COALESCE(cast($1 as time), $2);
EXCEPTION
    WHEN invalid_datetime_format THEN
        RETURN $2;
END;

Function: public.check_after_localization_text()

Returns: trigger

Language: PLPGSQL

DECLARE
    n integer;
BEGIN
    IF TG_OP = 'UPDATE' THEN
        IF NEW.text_id <> OLD.text_id THEN
            PERFORM error('Constant', OLD.text_id, NEW.text_id::text, 'text_id', TG_TABLE_NAME, TG_OP);
        END IF;
        IF NEW.table_for_text <> OLD.table_for_text THEN
            PERFORM error('Constant', NEW.text_id, OLD.table_for_text || ' - ' || NEW.table_for_text, 'table_for_text', TG_TABLE_NAME, TG_OP);
        END IF;
    END IF;
    EXECUTE 'SELECT count(*) FROM ' || NEW.table_for_text || ' WHERE text_id = $1'
        INTO n
        USING NEW.text_id;
    IF n <> 1  THEN
        IF n > 1 THEN
            PERFORM error('IdNotUni', NEW.text_id, NEW.table_for_text::text || ' #' || n, 'table_for_text', TG_TABLE_NAME, TG_OP);
        ELSE
            PERFORM error('IdNotFound', NEW.text_id, NEW.table_for_text::text, 'table_for_text', TG_TABLE_NAME, TG_OP);
        END IF;
        RETURN NULL;
    END IF;
    RETURN NEW;
END;

Function: public.check_alarm_service_vars()

Returns: trigger

Language: PLPGSQL

BEGIN
    IF TG_OP = 'UPDATE' AND NEW.service_var_id < 0 THEN -- convert: service_vars -> service_rrd_vars, intermediate state
        RETURN NEW;
    END IF;
    IF 0 = COUNT(*) FROM service_vars WHERE service_var_id = NEW.service_var_id THEN
        PERFORM error('IdNotFound', NEW.service_var_id, 'service_var_id', 'check_alarm_service_vars()', TG_TABLE_NAME, TG_OP);
        RETURN NULL;
    END IF;
    RETURN NEW;
END;

Function: public.check_before_param_value()

Returns: trigger

Language: PLPGSQL

DECLARE
    pt  paramtype;
BEGIN
    SELECT param_type_type INTO pt FROM param_types WHERE param_type_id = NEW.param_type_id;
    NEW.param_value = check_paramtype(NEW.param_value, pt);
    RETURN NEW;
END;

Function: public.check_before_service_value()

Returns: trigger

Language: PLPGSQL

DECLARE
    tids record;
    pt   paramtype;
BEGIN
    IF TG_OP = 'INSERT' THEN
        IF 0 < COUNT(*) FROM service_vars WHERE service_var_id = NEW.service_var_id THEN
            PERFORM error('IdNotUni', NEW.service_var_id, 'service_var_id', 'check_before_service_value()', TG_TABLE_NAME, TG_OP);
            RETURN NULL;
        END IF;
        IF 0 < COUNT(*) FROM service_vars WHERE service_var_name = NEW.service_var_name AND host_service_id = NEW.host_service_id THEN
            PERFORM error('IdNotUni', NEW.service_var_id, 'service_var_name', 'check_before_service_value()', TG_TABLE_NAME, TG_OP);
            RETURN NULL;
        END IF;
        IF TG_TABLE_NAME = 'service_rrd_vars' THEN
            IF (SELECT raw_to_rrd FROM service_var_types WHERE service_var_type_id = NEW.service_var_type_id) IS NULL THEN
                PERFORM error('NotNull', NEW.service_var_type_id, 'service_var_types.raw_to_rrd', 'check_before_service_value()', TG_TABLE_NAME, TG_OP);
                RETURN NULL;
            END IF;
        END IF;
    ELSIF TG_OP = 'UPDATE' THEN
        IF OLD.service_var_id <> NEW.service_var_id THEN
            PERFORM error('Constant', OLD.service_var_id, 'service_var_id', 'check_before_service_value()', TG_TABLE_NAME, TG_OP);
            RETURN NULL;
        END IF;
        IF OLD.service_var_name <> NEW.service_var_name THEN
            IF COUNT(*) FROM service_vars WHERE service_var_name = NEW.service_var_name AND host_service_id = NEW.host_service_id THEN
                PERFORM error('IdNotUni', NEW.service_var_id, 'service_var_name', 'check_before_service_value()', TG_TABLE_NAME, TG_OP);
                RETURN NULL;
            END IF;
        END IF;
    ELSIF TG_OP = 'DELETE' THEN
        DELETE FROM alarm_service_vars WHERE service_var_id = OLD.service_var_id;
        RETURN OLD;
    END IF;
    SELECT param_type_id, raw_param_type_id INTO tids FROM service_var_types WHERE service_var_type_id = NEW.service_var_type_id;
    IF NEW.service_var_value IS NOT NULL THEN
        SELECT param_type_type INTO pt FROM param_types WHERE param_type_id = tids.param_type_id;
        NEW.service_var_value := check_paramtype(NEW.service_var_value, pt);
    END IF;
    IF NEW.raw_value IS NOT NULL THEN
        SELECT param_type_type INTO pt FROM param_types WHERE param_type_id = tids.raw_param_type_id;
        NEW.raw_value         := check_paramtype(NEW.raw_value, pt);
    END IF;
    RETURN NEW;
END;

Function: public.check_host_services()

Returns: trigger

Language: PLPGSQL

A host_services rekord ellenörző trigger függvény: A rekord ID-t nem engedi modosítani. Ellenörzi, hogy a node_id valóban egy nodes vagy snmpdevices rekordot azonosít-e, kivéve UPDATE esetén, ha a node_id mező előjelet vált (a node ideiglenes törlését jelzi). Ha port_id nem NULL, ellenörzi, hogy a node_id álltal azonosított objektum portja-e. Ellenörzi a noalarm_flag, noalarm_from és noalarm_to mezők konzisztenciáját. Ha a két időadat közöl valamelyik, felesleges, akkor törli azt, ha hiányos akkor kizárást generál. Ha az idöadatok alapján a noalarm_flag már lejárt, akkor a noalarm_flag "off" lessz, és törli mindkét időadatot. Insert esetén, ha a superior_host_service_host_name értéke NULL, akkor egy find_superior() hívással megkísérli kitölteni azt. Ha a superior_host_service_host_name értéke nem NULL, és rekord beszúrás történt, vagy superior_host_service_host_name megváltozott, akkor ellenörzi, hogy megfelel-e a services.superior_service_mask -mintának a hivatkozott szervíz neve.

DECLARE
    id      bigint;
    msk     text;
    sn      text;
    cset    boolean   := FALSE;
    nulltd  timestamp := '2000-01-01 00:00';
BEGIN
    IF TG_OP = 'UPDATE' THEN
        IF OLD.node_id = - NEW.node_id THEN -- Temporary deletion of owner, no check
            RETURN NEW;
        END IF;
        IF OLD.node_id = NEW.node_id AND
          (OLD.superior_host_service_id IS NOT NULL AND NEW.superior_host_service_id IS NULL) THEN
            -- Update a superior akármi törlése miatt, több rekord törlésénél előfordulhat,
            -- hogy már nincs meg a node vagy port amire a node_id ill. a prort_id mutat.
            -- késöbb ez a rekord törölve lessz, de ha hibát dobunk, akkor semmilyen törlés nem lessz.
            cset := TRUE;
        END IF;
    END IF;
    IF cset = FALSE AND NEW.port_id IS NOT NULL THEN
        -- Ha van port, az nem mutathat egy másik host portjára!
        SELECT node_id INTO id FROM nports WHERE port_id = NEW.port_id;
        IF NOT FOUND THEN
            PERFORM error('InvRef', NEW.port_id, 'port_id', 'check_host_services()', TG_TABLE_NAME, TG_OP);
            RETURN NULL;
        END IF;
        IF id <> NEW.node_id THEN
            PERFORM error('InvalidOp', NEW.port_id, 'port_id', 'check_host_services()', TG_TABLE_NAME, TG_OP);
            RETURN NULL;
        END IF;
    ELSIF cset = FALSE AND 1 <> COUNT(*) FROM nodes WHERE node_id = NEW.node_id THEN
        PERFORM error('InvRef', NEW.node_id, 'node_id', 'check_host_services()', TG_TABLE_NAME, TG_OP);
        RETURN NULL;
    END IF;
    IF TG_OP = 'UPDATE' THEN
        IF NEW.host_service_id <> OLD.host_service_id THEN
            PERFORM error('Constant', OLD.host_service_id, 'host_service_id', 'check_host_services()', TG_TABLE_NAME, TG_OP);
        END IF;
        -- change noalarm ?
        IF  NEW.noalarm_flag <> OLD.noalarm_flag
         OR COALESCE(NEW.noalarm_from, nulltd) <> COALESCE(OLD.noalarm_from, nulltd)
         OR COALESCE(NEW.noalarm_to,   nulltd) <> COALESCE(OLD.noalarm_to,   nulltd) THEN
            IF NEW.noalarm_flag = 'off' OR NEW.noalarm_flag = 'on' OR NEW.noalarm_flag = 'to' THEN
                NEW.noalarm_from = NULL;
            END IF;
            IF NEW.noalarm_flag = 'off' OR NEW.noalarm_flag = 'on' OR NEW.noalarm_flag = 'from' THEN
                NEW.noalarm_to   = NULL;
            END IF;
            IF (NEW.noalarm_flag = 'to' OR NEW.noalarm_flag = 'from_to') AND NEW.noalarm_to IS NULL THEN
                PERFORM error('NotNull', OLD.host_service_id, 'noalarm_to', 'check_host_services()', TG_TABLE_NAME, TG_OP);
                RETURN NULL;
            END IF;
            IF (NEW.noalarm_flag = 'from' OR NEW.noalarm_flag = 'from_to') AND NEW.noalarm_from IS NULL THEN
                PERFORM error('NotNull', OLD.host_service_id, 'noalarm_from', 'check_host_services()', TG_TABLE_NAME, TG_OP);
                RETURN NULL;
            END IF;
            IF ( NEW.noalarm_flag = 'from_to'                               AND NEW.noalarm_from  > NEW.noalarm_to) OR
               ((NEW.noalarm_flag = 'from_to' OR  NEW.noalarm_flag = 'to')  AND CURRENT_TIMESTAMP > NEW.noalarm_to) THEN
                PERFORM error('OutOfRange', OLD.host_service_id, 'noalarm_to', 'check_host_services()', TG_TABLE_NAME, TG_OP);
                RETURN NULL;
            END IF;
            IF  NEW.noalarm_flag <> OLD.noalarm_flag            -- Ha mégis csak azonos (modosítottunk időadatokat)
             OR COALESCE(NEW.noalarm_from, nulltd) <> COALESCE(OLD.noalarm_from, nulltd)
             OR COALESCE(NEW.noalarm_to,   nulltd) <> COALESCE(OLD.noalarm_to,   nulltd) THEN
                INSERT INTO host_service_noalarms
                    (host_service_id,     noalarm_flag,     noalarm_from,     noalarm_to,     noalarm_flag_old, noalarm_from_old, noalarm_to_old, user_id,                                     msg) VALUES
                    (NEW.host_service_id, NEW.noalarm_flag, NEW.noalarm_from, NEW.noalarm_to, OLD.noalarm_flag, OLD.noalarm_from, OLD.noalarm_to, current_setting('lanview2.user_id')::bigint, NEW.last_noalarm_msg);
            END IF;
        END IF;
    END IF;
    IF cset = FALSE THEN 
        IF TG_OP = 'INSERT' AND NEW.superior_host_service_id IS NULL THEN
            NEW := find_superior(NEW);
        ELSIF NEW.superior_host_service_id IS NOT NULL AND (TG_OP = 'INSERT' OR NEW.superior_host_service_id <> OLD.superior_host_service_id) THEN
            SELECT superior_service_mask INTO msk FROM services WHERE service_id = NEW.service_id;
            IF msk IS NOT NULL THEN
                SELECT  service_name INTO sn
                    FROM host_services JOIN services USING(service_id)
                    WHERE host_service_id = NEW.superior_host_service_id;
                IF sn !~ msk THEN
                    PERFORM error('Params', NEW.host_service_id, 'superior_host_service_id : "' || sn || '" !~ "' || msk || '"' , 'check_host_services()', TG_TABLE_NAME, TG_OP);
                    RETURN NULL;
                END IF; -- 1
            END IF; -- 2
        END IF; -- 3
    END IF; -- 4
    RETURN NEW;
END

Function: public.check_insert_menu_items()

Returns: trigger

Language: PLPGSQL

DECLARE
    n   integer;
BEGIN
    IF NEW.item_sequence_number IS NULL THEN
        IF NEW.upper_menu_item_id IS NULL THEN
            SELECT MAX(item_sequence_number) INTO n FROM menu_items WHERE app_name = NEW.app_name AND upper_menu_item_id IS NULL;
        ELSE 
            SELECT MAX(item_sequence_number) INTO n FROM menu_items WHERE app_name = NEW.app_name AND upper_menu_item_id = NEW.upper_menu_item_id;
        END IF;
        IF n IS NULL THEN
            n := 0;
        END IF;
        NEW.item_sequence_number := n + 10;
    END IF;
    RETURN NEW;
END;

Function: public.check_insert_phs_links()

Returns: trigger

Language: PLPGSQL

DECLARE
    n bigint;
    old_id bigint := -1; -- ilyen ID nincs, de kezelhetőbb min a NULL
    uid text;
BEGIN
    IF TG_OP = 'UPDATE' THEN
        IF NEW.phs_link_id <> OLD.phs_link_id THEN -- Nem szeretjük, ha az id megváltozik
            PERFORM error('Constant', -1, 'phs_link_id', 'check_insert_phs_links()', TG_TABLE_NAME, TG_OP);
        END IF;
        old_id := OLD.phs_link_id;
    END IF;
    -- Link típusa: ha nincs megpróbálja kitölteni, ha nem jó pampog (port_id -t is ellenörzi.)
    NEW.phs_link_type1 := phs_link_type(NEW.port_id1, NEW.phs_link_type1);
    NEW.phs_link_type2 := phs_link_type(NEW.port_id2, NEW.phs_link_type2);
    NEW.link_type := link_type(NEW.port_id1, NEW.port_id2, NEW.link_type);
    -- Egyediség
    IF TG_OP = 'INSERT' THEN
        SELECT COUNT(*) INTO n FROM phs_links
            WHERE port_id1 = NEW.port_id1 AND port_shared = NEW.port_shared AND phs_link_type1 = NEW.phs_link_type1
               OR port_id1 = NEW.port_id2 AND port_shared = NEW.port_shared AND phs_link_type1 = NEW.phs_link_type2;
    ELSE    --  UPDATE
        SELECT COUNT(*) INTO n FROM phs_links
            WHERE (port_id1 = NEW.port_id1 AND port_shared = NEW.port_shared AND phs_link_type1 = NEW.phs_link_type1
                OR port_id1 = NEW.port_id2 AND port_shared = NEW.port_shared AND phs_link_type1 = NEW.phs_link_type2)
              AND phs_link_id <> OLD.phs_link_id;
    END IF;
    IF n > 0 THEN
        PERFORM error('IdNotUni', n, 'port_id1 or port_id2', 'check_insert_phs_links()', TG_TABLE_NAME, TG_OP);
    END IF;
    -- Megosztás csak akkor, ha az egyik, és csak az egyik oldal 'Front'
    IF NEW.port_shared <> '' AND NOT XOR('Front' = NEW.phs_link_type1, 'Front' = NEW.phs_link_type2) THEN
        PERFORM error('Params', -1, 'port_shared', 'check_insert_phs_links()', TG_TABLE_NAME, TG_OP);
    END IF;
    -- Share ütküzések
    PERFORM check_phs_shared(NEW.port_id1, NEW.port_shared, NEW.phs_link_type1, old_id);
    PERFORM check_phs_shared(NEW.port_id2, NEW.port_shared, NEW.phs_link_type2, old_id);
    -- Ha nincs kitöltve az user_id
    IF NEW.create_user_id IS NULL THEN
        SELECT current_setting('lanview2.user_id') INTO uid;
        IF uid <> 'NULL' THEN
            NEW.create_user_id := CAST(uid AS bigint);
        END IF;
    END IF;
    NEW.forward := CAST('t' AS boolean);
    RETURN NEW;
END;

Function: public.check_interface()

Returns: trigger

Language: PLPGSQL

Különböző node_id esetén nem lehet két azonos MAC. Ha a node_id előjelet vált, akkor nincs ellenörzés (node rekord ideiglenes törlése).

DECLARE
    n integer;
BEGIN
    IF NEW.hwaddress IS NULL THEN
        RETURN NEW;
    END IF;
    IF TG_OP = 'UPDATE' AND OLD.node_id = - NEW.node_id THEN
        RETURN NEW; -- No check
    END IF;
    SELECT COUNT(*) INTO n FROM interfaces WHERE node_id <> NEW.node_id AND hwaddress = NEW.hwaddress;
    IF n > 0 THEN
        PERFORM error('IdNotUni', NEW.port_id, NEW.hwaddress::text, 'check_interface()', TG_TABLE_NAME, TG_OP);
        RETURN NULL;
    END IF;
    RETURN NEW;
END;

Function: public.check_ip_address()

Returns: trigger

Language: PLPGSQL

DECLARE
    n   cidr;
    ipa ip_addresses;
    nip boolean;    -- IP address type IS NULL
    snid bigint;
    cnt integer;
BEGIN
    -- RAISE INFO 'check_ip_address() %/% NEW = %',TG_TABLE_NAME, TG_OP , NEW;
    -- Az új rekordban van ip cím ?
    nip := NEW.ip_address_type IS NULL;
    IF nip THEN
        IF NEW.address IS NULL OR is_dyn_addr(NEW.address) IS NOT NULL THEN
            NEW.ip_address_type := 'dynamic';
        ELSE
            NEW.ip_address_type := 'fixip';
        END IF;
    END IF;
    IF NEW.address IS NOT NULL THEN
        -- Check subnet_id
        IF NEW.subnet_id IS NOT NULL AND NOT (SELECT NEW.address << netaddr FROM subnets WHERE subnet_id = NEW.subnet_id) THEN
            PERFORM error('Params', NEW.subnet_id, 'subnet for : ' || CAST(NEW.address AS TEXT), 'check_ip_address()', TG_TABLE_NAME, TG_OP);
            RETURN NULL;
        END IF;
        -- Nincs subnet (id), keresünk egyet
        IF NEW.subnet_id IS NULL AND NEW.ip_address_type <> 'external' AND NEW.ip_address_type <> 'private' THEN
            BEGIN
                SELECT subnet_id INTO STRICT NEW.subnet_id FROM subnets WHERE netaddr >> NEW.address;
                EXCEPTION
                    WHEN NO_DATA_FOUND THEN     -- nem találtunk
                        PERFORM error('NotFound', -1, 'subnet address for : ' || CAST(NEW.address AS TEXT), 'check_ip_address()', TG_TABLE_NAME, TG_OP);
                    WHEN TOO_MANY_ROWS THEN     -- több találat is van, nem egyértelmű
                        PERFORM error('Ambiguous',-1, 'subnet address for : ' || CAST(NEW.address AS TEXT), 'check_ip_address()', TG_TABLE_NAME, TG_OP);
            END;
            -- RAISE INFO 'Set subnet id : %', NEW.subnet_id;
        ELSIF NEW.ip_address_type = 'external'  THEN
            -- external típusnál mindíg NULL a subnet_id
            NEW.subnet_id := NULL;
        END IF;
        -- Ha nem private, akkor vizsgáljuk az ütközéseket
        IF NEW.ip_address_type <> 'private' THEN
            -- Azonos IP címek?
            FOR ipa IN SELECT * FROM ip_addresses WHERE NEW.address = address LOOP
                IF ipa.ip_address_id <> NEW.ip_address_id THEN 
                    IF ipa.ip_address_type = 'dynamic' OR is_dyn_addr(NEW.address) IS NOT NULL THEN
                    -- Ütköző dinamikust töröljük.
                        UPDATE ip_addresses SET address = NULL, ip_address_type = 'dynamic' WHERE ip_address_id = ipa.ip_address_id;
                    ELSIF ipa.ip_address_type = 'joint' AND (nip OR NEW.ip_address_type = 'joint') THEN
                    -- Ha közös címként van megadva a másik, ...
                        NEW.ip_address_type := 'joint';
                    ELSIF ipa.ip_address_type <> 'private' THEN
                    -- Minden más esetben ha nem privattal ütközik az hiba
                        PERFORM error('IdNotUni', 0, CAST(NEW.address AS TEXT), 'check_ip_address()', TG_TABLE_NAME, TG_OP);
                    END IF;
                END IF;
            END LOOP;
        END IF;
        -- Ha a preferred nincs megadva, akkor az elsőnek megadott cím a preferált
        IF NEW.preferred IS NULL THEN
            SELECT 1 + COUNT(*) INTO NEW.preferred FROM interfaces JOIN ip_addresses USING(port_id) WHERE port_id = NEW.port_id AND preferred IS NOT NULL AND address IS NOT NULL;
        END IF;
    ELSE
        -- Cím ként a NULL csak a dynamic típusnál megengedett
        IF NEW.ip_address_type <> 'dynamic' THEN
            PERFORM error('DataError', 0, 'NULL ip as non dynamic type', 'check_ip_address()', TG_TABLE_NAME, TG_OP);
        END IF;
        -- RAISE INFO 'IP address is NULL';
    END IF;
    -- RAISE INFO 'Return, NEW = %', NEW;
    IF TG_OP = 'UPDATE' THEN 
        IF NEW.ip_address_id <> OLD.ip_address_id THEN
            PERFORM error('Constant', OLD.ip_address_id, 'ip_address_id', 'check_ip_address()', TG_TABLE_NAME, TG_OP);
            RETURN NULL;
        END IF;
    END IF;
    RETURN NEW;
END;

Function: public.check_log_links()

Returns: trigger

Language: PLPGSQL

DECLARE
    n bigint;
BEGIN
    IF TG_OP = 'UPDATE' THEN
        -- Csak a log_link_note mező módisítása megengedett
        IF (NEW.port_id1  <> OLD.port_id1 OR NEW.port_id2 <> OLD.port_id2 OR
            NEW.link_type <> OLD.link_type OR
            NEW.phs_link_chain <> OLD.phs_link_chain OR
            NEW.share_result <> OLD.share_result) THEN
            PERFORM error('Constant', -1, '', 'check_log_links()', TG_TABLE_NAME, TG_OP);
        END IF;
        RETURN NEW;
    END IF;
    -- RAISE INFO 'INSERT log.link %(%) -- %(%) [%]', port_id2full_name(NEW.port_id1), NEW.port_id1, port_id2full_name(NEW.port_id2), NEW.port_id2, NEW.phs_link_chain;
    n := COUNT(*) FROM log_links WHERE port_id1 = NEW.port_id1;
    IF 0 < n THEN
        -- RAISE WARNING 'port_id1 = %(%), found % record(s).', port_id2full_name(NEW.port_id1), NEW.port_id1, n;
        PERFORM error('IdNotUni', NEW.port_id1, 'port_id1', 'check_log_links()', TG_TABLE_NAME, TG_OP);
    END IF;
    RETURN NEW;
END;

Function: public.check_paramtype(t text, v public.paramtype)

Returns: text

Language: PLPGSQL

BEGIN
    RETURN CASE t
        WHEN 'text'     THEN v
        WHEN 'boolean'  THEN CASE v::boolean WHEN true THEN 'true' ELSE 'false' END
        WHEN 'integer'  THEN v::bigint::text
        WHEN 'real'     THEN v::double precision::text
        WHEN 'date'     THEN v::date::text
        WHEN 'time'     THEN v::time::text
        WHEN 'datetime' THEN v::timestamp::text
        WHEN 'interval' THEN v::interval::text
        WHEN 'inet'     THEN v::inet::text
        WHEN 'cidr'     THEN v::cidr::text
        WHEN 'mac'      THEN v::macaddr::text
        WHEN 'point'    THEN v::point::text
        WHEN 'bytea'    THEN v
    END;
END;

Function: public.check_phs_shared(bigint, public.portshare, public.phslinktype, bigint)

Returns: void

Language: PLPGSQL

DECLARE
    n bigint;
    ps portshare;
    id bigint := $4;
BEGIN
    IF $2 = '' OR $3 <> 'Front' THEN     -- Nincs SHARE
        IF $3 = 'Term' OR $3 = 'Back' THEN
            RETURN ;
        END IF;
        SELECT COUNT(*) INTO n FROM phs_links WHERE port_id1 = $1 AND phs_link_type1 = $3 AND phs_link_id <> id;
        IF n > 0 THEN
            PERFORM error('Collision', n, 'port_shared', 'check_phs_shared', 'phs_links_table');
        END IF;
        RETURN;
    ELSE
        -- Megnézzük, hogy az erre a portra vonatkozó sherelt link nem-e ütközik.
        FOR ps IN SELECT port_shared FROM phs_links WHERE port_id1 = $1 AND phs_link_type1 = $3 AND phs_link_id <> id LOOP
            IF FALSE = check_shared(ps, $2) THEN
                PERFORM error('Collision', n, 'port_shared', 'check_phs_shared', 'phs_links_table');
            END IF;
        END LOOP;
        -- Nem megengedett a megosztott link, ha valamelyik port a hátlapon meg van osztva
        SELECT shared_cable INTO ps FROM pports WHERE port_id = $1;
        IF ps <> '' THEN
            PERFORM error('Collision', n, 'port_shared and shared_cable', 'check_phs_shared', 'phs_links_table');
        END IF;
    END IF;
END;

Function: public.check_reference_node_id()

Returns: trigger

Language: PLPERL

Ellenőrzi, hogy a node_id mező valóban egy node rekordra mutat-e. Ha a node_id érték nem változik, akkor nincs ellenörzés. Ha a node_id előjelet vált, akkor sincs ellenörzés, a node_id mindíg pozitív szám, a negatív értékekkel az a speciális eset van jelezve, amikor a nodes rekordot snmpdevices rekordra vagy fordítva konvertáljuk, ebben az esetben a rekord ideiglenesen törölve lesz. A paraméter a tábla neve, amelyikben és amelyik leszármazottai között szerepelnie kell a node rekordnak

    ($inTable) = @{$_TD->{args}};
    if ($_TD->{new}{node_id} ==   $_TD->{old}{node_id}) { return; } # No change, ok
    if ($_TD->{new}{node_id} == - $_TD->{old}{node_id}) { return; } # Temporary deletion of owner, no check
    $rv = spi_exec_query('SELECT COUNT(*) FROM ' . $inTable .' WHERE node_id = ' . $_TD->{new}{node_id});
    $nn  = $rv->{rows}[0]->{count};
    if ($nn == 1) { return; }
    if ($nn == 0) {
        spi_exec_query("SELECT error('InvRef', $_TD->{new}{node_id}, '$inTable', 'check_reference_node_id()', '$_TD->{table_name}', '$_TD->{event}');");
    }
    else {
        spi_exec_query("SELECT error('DataError', $_TD->{new}{node_id}, '$inTable', 'check_reference_node_id()', '$_TD->{table_name}', '$_TD->{event}');");
    }
    return "SKIP";

Function: public.check_reference_port_id()

Returns: trigger

Language: PLPERL

Ellenőrzi, hogy a port_id mező valóban egy port rekordra mutat-e. Ha az opcionális első paraméter true, akkor megengedi a NULL értéket is. Ha megadjuk a második paramétert, akkor az a tábla neve, amelyikben és amelyik leszármazottai között szerepelnie kell a port rekordnak Ha a paraméter nincs megadva, akkor az összes port táblában keres (nport) Ha mega van adva egy harmadik paraméter, akkor az egy tábla név, melyben nem szerpelhet a rekord (csak "pport" lehet)

    ($null, $inTable, $exTable) = @{$_TD->{args}};
    if ((defined($null) && $null && !defined($_TD->{new}{port_id}))
     || ($_TD->{new}{port_id} == $_TD->{old}{port_id})) { return; } # O.K.
    if (!defined($inTable)) { $inTable = 'nports'; }
    $rv = spi_exec_query('SELECT COUNT(*) FROM ' . $inTable .' WHERE port_id = ' . $_TD->{new}{port_id});
    if( $rv->{status} ne SPI_OK_SELECT) {
        spi_exec_query("SELECT error('DataError', 'Status not SPI_OK_SELECT, but $rv->{status}', '$_TD->{table_name}', '$_TD->{event}');");
    }
    $nn  = $rv->{rows}[0]->{count};
    if ($nn == 0) {
        spi_exec_query("SELECT error('InvRef', $_TD->{new}{port_id}, '$inTable.port_id', 'check_reference_port_id()', '$_TD->{table_name}', '$_TD->{event}');");
        return "SKIP";
    }
    if ($nn != 1) {
        spi_exec_query("SELECT error('DataError', $_TD->{new}{port_id}, '$inTable.port_id', 'check_reference_port_id()', '$_TD->{table_name}', '$_TD->{event}');");
        return "SKIP";
    }
    if (defined($exTable) && $exTable) {
        $rv = spi_exec_query("SELECT COUNT(*) FROM $exTable WHERE port_id = $_TD->{new}{port_id}");
        $nn = $rv->{rows}[0]->{count};
        if ($nn != 0) {
            $cmd = "SELECT error('InvRef', $_TD->{new}{port_id}, '$exTable' ,'check_reference_port_id()', '$_TD->{table_name}', '$_TD->{event}');";
            # elog(NOTICE, $cmd);
            spi_exec_query($cmd);
            return "SKIP";
        }
    }
    return;

Function: public.check_shape_field()

Returns: trigger

Language: PLPGSQL

BEGIN
    IF NEW.table_field_name IS NULL THEN
	NEW.table_field_name = NEW.table_shape_field_name;
    END IF;
    RETURN NEW;
END;

Function: public.check_shared(public.portshare, public.portshare)

Returns: boolean

Language: PLPGSQL

Megvizsgálja, hogy a megadott két megosztás típus átfedi-e egymást,ha nem akkor igazzal tér vissza. Ha bármelyik paraméter NC, akkor NULL-lal tér vissza.

BEGIN
    IF $1 = 'NC' OR $2 = 'NC' THEN
        RETURN NULL;
    END IF;
    IF $1 = '' OR $2 = '' THEN
        RETURN FALSE;
    END IF;
    RETURN ( $1 = 'A'  AND ($2 = 'B' OR $2 = 'BA' OR $2 = 'BB'))
        OR ( $1 = 'AA' AND ($2 = 'B' OR $2 = 'BA' OR $2 = 'BB' OR $2 = 'AB' OR $2 = 'C' OR $2 = 'D'))
        OR ( $1 = 'AB' AND ($2 = 'B' OR $2 = 'BA' OR $2 = 'BB' OR $2 = 'AA'))
        OR ( $1 = 'B'  AND ($2 = 'A' OR $2 = 'AA' OR $2 = 'AB'))
        OR ( $1 = 'BA' AND ($2 = 'A' OR $2 = 'AA' OR $2 = 'AB' OR $2 = 'BB'))
        OR ( $1 = 'BB' AND ($2 = 'A' OR $2 = 'AA' OR $2 = 'AB' OR $2 = 'BA' OR $2 = 'C' OR $2 = 'D'))
        OR ( $1 = 'C'  AND ($2 = 'D' OR $2 = 'AA' OR $2 = 'BB'))
        OR ( $1 = 'D'  AND ($2 = 'C' OR $2 = 'AA' OR $2 = 'BB'));
END;

Function: public.check_superior_service(_hs public.host_services)

Returns: bigint

Language: PLPGSQL

Ha egy függő szervízről van szó, akkor a felsőbb szintű szolgáltatások között keres egy ismert és warning-nál magsabszintű riasztási állapotút, és annak az azonosítójával tér vissza. Egyébként ill. ha nincs találat, akkor NULL-al tér vissza.

DECLARE
    hs host_services;
    n  integer;
BEGIN
    hs := _hs;
    n  := 0;
    LOOP
        IF hs.superior_host_service_id IS NULL THEN
            RETURN NULL;
        END IF;
        IF n > 20 THEN
            PERFORM error('Loop', _hs.superior_host_service_id, 'superior_host_service_id', 'chack_superior_service()');
        END IF;
        SELECT * INTO hs FROM host_services WHERE host_service_id = hs.superior_host_service_id;
        IF hs.host_service_state > 'warning' AND hs.host_service_state <> 'unknown' THEN
            IF hs.act_alarm_log_id IS NULL THEN
                PERFORM error('DataWarn', hs.host_service_id, 'act_alarm_log_id', 'check_superior_service()', 'host_services');
            END IF;
            RETURN hs.act_alarm_log_id;
        END IF;
        n := n + 1;
    END LOOP;
END

Function: public.check_table_shape()

Returns: trigger

Language: PLPGSQL

DECLARE
    tsid  bigint;
BEGIN
    IF NEW.right_shape_ids IS NULL THEN
        RETURN NEW;
    END IF;
    IF array_length(NEW.right_shape_ids,1) = 0 THEN
        NEW.right_shape_ids = NULL;
        RETURN NEW;
    END IF;
    FOREACH tsid  IN ARRAY NEW.right_shape_ids LOOP
        IF 1 <> COUNT(*) FROM table_shapes WHERE table_shape_id = tsid THEN
            PERFORM error('IdNotFound', tsid, NEW.table_shape_name, 'check_table_shape()', TG_TABLE_NAME, TG_OP);
            RETURN NULL;
        END IF;
    END LOOP;
    RETURN NEW;
END;

Function: public.chk_flapping(iflapp bigint, tflapp interval, hsid integer)

Returns: boolean

Language: PLPGSQL

Ellenörzi, hogy az állpotváltozások billegésnek (flapping) nubősülnek-e. Vagyis a megadott időintervallumban (tflapp) a hsid azonosítójü szolgáltatás állpota töbszőr változott mint iflapp. Ha igen igazzal, egyébként hamis értékkel tér vissza.

BEGIN
    RETURN iflapp <  COUNT(*) FROM host_service_logs
            WHERE host_service_id = hsid
              AND date_of > (CURRENT_TIMESTAMP - tflapp);
END

Function: public.compare_db_version(minor integer, major integer)

Returns: integer

Language: PLPGSQL

DECLARE
    i int;
BEGIN
    i := get_int_sys_param('version_major');
    IF i = major THEN
        i := get_int_sys_param('version_minor');
        IF i = minor THEN
            RETURN 0;
        ELSIF  i < minor THEN
            RETURN 1;
        ELSE
            return -1;
        END IF;
    ELSIF  i < major THEN
        RETURN 1;
    ELSE
        return -1;
    END IF;
    
END

Function: public.crypt(text, text)

Returns: text

Language: C

pg_crypt

Function: public.crypt_user_password()

Returns: trigger

Language: PLPGSQL

Trigger függvény az users táblához. Titkosítja a passwd mwzőt, ha meg van adva, vagy változott.

BEGIN
    IF TG_OP = 'UPDATE' THEN
        IF NEW.passwd IS NULL THEN
            NEW.passwd := OLD.passwd;
            RETURN NEW;
        ELSIF NEW.passwd = OLD.passwd THEN
            RETURN NEW;
        END IF;
    ELSE -- 'INSERT'
        IF NEW.passwd IS NULL THEN
            RETURN NEW;
        END IF;
    END IF;
    NEW.passwd := crypt(NEW.passwd, gen_salt('md5'));
    RETURN NEW;
END

Function: public.current_mactab_stat(mst bigint, mac macaddr, pid public.mactabstate[])

Returns: mactabstate[]

Language: PLPGSQL

DECLARE
    ret mactabstate[] := '{}';
    suspect boolean;
BEGIN
    suspect := mst && ARRAY['suspect'::mactabstate];
    IF is_content_oui(mac) THEN
        ret = array_append(ret, 'oui'::mactabstate);
        suspect := false;
    END IF;
    IF 0 < COUNT(*) FROM interfaces WHERE hwaddress = mac THEN
        ret := array_append(ret, 'likely'::mactabstate);
        suspect := false;
        IF is_linked(pid, mac) THEN
            ret := array_append(ret, 'link'::mactabstate);
        END IF;
    END IF;
    IF is_content_arp(mac) THEN
        ret := array_append(ret, 'arp'::mactabstate);
    END IF;
    IF suspect THEN
        ret := array_append(ret, 'suspect'::mactabstate);
    END IF;
    RETURN ret;
END;

Function: public.db_err_id2name(bigint)

Returns: text

Language: PLPGSQL

DECLARE
    name TEXT;
BEGIN
    SELECT func_name || ':' || err_name INTO name
        FROM db_errs JOIN errors USING(error_id)
        WHERE dblog_id = $1;
    IF NOT FOUND THEN
        PERFORM error('IdNotFound', $1, 'dblog_id', 'db_err_id2name()', 'db_errs');
    END IF;
    RETURN name;
END;

Function: public.db_error_chk_reapeat()

Returns: trigger

Language: PLPGSQL

Trigger függvény az db_ers táblához, hogy ne legyenek ismételt rekordok.

DECLARE
    err db_errs; -- Időben az előző hiba rekord
BEGIN
    IF NEW.acknowledged THEN
	RETURN NEW;
    END IF;
    SELECT * INTO err FROM db_errs
	WHERE NOT acknowledged
	 AND error_id    = NEW.error_id
	 AND user_id     = NEW.user_id
	 AND table_name   = NEW.table_name
	 AND trigger_op  = NEW.trigger_op
	 AND err_subcode = NEW.err_subcode
	 AND err_msg  = NEW.err_msg
	 AND func_name    = NEW.func_name
	ORDER BY date_of_last DESC LIMIT 1;
    IF FOUND THEN
        UPDATE db_errs SET reapeat = err.reapeat +1, date_of_last = NOW() WHERE dblog_id = err.dblog_id;
        RETURN NULL;
    END IF;
    RETURN NEW;
END;

Function: public.dblink(text)

Returns: SET OF record

Language: C

dblink_record

Function: public.dblink(text, boolean)

Returns: SET OF record

Language: C

dblink_record

Function: public.dblink(text, text)

Returns: SET OF record

Language: C

dblink_record

Function: public.dblink(text, text, boolean)

Returns: SET OF record

Language: C

dblink_record

Function: public.dblink_build_sql_delete(text, int2vector, integer, text[])

Returns: text

Language: C

dblink_build_sql_delete

Function: public.dblink_build_sql_insert(text, int2vector, integer, text[], text[])

Returns: text

Language: C

dblink_build_sql_insert

Function: public.dblink_build_sql_update(text, int2vector, integer, text[], text[])

Returns: text

Language: C

dblink_build_sql_update

Function: public.dblink_cancel_query(text)

Returns: text

Language: C

dblink_cancel_query

Function: public.dblink_close(text)

Returns: text

Language: C

dblink_close

Function: public.dblink_close(text, boolean)

Returns: text

Language: C

dblink_close

Function: public.dblink_close(text, text)

Returns: text

Language: C

dblink_close

Function: public.dblink_close(text, text, boolean)

Returns: text

Language: C

dblink_close

Function: public.dblink_connect(text)

Returns: text

Language: C

dblink_connect

Function: public.dblink_connect(text, text)

Returns: text

Language: C

dblink_connect

Function: public.dblink_connect_u(text)

Returns: text

Language: C

dblink_connect

Function: public.dblink_connect_u(text, text)

Returns: text

Language: C

dblink_connect

Function: public.dblink_current_query()

Returns: text

Language: C

dblink_current_query

Function: public.dblink_disconnect()

Returns: text

Language: C

dblink_disconnect

Function: public.dblink_disconnect(text)

Returns: text

Language: C

dblink_disconnect

Function: public.dblink_error_message(text)

Returns: text

Language: C

dblink_error_message

Function: public.dblink_exec(text)

Returns: text

Language: C

dblink_exec

Function: public.dblink_exec(text, boolean)

Returns: text

Language: C

dblink_exec

Function: public.dblink_exec(text, text)

Returns: text

Language: C

dblink_exec

Function: public.dblink_exec(text, text, boolean)

Returns: text

Language: C

dblink_exec

Function: public.dblink_fdw_validator(catalog text[], options oid)

Returns: void

Language: C

dblink_fdw_validator

Function: public.dblink_fetch(text, integer)

Returns: SET OF record

Language: C

dblink_fetch

Function: public.dblink_fetch(text, integer, boolean)

Returns: SET OF record

Language: C

dblink_fetch

Function: public.dblink_fetch(text, text, integer)

Returns: SET OF record

Language: C

dblink_fetch

Function: public.dblink_fetch(text, text, integer, boolean)

Returns: SET OF record

Language: C

dblink_fetch

Function: public.dblink_get_connections()

Returns: text[]

Language: C

dblink_get_connections

Function: public.dblink_get_notify()

Returns: SET OF record

Language: C

dblink_get_notify

Function: public.dblink_get_notify(extra text)

Returns: SET OF record

Language: C

dblink_get_notify

Function: public.dblink_get_pkey(text)

Returns: SET OF dblink_pkey_results

Language: C

dblink_get_pkey

Function: public.dblink_get_result(text)

Returns: SET OF record

Language: C

dblink_get_result

Function: public.dblink_get_result(text, boolean)

Returns: SET OF record

Language: C

dblink_get_result

Function: public.dblink_is_busy(text)

Returns: integer

Language: C

dblink_is_busy

Function: public.dblink_open(text, text)

Returns: text

Language: C

dblink_open

Function: public.dblink_open(text, text, boolean)

Returns: text

Language: C

dblink_open

Function: public.dblink_open(text, text, text)

Returns: text

Language: C

dblink_open

Function: public.dblink_open(text, text, text, boolean)

Returns: text

Language: C

dblink_open

Function: public.dblink_send_query(text, text)

Returns: integer

Language: C

dblink_send_query

Function: public.dearmor(text)

Returns: bytea

Language: C

pg_dearmor

Function: public.decrypt(bytea, bytea, text)

Returns: bytea

Language: C

pg_decrypt

Function: public.decrypt_iv(bytea, bytea, bytea, text)

Returns: bytea

Language: C

pg_decrypt_iv

Function: public.delete_lldp_link()

Returns: trigger

Language: PLPGSQL

BEGIN
    DELETE FROM lldp_links_table
        WHERE (port_id1 = OLD.port_id1 AND port_id2 = OLD.port_id2)
           OR (port_id1 = OLD.port_id2 AND port_id2 = OLD.port_id1);
    RETURN OLD;
END;

Function: public.delete_node_post()

Returns: trigger

Language: PLPGSQL

BEGIN
    DELETE FROM nports            WHERE node_id = OLD.node_id;
    DELETE FROM host_services     WHERE node_id = OLD.node_id;
    DELETE FROM node_params       WHERE node_id = OLD.node_id;
    RETURN OLD;
END;

Function: public.delete_port_post()

Returns: trigger

Language: PLPGSQL

BEGIN
    DELETE FROM port_params       WHERE port_id = OLD.port_id;
    DELETE FROM host_services     WHERE port_id = OLD.port_id;
    DELETE FROM port_vlans        WHERE port_id = OLD.port_id;
    DELETE FROM port_vlan_logs    WHERE port_id = OLD.port_id;
    DELETE FROM mactab            WHERE port_id = OLD.port_id;
    DELETE FROM phs_links_table   WHERE port_id1 = OLD.port_id OR port_id2 = OLD.port_id;
    DELETE FROM lldp_links_table  WHERE port_id1 = OLD.port_id OR port_id2 = OLD.port_id;
    RETURN OLD;
END;

Function: public.delete_record_text()

Returns: trigger

Language: PLPGSQL

BEGIN
    DELETE FROM localizations WHERE text_id = OLD.text_id AND table_for_text = TG_TABLE_NAME::tablefortext;
    RETURN OLD;
END;

Function: public.digest(bytea, text)

Returns: bytea

Language: C

pg_digest

Function: public.digest(text, text)

Returns: bytea

Language: C

pg_digest

Function: public.dow2int(public.dayofweek)

Returns: integer

Language: PLPGSQL

BEGIN
    CASE $1
        WHEN 'sunday'    THEN  RETURN 0;
        WHEN 'monday'    THEN  RETURN 1;
        WHEN 'tuesday'   THEN  RETURN 2;
        WHEN 'wednesday' THEN  RETURN 3;
        WHEN 'thursday'  THEN  RETURN 4;
        WHEN 'friday'    THEN  RETURN 5;
        WHEN 'saturday'  THEN  RETURN 6;
        ELSE                   RETURN NULL;
    END CASE;
END;

Function: public.encrypt(bytea, bytea, text)

Returns: bytea

Language: C

pg_encrypt

Function: public.encrypt_iv(bytea, bytea, bytea, text)

Returns: bytea

Language: C

pg_encrypt_iv

Function: public.enum_name2note(text, text)

Returns: text

Language: PLPGSQL

Egy enumerációs értékhez tartozó note stringet kéri le Paraméterek: $1 Az enumerációs érték. $2 Az enumerációs típus neve opcionális. Ha van megfelelő rekord enum_vals táblában, akkor enum_val_note értékével tér vissza, ha nem akkor az első paraméter értékével. Ha nem adtuk meg az enumerációs típust, és az enumerációs értékre több találatot is kapunk, akkor a függvény hibát dob.

DECLARE
    note text;
BEGIN
    IF $2 IS NULL THEN
        BEGIN
            SELECT enum_val_note INTO note FROM enum_vals WHERE enum_val_name = $1;
            EXCEPTION
                WHEN NO_DATA_FOUND THEN     -- nem találtunk
                    note = $1;
                WHEN TOO_MANY_ROWS THEN     -- több találat is van, nem egyértelmű
                    PERFORM error('Ambiguous', -1, $1, 'enum_name2note()', 'enum_vals');
        END;
    ELSE 
        SELECT enum_val_note INTO note FROM enum_vals WHERE enum_val_name = $1 AND enum_type_name = $2;
        IF NOT FOUND THEN
            note = $1;
        END IF;
    END IF;
    RETURN note;
END

Function: public.error(text, bigint, text, text, text, text)

Returns: boolean

Language: PLPGSQL

Egy hiba rekord rögzítése. Egy adatbázis tartalmi hiba rögzítése, ha az egy aplikációban derült ki, ill. azt az app a függvény hívással jelzi.

DECLARE
    er errors%ROWTYPE;
    ui text;
    cmd text;
    con CONSTANT text := 'errlog';
    subc bigint := $2;
    subm text    := $3;
    srcn text    := $4;
    tbln text    := $5;
    trgn text    := $6;
BEGIN
    IF subc IS NULL THEN subc := -1;    END IF;
    IF subm IS NULL THEN subm := 'nil'; END IF;
    IF srcn IS NULL THEN srcn := 'nil'; END IF;
    IF tbln IS NULL THEN tbln := 'nil'; END IF;
    IF trgn IS NULL THEN trgn := 'no';  END IF;
    -- RAISE NOTICE 'called: error(%,%,%,%,%,%) ...', $1,subc,subm,srcn,tbln,trgn;
    er := error_by_name($1);
    PERFORM set_config('lanview2.last_error_code', CAST(er.error_id AS text), false);
    SELECT current_setting('lanview2.user_id') INTO ui;
    IF ui = '-1' THEN
        ui = '0';	-- nobody
    END IF;
    -- Tranzakción kívülröl kel (dblink-el) kiírni a log rekordot, mert visszagörgetheti
    SELECT 'dbname=lanview2 port=' || setting INTO cmd FROM pg_show_all_settings() WHERE name = 'port';
    PERFORM dblink_connect(con, cmd);
    cmd := 'INSERT INTO db_errs'
     || '(error_id, user_id, table_name, trigger_op, err_subcode, err_msg, func_name) VALUES ('
     || er.error_id   || ',' || ui || ',' || quote_nullable(tbln) || ','
     || quote_nullable(trgn) || ',' || subc || ',' || quote_nullable(subm) || ',' || quote_nullable(srcn)
     || ')';
    RAISE NOTICE 'Error log :  "%"', cmd;
    PERFORM dblink_exec(con, cmd, false);
    PERFORM dblink_disconnect(con);
    -- dblink vége
    CASE er.error_type
        WHEN 'Ok' THEN
            RAISE INFO 'Info %, #% %',       $1, subc, (er.error_note || subm);
        WHEN 'Warning', 'Ok' THEN
            RAISE WARNING 'WARNING %, #% %', $1, subc, (er.error_note || subm);
     -- WHEN 'Fatal', 'Error' THEN
        ELSE
            RAISE EXCEPTION 'ERROR %, #% %', $1, subc, (er.error_note || subm);
    END CASE;
    RETURN true;
END;

Function: public.error_by_id(bigint)

Returns: errors

Language: PLPGSQL

Egy hiba tipus rekord beolvasása a hiba tipus azonosító alapján

DECLARE
    err errors%ROWTYPE;
BEGIN
    SELECT * INTO err FROM errors WHERE error_id = $1;
    IF NOT FOUND THEN
        SELECT * INTO err FROM errors WHERE error_name = 'UnknErrorId';
        IF NOT FOUND THEN
            RAISE EXCEPTION 'Sytem data error in errors table, original error code is %', $1;
        END IF;
    END IF;
    RETURN err;
END;

Function: public.error_by_name(text)

Returns: errors

Language: PLPGSQL

Egy hiba típus rekord beolvasása a hiba típus név alapján

DECLARE
    err errors%ROWTYPE;
BEGIN
    SELECT * INTO err FROM errors WHERE error_name = $1;
    IF NOT FOUND THEN
        SELECT * INTO err FROM errors WHERE error_name = 'UnknErrorId';
        IF NOT FOUND THEN
            RAISE EXCEPTION 'Sytem data error in errors table, original error code is %', $1;
        END IF;
        err.error_note := err.error_note || ' #' || $1;
    END IF;
    RETURN err;
END;

Function: public.error_id2name(bigint)

Returns: text

Language: PLPGSQL

 DECLARE name text; BEGIN IF $1 IS NULL THEN RETURN NULL;  END IF; SELECT error_name INTO name FROM errors WHERE error_id = $1; IF NOT FOUND THEN PERFORM error('IdNotFound', $1, 'error_id', 'error_id2name', 'errors'); END IF; RETURN name; END 

Function: public.error_name2id(text)

Returns: bigint

Language: PLPGSQL

Hiba tipus azonosító a név alapján

DECLARE
    err errors%ROWTYPE;
BEGIN
    err := error_by_name($1);
    return err.error_id;
END;

Function: public.error_name2note(text)

Returns: text

Language: PLPGSQL

Hiba tipus leírás a név alapján

DECLARE
    err errors%ROWTYPE;
BEGIN
    err := error_by_name($1);
    return err.error_note;
END;

Function: public.expired_offline_alarm()

Returns: void

Language: PLPGSQL

DECLARE
    t interval;
BEGIN
    t := now() - get_interval_sys_param('user_message_timeout');
    IF NOT NULL t THEN
        UPDATE user_events SET event_state = 'dropped', happened = now()
            WHERE event_type = 'sendmail' AND event_state = 'necessary' AND created < t;
    END IF;
END

Function: public.expired_online_alarm()

Returns: void

Language: PLPGSQL

DECLARE
    t timestamp;
BEGIN
    t := now() - get_interval_sys_param('user_notice_timeout');
    IF NOT NULL t THEN
        UPDATE user_events SET event_state = 'dropped', happened = now()
            WHERE event_type = 'notice' AND event_state = 'necessary' AND created < t;
    END IF;
END

Function: public.expired_online_alarm(did bigint)

Returns: void

Language: PLPGSQL

DECLARE
    expi interval;
BEGIN
    SELECT param_value::interval INTO expi FROM sys_params WHERE sys_param_name = 'user_notice_timeout';
    UPDATE user_events SET event_state = 'dropped'
        WHERE event_state = 'necessary' AND (created + expi) < NOW();
END

Function: public.find_superior(_ptyp public.host_services, _hsnm text, hsrv text)

Returns: host_services

Language: PLPGSQL

DECLARE
    r    record;
    hsnm text := _hsnm;
    ptyp text := _ptyp;
    serv text;
    rres bigint;
    nid  bigint;
BEGIN
    IF hsnm IS NULL THEN
        hsnm := superior_service_mask FROM services WHERE service_id = hsrv.service_id;
    END IF;
    IF ptyp IS NULL THEN
        ptyp := substring(
            (SELECT features FROM services WHERE service_id = hsrv.service_id)
            FROM E'\\:iftype\\=(.*)\\:');
    END IF;
    IF hsnm IS NULL OR ptyp IS NULL THEN
--        RAISE INFO 'find_superior(%,%)', hsnm, ptyp;
        RETURN hsrv;
    END IF;
    nid = hsrv.node_id;
    RAISE INFO 'Simple search. node_id = %, ptype = %, hsnm = %', nid, ptyp, hsnm;
    SELECT suphstsrv.host_service_id, suphstsrv.node_id INTO r
        FROM nports         slport
        JOIN iftypes        slprtyp   ON slprtyp.iftype_id = slport.iftype_id
        JOIN log_links      loglink   ON loglink.port_id1  = slport.port_id
        JOIN nports         maport    ON maport.port_id    = loglink.port_id2
        JOIN host_services  suphstsrv ON suphstsrv.node_id = maport.node_id
        JOIN services       supsrv    ON supsrv.service_id = suphstsrv.service_id
      WHERE slport.node_id = nid AND slprtyp.iftype_name = ptyp AND supsrv.service_name ~ hsnm;
    GET DIAGNOSTICS rres = ROW_COUNT;
    RAISE INFO '(simple) ROW_COUNT is %, FOUND is %', rres, FOUND;
    IF rres = 0 THEN
        RAISE INFO 'Search acros one hub';
        SELECT shs.host_service_id, shs.node_id INTO r
            FROM nports         ap
            JOIN iftypes        apt ON ap.iftype_id = apt.iftype_id
            JOIN log_links      ll  ON ll.port_id1 = ap.port_id
            JOIN nports         hp  ON ll.port_id2 = hp.port_id
            JOIN nports         shp ON shp.node_id = hp.node_id
            JOIN log_links      sll ON shp.port_id = sll.port_id1
            JOIN nports         sp  ON sp.port_id  = sll.port_id2
            JOIN host_services  shs ON shs.node_id = sp.node_id
            JOIN services       ss  ON shs.service_id = ss.service_id
            WHERE ap.node_id = nid AND apt.iftype_name = ptyp AND ss.service_name ~ hsnm;
        GET DIAGNOSTICS rres = ROW_COUNT;
        RAISE INFO '(complex) ROW_COUNT is %', rres;
    END IF;
    IF rres > 1 THEN
       PERFORM error('Ambiguous', hsrv.host_service_id, ptyp || ',' || hsnm, 'set_superior');
    ELSIF rres = 0 THEN
       PERFORM error('WNotFound', hsrv.host_service_id, ptyp || ',' || hsnm, 'set_superior');
       RETURN hsrv;
    END IF;
    hsrv.superior_host_service_id := r.host_service_id;
    RETURN hsrv;
END

Function: public.first_node_id2name(bigint[])

Returns: text

Language: PLPGSQL

DECLARE
    id text;
BEGIN
    RETURN node_id2name($1[1]);
END

Function: public.gen_random_bytes(integer)

Returns: bytea

Language: C

pg_random_bytes

Function: public.gen_random_uuid()

Returns: uuid

Language: C

pg_random_uuid

Function: public.gen_salt(text)

Returns: text

Language: C

pg_gen_salt

Function: public.gen_salt(text, integer)

Returns: text

Language: C

pg_gen_salt_rounds

Function: public.get_bool_port_param(name bigint, pid text)

Returns: boolean

Language: PLPGSQL

BEGIN
    RETURN cast_to_boolean(param_value) FROM port_params WHERE port_id = pid AND port_param_name = name;
END;

Function: public.get_bool_sys_param(pname text)

Returns: boolean

Language: PLPGSQL

BEGIN
    RETURN cast_to_boolean(get_text_sys_param(pname));
END

Function: public.get_image(pid bigint)

Returns: bigint

Language: PLPGSQL

Lekéri a rekord vagy a legközelebbi parent image_id-jét. Addig megy a gyökér felé, amíg nem NULL értéket talál, vagy nincs több parent.

DECLARE
    iid bigint;
BEGIN
    SELECT image_id INTO iid FROM places WHERE place_id = pid;
    IF iid IS NOT NULL THEN
        RETURN iid;
    END IF;
    RETURN get_parent_image(pid);
END

Function: public.get_int_sys_param(pname text)

Returns: bigint

Language: PLPGSQL

BEGIN
    RETURN cast_to_integer(get_text_sys_param(pname));
END

Function: public.get_interval_sys_param(pname text)

Returns: interval

Language: PLPGSQL

BEGIN
    RETURN cast_to_interval(get_text_sys_param(pname));
END

Function: public.get_language_id()

Returns: integer

Language: PLPGSQL

BEGIN
    RETURN CAST(current_setting('lanview2.language_id') AS integer);
    EXCEPTION
        WHEN OTHERS THEN
            RETURN COALESCE(get_int_sys_param('default_language'), get_int_sys_param('failower_language'));
END;

Function: public.get_parent_image(idr bigint)

Returns: bigint

Language: PLPGSQL

Lekéri a legközelebbi parent image_id-jét. Addig megy a gyökér felé, amíg nem NULL értéket talál, vagy nincs több parent.

DECLARE
    n integer;
    pid bigint := idr;
    iid bigint;
BEGIN
    SELECT parent_id INTO pid FROM places WHERE place_id = pid;
    IF NOT FOUND THEN
        RETURN NULL;
    END IF;
    n := 0;
    LOOP
        n := n + 1;
        IF N > 16 THEN
            PERFORM error('Loop', idr, '', 'is_parent_place()', 'places');
        END IF;
        SELECT parent_id, image_id INTO pid, iid FROM places WHERE place_id = pid;
        IF NOT FOUND THEN
            RETURN NULL;
        END IF;
        IF iid IS NOT NULL THEN
            RETURN iid;
        END IF;
    END LOOP;
END

Function: public.get_text_node_param(tname bigint, nid text)

Returns: text

Language: PLPGSQL

DECLARE
    v text;
BEGIN
    SELECT param_value INTO v
        FROM node_params
        JOIN param_types USING(param_type_id)
        WHERE param_type_name = tname AND node_id = nid;
    IF NOT FOUND THEN
        RETURN NULL;
    END IF;
    RETURN v;
END

Function: public.get_text_port_param(tname bigint, pid text)

Returns: text

Language: PLPGSQL

DECLARE
    v text;
BEGIN
    SELECT param_value INTO v
        FROM port_params
        JOIN param_types USING(param_type_id)
        WHERE param_type_name = tname AND port_id = pid;
    IF NOT FOUND THEN
        RETURN NULL;
    END IF;
    RETURN v;
END

Function: public.get_text_sys_param(pname text)

Returns: text

Language: PLPGSQL

DECLARE
    res text;
BEGIN
    SELECT param_value INTO res FROM sys_params WHERE sys_param_name = pname;
    IF NOT FOUND THEN
        RETURN NULL;
    END IF;
    RETURN res;
END

Function: public.group_id2name(bigint)

Returns: text

Language: PLPGSQL

 DECLARE name text; BEGIN IF $1 IS NULL THEN RETURN NULL;  END IF; SELECT group_name INTO name FROM groups WHERE group_id = $1; IF NOT FOUND THEN PERFORM error('IdNotFound', $1, 'group_id', 'group_id2name', 'groups'); END IF; RETURN name; END 

Function: public.group_name2id(text)

Returns: bigint

Language: PLPGSQL

BEGIN
    RETURN group_id FROM groups WHERE group_name = $1;
END

Function: public.hmac(bytea, bytea, text)

Returns: bytea

Language: C

pg_hmac

Function: public.hmac(text, text, text)

Returns: bytea

Language: C

pg_hmac

Function: public.host_service_id2name(bigint)

Returns: text

Language: PLPGSQL

A host_service_id -ből a hivatkozott rekord alapján előállít egy egyedi nevet. Ha nincs ilyen rekord, vagy a paraméter NULL, akkor NULL-lal tér vissza.

DECLARE
    name TEXT;
    proto TEXT;
    prime TEXT;
BEGIN
    IF $1 IS NULL THEN
        return NULL;
    END IF;
    SELECT
            n.node_name || CASE WHEN p.port_name IS NULL THEN '' ELSE ':' || p.port_name END || '.' || s.service_name,
            sprime.service_name,
            sproto.service_name
          INTO name, prime, proto
        FROM host_services hs
        JOIN nodes n USING(node_id)
        JOIN services s USING(service_id)
        LEFT JOIN nports p ON hs.port_id = p.port_id			-- ez lehet NULL
        JOIN services sproto ON hs.proto_service_id = sproto.service_id	-- a 'nil' nevű services a NULL
        JOIN services sprime ON hs.prime_service_id = sprime.service_id	-- a 'nil' nevű services a NULL
        WHERE host_service_id = $1;
    IF NOT FOUND THEN
        -- PERFORM error('IdNotFound', $1, 'host_service_id', 'host_service_id2name()', 'host_services');
        RETURN NULL;
    END IF;
    IF proto = 'nil' AND prime = 'nil' THEN
        RETURN name;
    ELSIF proto = 'nil' THEN
        RETURN name || '(:' || prime || ')';
    ELSIF prime = 'nil' THEN
        RETURN name || '(' || proto || ':)';
    ELSE
        RETURN name || '(' || proto || ':' || prime || ')';
    END IF;
END;

Function: public.iftype_id2name(bigint)

Returns: text

Language: PLPGSQL

 DECLARE name text; BEGIN IF $1 IS NULL THEN RETURN NULL;  END IF; SELECT iftype_name INTO name FROM iftypes WHERE iftype_id = $1; IF NOT FOUND THEN PERFORM error('IdNotFound', $1, 'iftype_id', 'iftype_id2name', 'iftypes'); END IF; RETURN name; END 

Function: public.iftype_name2id(itn text)

Returns: bigint

Language: PLPGSQL

DECLARE
    n bigint;
BEGIN
    BEGIN
        SELECT iftype_id INTO n FROM iftypes WHERE iftype_name = itn;
        EXCEPTION
            WHEN NO_DATA_FOUND THEN     -- nem találtunk
                PERFORM error('NameNotFound', -1, 'iftype_name = ' || itn, 'iftype_name2id(itn text)', 'iftypes', NULL);
    END;
    RETURN n;
END;

Function: public.image_id2name(bigint)

Returns: text

Language: PLPGSQL

 DECLARE name text; BEGIN IF $1 IS NULL THEN RETURN NULL;  END IF; SELECT image_name INTO name FROM images WHERE image_id = $1; IF NOT FOUND THEN PERFORM error('IdNotFound', $1, 'image_id', 'image_id2name', 'images'); END IF; RETURN name; END 

Function: public.insert_error(text, bigint, text, text, text, text)

Returns: db_errs

Language: PLPGSQL

DECLARE
    er errors%ROWTYPE;
    ui   bigint;
    subc bigint := $2;
    subm text    := $3;
    srcn text    := $4;
    tbln text    := $5;
    trgn text    := $6;
    re  db_errs%ROWTYPE;
BEGIN
    IF subc IS NULL THEN subc := -1;    END IF;
    IF subm IS NULL THEN subm := 'nil'; END IF;
    IF srcn IS NULL THEN srcn := 'nil'; END IF;
    IF tbln IS NULL THEN tbln := 'nil'; END IF;
    IF trgn IS NULL THEN trgn := 'ext'; END IF;
    er := error_by_name($1);
    SELECT current_setting('lanview2.user_id') INTO ui;
    IF ui = '-1' THEN
        ui := 0;	-- nobody
    END IF;
    INSERT INTO db_errs
	      (error_id, user_id, table_name, trigger_op, err_subcode, err_msg, func_name)
	   VALUES
	      (er.error_id, ui, tbln, trgn, subc, subm, srcn)
	   RETURNING * INTO re;
    RETURN re;
END;

Function: public.int2dow(integer)

Returns: dayofweek

Language: PLPGSQL

BEGIN
    CASE $1
        WHEN 0  THEN  RETURN 'sunday';
        WHEN 1  THEN  RETURN 'monday';
        WHEN 2  THEN  RETURN 'tuesday';
        WHEN 3  THEN  RETURN 'wednesday';
        WHEN 4  THEN  RETURN 'thursday';
        WHEN 5  THEN  RETURN 'friday';
        WHEN 6  THEN  RETURN 'saturday';
        ELSE          RETURN NULL;
    END CASE;
END;

Function: public.ip2full_port_name(ip inet)

Returns: text

Language: PLPGSQL

DECLARE
    nn text[];
BEGIN
    nn = ARRAY(
        SELECT node_name || ':' || port_name
            FROM interfaces
            JOIN ip_addresses USING(port_id)
            JOIN nodes USING(node_Id)
            WHERE address = ip
            ORDER BY node_name ASC, port_name ASC
        );
    IF array_length(nn, 1) = 0 THEN
        RETURN NULL;
    END IF;
    RETURN array_to_string(nn, ', ');
END;

Function: public.is_content_arp(mac macaddr)

Returns: boolean

Language: PLPGSQL

Megvizsgálja, hogy a paraméterként megadott MAC által azonosítptt arps rekord létezik-e. Ha igen true-val, ellenkező esetben false-val tér vissza.

BEGIN
    RETURN 0 <> COUNT(*) FROM arps WHERE hwaddress = mac;
END;

Function: public.is_content_oui(mac macaddr)

Returns: boolean

Language: PLPGSQL

Megvizsgálja, hogy a paraméterként megadott MAC első 3 byte-ja által azonosítptt OUI rekord létezik-e. Ha igen true-val, ellenkező esetben false-val tér vissza.

BEGIN
    RETURN 0 <> COUNT(*) FROM ouis WHERE oui = trunc(mac);
END;

Function: public.is_dyn_addr(inet)

Returns: bigint

Language: PLPGSQL

Ellenőrzi, hogy a paraméterként megadott IP cím része-e egy dinamikus IP tartománynak

DECLARE
    id  bigint;
BEGIN
    SELECT dyn_addr_range_id INTO id FROM dyn_addr_ranges WHERE exclude = false AND begin_address <= $1 AND $1 <= end_address;
    IF NOT FOUND THEN
        RETURN NULL;
    END IF;
    IF 0 < COUNT(*) FROM dyn_addr_ranges WHERE exclude = true  AND begin_address <= $1 AND $1 <= end_address THEN
        RETURN NULL;
    END IF;
    RETURN id;
END;

Function: public.is_linked(mac bigint, pid macaddr)

Returns: boolean

Language: PLPGSQL

Megvizsgálja, hogy a port címtábla lekérdezés eredményeként kapott MAC címnek megfelelő log_links táblabejegyzés is létezik-e. Paraméterek: pid A port id, melynek a címtáblájából a MAC származik. mac A címtáblából kiolvasott MAC cím. Visszaadott érték: Ha megtalálta a port_id és MAC párossal egyenértékű rekordot, akkor true, ha nem akkor false. Ha több rekord is megfeleltethető, ami elvileg lehetetlen, akkor dob egy kizárást.

DECLARE
    n integer;
BEGIN
    SELECT COUNT(*) INTO n FROM log_links JOIN interfaces ON log_links.port_id2 = interfaces.port_id WHERE log_links.port_id1 = pid AND interfaces.hwaddress = mac;
    CASE n
    WHEN 1 THEN
        RETURN true;
    WHEN 0 THEN
        RETURN false;
    ELSE
        PERFORM error('DataError', n, 'MAC is not unique', 'is_linked(bigint, macaddr)', 'interfaces, log_links');
    END CASE;
END;

Function: public.is_noalarm(tm public.noalarmtype, tm_to timestamp without time zone, tm_from timestamp without time zone, flg timestamp without time zone)

Returns: isnoalarm

Language: PLPGSQL

BEGIN
    CASE
        WHEN  flg = 'off'                                       THEN RETURN  'off';      -- Nincs tiltás
        WHEN  flg = 'on'                                        THEN RETURN  'on';      -- Időkorlát nélküli tiltás
        WHEN (flg = 'to' OR flg = 'from_to') AND tm >  tm_to    THEN RETURN  'expired'; -- Már lejárt
        WHEN  flg = 'to'                     AND tm <= tm_to    THEN RETURN  'on';      -- Tiltás
        WHEN                                     tm >= tm_from  THEN RETURN  'on';      -- Tiltás
        WHEN                                     tm <  tm_from  THEN RETURN  'off';     -- Még nem lépett életbe
    END CASE;
END

Function: public.is_parent_place(idq bigint, idr bigint)

Returns: boolean

Language: PLPGSQL

Lekérdezi, hogy az idr azonosítójú places rekord parentje-e az idq-azonosítójúnak.

DECLARE
    n integer;
    id bigint := idr;
BEGIN
    n := 0;
    LOOP
        IF id = idq THEN
            RETURN TRUE;
        END IF;
        n := n + 1;
        IF N > 10 THEN
            PERFORM error('Loop', idr, '', 'is_parent_place()', 'places');
        END IF;
        SELECT parent_id INTO id FROM places WHERE place_id = id;
        IF NOT FOUND OR idr IS NULL THEN
            RETURN FALSE;
        END IF;
    END LOOP;
END

Function: public.is_place_in_zone(idq bigint, idr bigint)

Returns: boolean

Language: PLPGSQL

Lekérdezi, hogy az idr azonosítójú places tagja-e az grn-nevű place_groups zónának, vagy valamelyik parentje tag-e

DECLARE
    n integer;
BEGIN
    CASE idq
        WHEN 0 THEN -- none
            RETURN FALSE;
        WHEN 1 THEN -- all
            RETURN TRUE;
        ELSE
            SELECT COUNT(*) INTO n FROM place_group_places WHERE place_group_id = idq AND (place_id = idr OR is_parent_place(idr, place_id));
            RETURN n > 0;
    END CASE;
END

Function: public.language_id2code(lid bigint)

Returns: text

Language: PLPGSQL

DECLARE
    n text;
BEGIN
    SELECT lang_2 || '_' || country_a2 INTO n FROM languages WHERE language_id = lid;
    IF NOT FOUND THEN
        PERFORM error('IdNotFound', lid, 'language_id', 'language_id2name()', 'languages');
    END IF;
    RETURN n;
END;

Function: public.language_id2name(bigint)

Returns: text

Language: PLPGSQL

 DECLARE name text; BEGIN IF $1 IS NULL THEN RETURN NULL;  END IF; SELECT language_name INTO name FROM languages WHERE language_id = $1; IF NOT FOUND THEN PERFORM error('IdNotFound', $1, 'language_id', 'language_id2name', 'languages'); END IF; RETURN name; END 

Function: public.link_type(bigint, bigint, public.linktype)

Returns: linktype

Language: PLPGSQL

DECLARE
    plt1   linktype;
    plt2   linktype;
BEGIN
    IF $3 IS NOT NULL THEN
        RETURN $3;
    END IF;
    -- Port link típus lekérése, Ellenőrizni már nem kell
    plt1 := iftype_link_type FROM nports JOIN iftypes USING (iftype_id) WHERE port_id = $1;
    plt2 := iftype_link_type FROM nports JOIN iftypes USING (iftype_id) WHERE port_id = $2;
    CASE
        WHEN plt1 = 'patch' AND plt2 = 'patch' THEN
            RETURN 'ptp';
        WHEN plt1 = 'patch' THEN
            RETURN plt2;
        WHEN plt2 = 'patch' THEN
            RETURN plt1;
        ELSE
            RETURN link_type12(plt1, plt2);
    END CASE;
    RETURN NULL;
END;

Function: public.link_type12(public.linktype, public.linktype)

Returns: linktype

Language: PLPGSQL

BEGIN
    IF $1 <> $2 THEN
        PERFORM error('Collision', -1, $1 || ' <> ' || $2, 'link_type', 'phs_links_table');
    END IF;
    RETURN $1;
END;

Function: public.localization_texts(tft bigint, tid public.tablefortext)

Returns: localizations

Language: PLPGSQL

DECLARE
    r   localizations;
    lid integer;
    lids integer[];
BEGIN
    lid := get_language_id();	-- actual
    SELECT * INTO r FROM localizations WHERE text_id = tid AND language_id = lid;
    IF FOUND THEN
        RETURN r;
    END IF;
    lids := ARRAY[lid];
    SELECT next_id INTO lid FROM languages WHERE language_id = lid;    -- next
    IF lid IS NOT NULL THEN
        SELECT * INTO r FROM localizations WHERE text_id = tid AND table_for_text = tft AND language_id = lid;
        IF FOUND THEN
            RETURN r;
        END IF;
    END IF;
    lids := lids || lid;
    SELECT language_id INTO lid FROM languages WHERE language_name = get_text_sys_param('default_language');	-- default
    IF lid IS NOT NULL AND NOT lid = ANY (lids) THEN
        SELECT * INTO r FROM localizations WHERE text_id = tid AND table_for_text = tft AND language_id = lid;
        IF FOUND THEN
            RETURN r;
        END IF;
    END IF;
    lids := lids || lid;
    SELECT language_id INTO lid FROM languages WHERE language_name = get_text_sys_param('failower_language');	-- failower
    IF lid IS NOT NULL AND NOT lid = ANY (lids) THEN
        SELECT * INTO r FROM localizations WHERE text_id = tid AND table_for_text = tft AND language_id = lid;
        IF FOUND THEN
            RETURN r;
        END IF;
    END IF;
    -- any
    SELECT * INTO r FROM localizations WHERE text_id = tid AND table_for_text = tft LIMIT 1;
    IF FOUND THEN
        RETURN r;
    END IF;
    r.text_id := tid;
    r.language_id := lids[1];
    -- r.texts := ARRAY['Unknown text id ' || tft || '#' || tid::text];
    return r;
END;

Function: public.mac2full_port_name(mac macaddr)

Returns: text

Language: PLPGSQL

DECLARE
    nn text[];
BEGIN
    nn = ARRAY(
        SELECT node_name || ':' || port_name
            FROM interfaces
            JOIN nodes USING(node_Id)
            WHERE hwaddress = mac
            ORDER BY node_name ASC, port_name ASC
        );
    IF array_length(nn, 1) = 0 THEN
        RETURN NULL;
    END IF;
    RETURN array_to_string(nn, ', ');
END;

Function: public.mac2node_name(mac macaddr)

Returns: text

Language: PLPGSQL

DECLARE
    nn text;
BEGIN
    SELECT node_name INTO nn 
        FROM interfaces
        JOIN nodes USING(node_Id)
        WHERE hwaddress = mac
        LIMIT 1;
    IF NOT FOUND THEN
        RETURN NULL;
    END IF;
    RETURN nn;
END;

Function: public.mactab_changestat(rt public.mactab, typ public.mactabstate[], mst public.settype, mt boolean)

Returns: reasons

Language: PLPGSQL

BEGIN
    IF typ IS NULL THEN
        typ := mt.set_type;
    END IF;
    IF mst <@ mt.mactab_state AND mst @> mt.mactab_state AND typ = mt.set_type THEN
        IF rt THEN
            UPDATE mactab SET last_time = CURRENT_TIMESTAMP, state_updated_time = CURRENT_TIMESTAMP WHERE hwaddress = mt.hwaddress;
        ELSE
            UPDATE mactab SET state_updated_time = CURRENT_TIMESTAMP WHERE hwaddress = mt.hwaddress;
        END IF;
        RETURN 'unchange';
    END IF;
    INSERT INTO mactab_logs(hwaddress, reason, port_id_old, mactab_state_old, first_time_old, last_time_old, set_type_old, port_id_new, mactab_state_new, set_type_new)
           VALUES       (mt.hwaddress,'modify',mt.port_id,  mt.mactab_state,  mt.first_time,  mt.last_time,  mt.set_type,  mt.port_id,  mst,              typ);
    IF rt THEN
        UPDATE mactab SET mactab_state = mst, last_time = CURRENT_TIMESTAMP, state_updated_time = CURRENT_TIMESTAMP  WHERE hwaddress = mt.hwaddress;
    ELSE
        UPDATE mactab SET mactab_state = mst, state_updated_time = CURRENT_TIMESTAMP WHERE hwaddress = mt.hwaddress;
    END IF;
    RETURN 'update';
END;

Function: public.mactab_move(mst public.mactab, typ bigint, mac macaddr, pid public.settype, mt public.mactabstate[])

Returns: void

Language: PLPGSQL

BEGIN
    INSERT INTO mactab_logs(hwaddress, reason, port_id_old, mactab_state_old, first_time_old, last_time_old, set_type_old, port_id_new, mactab_state_new, set_type_new)
           VALUES         (mac,       'move', mt.port_id,  mt.mactab_state,  mt.first_time,  mt.last_time,  mt.set_type,  pid,         mst,              typ);
    UPDATE mactab SET port_id = pid, mactab_state = mst, first_time = CURRENT_TIMESTAMP, last_time = CURRENT_TIMESTAMP, state_updated_time = CURRENT_TIMESTAMP
            WHERE hwaddress = mac;
END;

Function: public.mactab_remove(re public.mactab, mt public.reasons)

Returns: void

Language: PLPGSQL

BEGIN
    INSERT INTO mactab_logs(hwaddress, reason, port_id_old, mactab_state_old, first_time_old, last_time_old, set_type_old)
           VALUES       (mt.hwaddress, re,     mt.port_id,  mt.mactab_state,  mt.first_time,  mt.last_time,  mt.set_type);
    DELETE FROM mactab WHERE hwaddress = mt.hwaddress;
END;

Function: public.menu_item_id2name(bigint)

Returns: text

Language: PLPGSQL

 DECLARE name text; BEGIN IF $1 IS NULL THEN RETURN NULL;  END IF; SELECT menu_item_name INTO name FROM menu_items WHERE menu_item_id = $1; IF NOT FOUND THEN PERFORM error('IdNotFound', $1, 'menu_item_id', 'menu_item_id2name', 'menu_items'); END IF; RETURN name; END 

Function: public.min_shared(public.portshare, public.portshare)

Returns: portshare

Language: PLPGSQL

Legkisebb SHARE meghatározása, ha a két share kombináció nem ad semmilyen összeköttetést, akkor NC

BEGIN
    RETURN CASE
        WHEN $1 IS NULL OR $2 IS NULL THEN
            'NC'
        WHEN $1 = 'NC'  OR $2 = 'NC'  THEN
            'NC'
        WHEN $1 = '' OR $1 = $2 THEN
            $2
        WHEN $2 = '' THEN
            $1
        WHEN $1 < $2
         AND (   ( $1 = 'A' AND ( $2 = 'AA' OR $2 = 'AB' ) )
	      OR ( $1 = 'B' AND ( $2 = 'BA' OR $2 = 'BB' ) )) THEN
            $2
        WHEN $1 > $2
         AND (   ( $2 = 'A' AND ( $1 = 'AA' OR $1 = 'AB' ) )
	      OR ( $2 = 'B' AND ( $1 = 'BA' OR $1 = 'BB' ) )) THEN
            $1
        ELSE
            'NC'
     END;
END;

Function: public.names2language_id(l character varying, c character varying)

Returns: integer

Language: PLPGSQL

DECLARE
    id integer;
BEGIN
    SELECT language_id INTO id FROM languages WHERE l = lang_2 AND c = country_a2;
    IF NOT FOUND THEN
        PERFORM error('NameNotFound', -1, c || '_' || l, 'names2language_id()', 'languages');
    END IF;
    RETURN id;
END;

Function: public.next_dow(public.dayofweek)

Returns: dayofweek

Language: PLPGSQL

DECLARE
    dows  dayofweek[];
BEGIN
    dows = enum_range($1);
    IF array_length(dows, 1) > 1 THEN
        RETURN dows[1];
    ELSE
        RETURN enum_first($1);
    END IF;
END;

Function: public.next_patch(sh bigint, link_type public.phslinktype, pid public.portshare)

Returns: phs_links

Language: PLPGSQL

Find the next link. It assumes that the first port_id parameter identifies a patch port. The direction of the search link is determined by the second parameter, which belongs to the current link, that is 'front' in the direction of the back, in the direction of 'back' in the front panel. Returned value is the recorded phs_links record, or NULL. In the return record, the port_shared field is modified, the value is set as the parameter, and the scanned the result of sharing. If there are multiple possible link records, the lowest share returns the function (if there is one A and B, then A), the rest of the records can be obtained by modifying the second parameter. List of additional shares found in the note field.

DECLARE
    port        pports;         -- patch port rekord
    osh         portshare;      -- Result sharing
    tsh         portshare;      -- temp.
    orec        phs_links;      -- Returned value. Modified phs_links record
    trec        phs_links;      -- temp.
    f           boolean;
BEGIN
    osh := sh;
    BEGIN   -- Get patch port record
        SELECT * INTO STRICT port FROM pports WHERE port_id = pid;
        EXCEPTION
            WHEN NO_DATA_FOUND THEN     -- Not found. Incorrect parameter.
                PERFORM error('NotFound', pid, 'port_id', 'next_phs_link()', 'pports');
            WHEN TOO_MANY_ROWS THEN     -- Incredible, Database data error
                PERFORM error('Ambiguous',pid, 'port_id', 'next_phs_link()', 'pports');
    END;
    RAISE INFO 'port = %:%/%/%', node_id2name(port.node_id), port.port_name, link_type, sh;
    IF link_type = 'Front' THEN        -- If Front, then go back
        RAISE INFO 'Is Front, go back';
        IF port.shared_cable <> '' THEN             -- Share ?
            osh := min_shared(port.shared_cable, sh);
            IF osh = 'NC' THEN  -- There is no connection
                RAISE INFO 'RETURN: osh = NC';
                RETURN NULL;         -- NULL, No next
            END IF;
            -- Fetch, real port, if shared cable
            IF port.shared_port_id IS NOT NULL THEN
                SELECT * INTO port FROM pports WHERE port_id = port.shared_port_id;
            END IF;
        END IF;
        BEGIN -- Back link. Only one can be
            SELECT * INTO STRICT orec FROM phs_links
                WHERE port_id1 = port.port_id AND phs_link_type1 = 'Back';
            EXCEPTION
                WHEN NO_DATA_FOUND THEN -- No next
                    RAISE INFO 'RETURN: NULL (break)';
                    RETURN NULL;
                WHEN TOO_MANY_ROWS THEN -- Incredible. Database data error
                    PERFORM error('Ambiguous', -1, 'port_id1', 'next_phs_link()', 'phs_links');
        END;
        orec.port_shared   := min_shared(orec.port_shared, osh);    -- Result share
        orec.phs_link_note := NULL;                                 -- There are no branches
        RAISE INFO 'next_patch() RETURN osh = "%"; orec : id = % %/% -> %/%',
            orec.port_shared, orec.phs_link_id, orec.phs_link_type1, orec.port_id1, orec.phs_link_type2, orec.port_id2;
        RETURN orec;
    ELSIF link_type = 'Back' THEN          -- If back, then go front
        RAISE INFO 'Is Back, go Front; %/%', port, sh;
        pid := COALESCE(port.shared_port_id, pid);
        RAISE INFO 'Base port_id : %', pid;
        f   := false;  -- Found
        orec := NULL;
        FOR trec IN SELECT * FROM phs_links WHERE port_id1 IN (SELECT port_id FROM pports WHERE shared_port_id = pid OR port_id = pid) AND phs_link_type1 = 'Front' ORDER BY port_shared ASC LOOP
            SELECT shared_cable INTO tsh FROM pports WHERE port_id = trec.port_id1;
            RAISE INFO 'for : phs_link_id = %, port_shared = %,%', trec.phs_link_id, trec.port_shared, tsh;
            tsh := min_shared(tsh, osh);
            tsh := min_shared(tsh, trec.port_shared);
            IF tsh <> 'NC' THEN
                IF f THEN   -- More results, shared value(s) -> note
                    IF orec.phs_link_note IS NULL THEN
                        orec.phs_link_note := tsh::text;
                    ELSE
                        orec.phs_link_note := orec.phs_link_note || ',' || tsh::text;
                    end if;
                ELSE    -- The first result is the result
                    orec := trec;
                    orec.port_shared   := tsh;
                    orec.phs_link_note := NULL;
                    f := true;
                END IF;
            END IF;
        END LOOP;
        RAISE INFO 'RETURN sh = "%"/[%]; rrec id = % % -> %',
            orec.port_shared, orec.phs_link_note, orec.phs_link_id, orec.port_id1, orec.port_id2;
        RETURN orec;
    ELSE
        -- Is not patch. Incorrect parameter.
        PERFORM error('Params', -1, 'phs_link_type2', 'next_phs_link', 'phs_links');
    END IF;
END;

Function: public.next_phs_link(dir public.phs_links, sh public.portshare, rec public.linkdirection)

Returns: phs_links

Language: PLPGSQL

A következő link keresése. A második paraméter az eddigi eredő megosztás. A harmadik paraméter határozza meg milyen irányba kell menni: 'Right' esetén a második porton kell tovább lépni, egyébként az elsőn. A visszaadott érték a talált phs_links rekord, vagy NULL. A visszaadott rekordban a port_shared mező modosítva lessz, értéke a paraméterként megadott, és a beolvasott megosztás eredője. Ha több lehetséges link rekord van, akkor a legalacsonyabb megosztás értéküt adja vissza a függvény (ha van egy A és B, akkor az A-t),a többi rekordot a második paraméter modosításával kaphatjuk vissza. A hívás feltételezi, hogy az irányba eső port egy patch port.

DECLARE
    pid         bigint;        -- port_id a megadott irányban
    link_type   phslinktype;    -- link/csatlakozás típusa a megadott irányban
BEGIN
    IF dir = 'Right' THEN
        pid         := rec.port_id2;
        link_type   := rec.phs_link_type2;
    ELSE
        pid         := rec.port_id1;
        link_type   := rec.phs_link_type1;
    END IF;
    RETURN next_patch(pid, link_type, sh);
END;

Function: public.node2snmpdevice(nid bigint)

Returns: snmpdevices

Language: PLPGSQL

Egy létező nodes rekord konvertálása/mozgatása az snmpdefices táblába, a tulajdonában lévő objektumok megtartásával.

DECLARE
    node  nodes;
    ntype nodetype[];
    snmpdev snmpdevices;
BEGIN
    SELECT * INTO node FROM ONLY nodes WHERE node_id = nid;
    IF NOT FOUND THEN
        PERFORM error('IdNotFound', nid, 'node_id', 'node2snmpdevice(bigint)', 'nodes');
        RETURN NULL;
    END IF;
    UPDATE node_params   SET node_id = -nid WHERE node_id = nid;
    UPDATE nports        SET node_id = -nid WHERE node_id = nid;
    UPDATE host_services SET node_id = -nid WHERE node_id = nid;
    DELETE FROM nodes WHERE node_id = nid;
    ntype := array_append(node.node_type, 'snmp'::nodetype);
    ntype := array_replace(ntype, 'node'::nodetype, 'host'::nodetype);
    INSERT INTO
        snmpdevices(node_id, node_name, node_note, node_type, place_id, features, deleted,
            inventory_number, serial_number, model_number, model_name, location,
            node_stat, os_name, os_version)
        VALUES(nid, node.node_name, node.node_note, ntype, node.place_id, node.features, node.deleted,
            node.inventory_number, node.serial_number, node.model_number, node.model_name, node.location,
            node.node_stat, node.os_name, node.os_version)
        RETURNING * INTO snmpdev;
    UPDATE node_params   SET node_id = nid WHERE node_id = -nid;
    UPDATE nports        SET node_id = nid WHERE node_id = -nid;
    UPDATE host_services SET node_id = nid WHERE node_id = -nid;
    RETURN snmpdev;
END

Function: public.node_check_before_insert()

Returns: trigger

Language: PLPGSQL

DECLARE
    n bigint;
BEGIN
--  RAISE INFO 'Insert NODE, new id = %', NEW.node_id;
    SELECT COUNT(*) INTO n FROM patchs WHERE node_id = NEW.node_id;
    IF n > 0 THEN
        PERFORM error('IdNotUni', NEW.node_id, 'node_id', 'node_check_before_insert()', TG_TABLE_NAME, TG_OP);
    END IF;
    SELECT COUNT(*) INTO n FROM patchs WHERE node_name = NEW.node_name;
    IF n > 0 THEN
        PERFORM error('NameNotUni', -1, 'node_name = ' || NEW.node_name, 'node_check_before_insert()', TG_TABLE_NAME, TG_OP);
    END IF;
    CASE TG_TABLE_NAME
        WHEN 'patchs' THEN
            NEW.node_type = '{patch}';  -- constant field
        WHEN 'nodes' THEN
            IF NEW.node_type IS NULL THEN
                NEW.node_type = '{node}';
            END IF;
            IF 'patch'::nodetype = ANY (NEW.node_type) THEN
                PERFORM error('DataError', NEW.node_id, 'node_type', 'node_check_before_insert()', TG_TABLE_NAME, TG_OP);
            END IF;
        WHEN 'snmpdevices' THEN
            IF NEW.node_type IS NULL THEN
                NEW.node_type = '{host,snmp}';
            END IF;
            IF 'patch'::nodetype = ANY (NEW.node_type) THEN
                PERFORM error('DataError', NEW.node_id, 'node_type', 'node_check_before_insert()', TG_TABLE_NAME, TG_OP);
            END IF;
        ELSE
            PERFORM error('DataError', NEW.node_id, 'node_id', 'node_check_before_insert()', TG_TABLE_NAME, TG_OP);
    END CASE;
    RETURN NEW;
END;

Function: public.node_check_before_update()

Returns: trigger

Language: PLPGSQL

DECLARE
    n bigint;
BEGIN
    IF NEW.node_id <> OLD.node_id THEN
        PERFORM error('Constant', NEW.node_id, 'node_id', 'node_check_before_update()', TG_TABLE_NAME, TG_OP);
    END IF;
    IF NEW.node_name <> OLD.node_name THEN
        SELECT COUNT(*) INTO n FROM patchs WHERE node_name = NEW.node_name;
        IF n > 0 THEN
            PERFORM error('NameNotUni', NEW.node_id, 'node_name = ' || NEW.node_name, 'node_check_before_update()', TG_TABLE_NAME, TG_OP);
        END IF;
    END IF;
    IF NEW.serial_number IS NOT NULL AND  NEW.serial_number <> OLD.serial_number THEN
        SELECT COUNT(*) INTO n FROM patchs WHERE serial_number = NEW.serial_number;
        IF n > 0 THEN
            PERFORM error('NameNotUni', NEW.node_id, 'serial_number = ' || NEW.serial_number, 'node_check_before_update()', TG_TABLE_NAME, TG_OP);
        END IF;
    END IF;
    IF NEW.inventory_number IS NOT NULL AND  NEW.inventory_number <> OLD.inventory_number THEN
        SELECT COUNT(*) INTO n FROM patchs WHERE inventory_number = NEW.inventory_number;
        IF n > 0 THEN
            PERFORM error('NameNotUni', NEW.node_id, 'inventory_number = ' || NEW.inventory_number, 'node_check_before_update()', TG_TABLE_NAME, TG_OP);
        END IF;
    END IF;
    RETURN NEW;
END;

Function: public.node_id2name(bigint)

Returns: text

Language: PLPGSQL

DECLARE
    id text;
BEGIN
    IF $1 IS NULL THEN
        return NULL;
    END IF;
    SELECT node_name INTO id FROM patchs WHERE node_id = $1;
    IF NOT FOUND THEN
        PERFORM error('IdNotFound', $1, 'node_id', 'node_id2name()', 'patchs');
    END IF;
    RETURN id;
END

Function: public.node_id2table_name(bigint)

Returns: text

Language: PLPGSQL

BEGIN
    RETURN relname FROM patchs JOIN pg_class ON patchs.tableoid = pg_class.oid WHERE node_id = $1;
END

Function: public.node_name2id(text)

Returns: bigint

Language: PLPGSQL

DECLARE
    id bigint;
BEGIN
    SELECT node_id INTO id FROM patchs WHERE node_name = $1 AND deleted = false;
    IF NOT FOUND THEN
        PERFORM error('NameNotFound', -1, $1, 'node_name2id()', 'patchs');
    END IF;
    RETURN id;
END

Function: public.param_type_id2name(bigint)

Returns: text

Language: PLPGSQL

 DECLARE name text; BEGIN IF $1 IS NULL THEN RETURN NULL;  END IF; SELECT param_type_name INTO name FROM param_types WHERE param_type_id = $1; IF NOT FOUND THEN PERFORM error('IdNotFound', $1, 'param_type_id', 'param_type_id2name', 'param_types'); END IF; RETURN name; END 

Function: public.param_type_name2id(text)

Returns: bigint

Language: PLPGSQL

DECLARE
    id bigint;
BEGIN
    SELECT param_type_id INTO id FROM param_types WHERE param_type_name = $1;
    IF NOT FOUND THEN
        PERFORM error('NameNotFound', -1, $1, 'param_type_name2id()', 'param_types');
    END IF;
    RETURN id;
END

Function: public.pgp_armor_headers(value text)

Returns: SET OF record

Language: C

pgp_armor_headers

Function: public.pgp_key_id(bytea)

Returns: text

Language: C

pgp_key_id_w

Function: public.pgp_pub_decrypt(bytea, bytea)

Returns: text

Language: C

pgp_pub_decrypt_text

Function: public.pgp_pub_decrypt(bytea, bytea, text)

Returns: text

Language: C

pgp_pub_decrypt_text

Function: public.pgp_pub_decrypt(bytea, bytea, text, text)

Returns: text

Language: C

pgp_pub_decrypt_text

Function: public.pgp_pub_decrypt_bytea(bytea, bytea)

Returns: bytea

Language: C

pgp_pub_decrypt_bytea

Function: public.pgp_pub_decrypt_bytea(bytea, bytea, text)

Returns: bytea

Language: C

pgp_pub_decrypt_bytea

Function: public.pgp_pub_decrypt_bytea(bytea, bytea, text, text)

Returns: bytea

Language: C

pgp_pub_decrypt_bytea

Function: public.pgp_pub_encrypt(text, bytea)

Returns: bytea

Language: C

pgp_pub_encrypt_text

Function: public.pgp_pub_encrypt(text, bytea, text)

Returns: bytea

Language: C

pgp_pub_encrypt_text

Function: public.pgp_pub_encrypt_bytea(bytea, bytea)

Returns: bytea

Language: C

pgp_pub_encrypt_bytea

Function: public.pgp_pub_encrypt_bytea(bytea, bytea, text)

Returns: bytea

Language: C

pgp_pub_encrypt_bytea

Function: public.pgp_sym_decrypt(bytea, text)

Returns: text

Language: C

pgp_sym_decrypt_text

Function: public.pgp_sym_decrypt(bytea, text, text)

Returns: text

Language: C

pgp_sym_decrypt_text

Function: public.pgp_sym_decrypt_bytea(bytea, text)

Returns: bytea

Language: C

pgp_sym_decrypt_bytea

Function: public.pgp_sym_decrypt_bytea(bytea, text, text)

Returns: bytea

Language: C

pgp_sym_decrypt_bytea

Function: public.pgp_sym_encrypt(text, text)

Returns: bytea

Language: C

pgp_sym_encrypt_text

Function: public.pgp_sym_encrypt(text, text, text)

Returns: bytea

Language: C

pgp_sym_encrypt_text

Function: public.pgp_sym_encrypt_bytea(bytea, text)

Returns: bytea

Language: C

pgp_sym_encrypt_bytea

Function: public.pgp_sym_encrypt_bytea(bytea, text, text)

Returns: bytea

Language: C

pgp_sym_encrypt_bytea

Function: public.phs_link_type(bigint, public.phslinktype)

Returns: phslinktype

Language: PLPGSQL

DECLARE
    itlt    linktype;
BEGIN
    BEGIN
        -- Link típus lekérése, egyben ellenőrizzük van-e ilyen port egyáltalán
        SELECT iftype_link_type INTO STRICT itlt FROM nports JOIN iftypes USING (iftype_id) WHERE port_id = $1;
        EXCEPTION
            WHEN NO_DATA_FOUND THEN     -- nem találtunk
                PERFORM error('NotFound', -1, 'port_id', 'phs_link_type()', 'phs_links_table', 'INSERT');
            WHEN TOO_MANY_ROWS THEN     -- több találat is van, nem egyértelmű, és nagyon gáz
                PERFORM error('DataError',-1, 'port_id', 'phs_link_type()', 'phs_links_table', 'INSERT');
    END;
    IF $2 IS NULL THEN  -- Nincs megadva link típus
        IF itlt = 'ptp' OR itlt = 'bus' THEN    -- ebben az esetben kitalálható
            RETURN 'Term';                      -- kitaláltuk, és bizonyára jó is, tehát kész
        ELSIF itlt = 'patch' THEN               -- nem egyértelmű
            PERFORM error('Ambiguous', -1, 'phs_link_type', 'phs_link_type()', 'phs_links_table');
        ELSE                                    -- Nem is lehet linkje
            PERFORM error('Params', -1, 'phs_link_type', 'phs_link_type()', 'phs_links_table');
        END IF;
    END IF;
    IF $2 = 'Term' AND ( itlt = 'ptp' OR itlt = 'bus' ) THEN
        RETURN $2;  -- OK
    ELSIF ( $2 = 'Front' OR $2 = 'Back' ) AND itlt = 'patch' THEN
        RETURN $2;  -- OK
    END IF;
    PERFORM error('Params', -1, 'iftype_link_type = ' || itlt || ', phs_link_type = ' || $2, 'phs_link_type()', 'phs_links_table', 'INSERT');
    RETURN NULL;
END;

Function: public.place_group_id2name(bigint)

Returns: text

Language: PLPGSQL

 DECLARE name text; BEGIN IF $1 IS NULL THEN RETURN NULL;  END IF; SELECT place_group_name INTO name FROM place_groups WHERE place_group_id = $1; IF NOT FOUND THEN PERFORM error('IdNotFound', $1, 'place_group_id', 'place_group_id2name', 'place_groups'); END IF; RETURN name; END 

Function: public.place_id2name(bigint)

Returns: text

Language: PLPGSQL

 DECLARE name text; BEGIN IF $1 IS NULL THEN RETURN NULL;  END IF; SELECT place_name INTO name FROM places WHERE place_id = $1; IF NOT FOUND THEN PERFORM error('IdNotFound', $1, 'place_id', 'place_id2name', 'places'); END IF; RETURN name; END 

Function: public.place_name2id(text)

Returns: bigint

Language: PLPGSQL

DECLARE
    id bigint;
BEGIN
    SELECT place_id INTO id FROM places WHERE place_name = $1;
    IF NOT FOUND THEN
        PERFORM error('NameNotFound', -1, $1, 'place_name2id()', 'places');
    END IF;
    RETURN id;
END

Function: public.port_check_before_insert()

Returns: trigger

Language: PLPGSQL

DECLARE
    n bigint;
    t text;
BEGIN
    SELECT COUNT(*) INTO n FROM nports WHERE port_id = NEW.port_id;
    IF n > 0 THEN
        PERFORM error('IdNotUni', NEW.port_id, 'port_id', 'port_check_before_insert()', TG_TABLE_NAME, TG_OP);
    END IF;
    IF 'pports' = TG_TABLE_NAME THEN
        NEW.iftype_id := iftype_name2id('patch');
    ELSE
        IF NEW.iftype_id = iftype_name2id('patch') THEN
            PERFORM error('DataError', NEW.iftype_id, 'iftype_id', 'port_check_before_insert()', TG_TABLE_NAME, TG_OP);
        END IF;
    END IF;
    SELECT COUNT(*) INTO n FROM nports WHERE port_name = NEW.port_name AND node_id = NEW.node_id;
    IF n > 0 THEN
        PERFORM error('NameNotUni', -1, 'port_name', 'port_check_before_insert()', TG_TABLE_NAME, TG_OP);
    END IF;
    RETURN NEW;
END;

Function: public.port_check_before_update()

Returns: trigger

Language: PLPGSQL

DECLARE
    n bigint;
BEGIN
    IF NEW.port_id <> OLD.port_id THEN
        PERFORM error('Constant', -1, 'port_id', 'check_port_id_before_update()', TG_TABLE_NAME, TG_OP);
    END IF;
    IF ('pports' = TG_TABLE_NAME) <> (NEW.iftype_id = iftype_name2id('patch')) THEN
        PERFORM error('DataError', NEW.iftype_id, 'iftype_id', 'port_check_before_update()', TG_TABLE_NAME, TG_OP);
    END IF;
    IF NEW.port_name <> OLD.port_name THEN
        SELECT COUNT(*) INTO n FROM nports WHERE port_name = NEW.port_name AND node_id = NEW.node_id;
        IF n > 0 THEN
            PERFORM error('NameNotUni', NEW.port_id, 'port_name = ' || NEW.ports_name, 'port_check_before_update()', TG_TABLE_NAME, TG_OP);
        END IF;
    END IF;
    RETURN NEW;
END;

Function: public.port_id2full_name(bigint)

Returns: text

Language: PLPGSQL

DECLARE
    name text;
BEGIN
    IF $1 IS NULL THEN
        return NULL;
    END IF;
    SELECT node_id2name(node_id) || ':' || port_name INTO name FROM nports WHERE port_id = $1;
    IF NOT FOUND THEN
        PERFORM error('IdNotFound', $1, 'port_id', 'port_id2full_name()', 'nports');
    END IF;
    RETURN name;
END

Function: public.port_id2name(bigint)

Returns: text

Language: PLPGSQL

DECLARE
    name text;
BEGIN
    IF $1 IS NULL THEN
        return NULL;
    END IF;
    SELECT port_name INTO name FROM nports WHERE port_id = $1;
    IF NOT FOUND THEN
        PERFORM error('IdNotFound', $1, 'port_id', 'port_id2name()', 'nports');
    END IF;
    RETURN name;
END

Function: public.port_id2table_name(bigint)

Returns: text

Language: PLPGSQL

BEGIN
    RETURN relname FROM nports JOIN pg_class ON nports.tableoid = pg_class.oid WHERE port_id = $1;
END

Function: public.post_insert_phs_links()

Returns: trigger

Language: PLPGSQL

DECLARE
    lid         bigint;             -- phs_link_id
    pid         bigint;             -- port_id a lánc elején
    lrec_r      phs_links;          -- phs_links rekord jobra menet / végpont felöli menet
    lrec_l      phs_links;          -- phs_links rekord balra menet
    psh         portshare;          -- Eredő share
    psh_r       portshare;          -- Mentett eredő share a jobramenet végén
    dir         linkdirection;      -- Végig járási (kezdő) irány
    path_r      bigint[];           -- Linkek (id) lánca, jobra menet, vagy végpontrol menet
    path_l      bigint[];           -- Linkek (id) lánca, barla menet
    shares      portshare[];
    shix        bigint;             -- Index a fenti tömbön
    lt          linktype;
    logl        log_links_table;
BEGIN
    IF TG_OP = 'DELETE' THEN
        -- Delete log_links if exists.
        DELETE FROM log_links_table WHERE OLD.phs_link_id = ANY (phs_link_chain);
        RETURN OLD;
    END IF;
    NEW.forward := false; -- This is always false
    IF TG_OP = 'UPDATE' AND 
                    (OLD.port_id1       = NEW.port_id1       AND OLD.port_id2       = NEW.port_id2      AND
                     OLD.port_shared    = NEW.port_shared    AND
                     OLD.phs_link_type1 = NEW.phs_link_type1 AND OLD.phs_link_type2 = NEW.phs_link_type2)
    THEN    -- There is no significant change
        RETURN NEW;
    END IF;
    NEW.modify_time = NOW();
 -- end to end link is logical link
    IF NEW.phs_link_type1 = 'Term' AND NEW.phs_link_type2 = 'Term' THEN
        RAISE INFO 'Insert logical link record 1-1 ...';
        path_r := ARRAY[NEW.phs_link_id];
        INSERT INTO log_links_table (port_id1,     port_id2,     link_type,     phs_link_chain)
                             VALUES (NEW.port_id1, NEW.port_id2, NEW.link_type, path_r)
                             RETURNING * INTO logl;
        RAISE INFO 'Log links record id = %', logl.log_link_id;
        RETURN NEW;
 -- end to patch : One end of the chain
    ELSIF NEW.phs_link_type1 = 'Term' OR NEW.phs_link_type2 = 'Term' THEN
        -- Direction?
        IF NEW.phs_link_type1 = 'Term' THEN
            dir := 'Right';
            RAISE INFO 'Step from end chain: Right';
            pid := NEW.port_id1;    -- Az innenső végponti port id
        ELSE
            dir := 'Left';
            -- RAISE INFO 'Step from end chain: Left';
            pid := NEW.port_id2;    -- Az innenső végponti port id
        END IF;
        lt  := NEW.link_type;
        psh := NEW.port_shared;
        path_r := ARRAY[NEW.phs_link_id]; -- First link
        lrec_r := NEW;
        LOOP
            RAISE INFO '******* loop : psh = "%" lrec_r: id = %, % -> %',psh, lrec_r.phs_link_id, lrec_r.port_id1, lrec_r.port_id2;
            lrec_r := next_phs_link(lrec_r, psh, dir);
            RAISE INFO 'After call next, psh = "%" lrec_r: id = %, % -> %', psh, lrec_r.phs_link_id, lrec_r.port_id1, lrec_r.port_id2;
            psh := COALESCE(lrec_r.port_shared, 'NC');  -- is result share
            dir := 'Right';     -- The next step always 'Right'
            IF psh = 'NC' THEN     -- no next
                RAISE INFO 'Not found logical link.';
                RETURN NEW;
            END IF;
            RAISE INFO 'Path : [%] <@ [%]', lrec_r.phs_link_id, array_to_string(path_r, ',');
            IF  ARRAY[lrec_r.phs_link_id] <@ path_r  -- Loop ?
             OR array_length(path_r, 1) > 10 THEN    -- Too long chain ?
                PERFORM error('Loop', lrec_r.phs_link_id, 'phs_link_id', 'post_insert_phs_links()', TG_TABLE_NAME, TG_OP);
            END IF;
            path_r := array_append(path_r, lrec_r.phs_link_id);
            IF lrec_r.phs_link_type2 = 'Term' THEN    -- Bingo
                lt := link_type12(lt, lrec_r.link_type);
                RAISE INFO 'Insert logical link record (*)%(%) - %(%) [%]...',
                        port_id2full_name(pid), pid, port_id2full_name(lrec_r.port_id2), lrec_r.port_id2, array_to_string(path_r, ',');
                INSERT INTO log_links_table (port_id1, port_id2,   phs_link_chain, share_result, link_type)
                                     VALUES (pid, lrec_r.port_id2, path_r,         psh,          lt);
                RETURN NEW;
            END IF;
        END LOOP;
 -- patch to patch
    ELSE
        RAISE INFO 'Walk to the right, then to the left, per share.';
        shares := ARRAY['','A','B','AA','AB','BA','BB','C','D'];    -- probe all shares
        WHILE array_length(shares, 1) > 0 LOOP
            path_r := ARRAY[NEW.phs_link_id];           -- The path array for go right, and start point
            path_l := ARRAY[]::bigint[];                -- The path array for go left
            psh    := shares[1];                        -- Pop first share
            shares := shares[2:array_upper(shares,1)];
            lrec_r := NEW;                              -- Start point for right
            lrec_l := NEW;                              -- Start point for left
            dir    := 'Right';                          -- Go right
            RAISE INFO '******** Loop ..., Right chanin share : "%"', psh;
            -- Go right
            LOOP
                RAISE INFO '>>>>>> Loop , psh = "%" lrec_r: id = %, % -> %', psh, lrec_r.phs_link_id, lrec_r.port_id1, lrec_r.port_id2;
                lrec_r := next_phs_link(lrec_r, psh, dir);
                RAISE INFO 'NEXT Right : psh = "%" lrec_r: id = %, % -> %', psh, lrec_r.phs_link_id, lrec_r.port_id1, lrec_r.port_id2;
                psh    := COALESCE(lrec_r.port_shared, 'NC');
                EXIT WHEN psh = 'NC';
                IF  lrec_r.phs_link_id = ANY (path_r)  -- Loop ?
                OR array_length(path_r, 1) > 10 THEN   -- Too long chain ?
                    PERFORM error('Loop', lrec_r.phs_link_id, 'phs_link_id', 'post_insert_phs_links()', TG_TABLE_NAME, TG_OP);
                END IF;
                path_r := array_append(path_r, lrec_r.phs_link_id);
                EXIT WHEN lrec_r.phs_link_type2 = 'Term';    -- Bingo, right
            END LOOP;
            IF psh = 'NC' THEN
                RAISE INFO 'Broken chain to the right';
                CONTINUE;   -- No results, maybe the next
            ELSE
                RAISE INFO 'Right endpoint';
            END IF;
            -- Go left
            dir := 'Left';  -- First step only
            LOOP
                RAISE INFO '<<<<<< Loop , psh = "%" lrec_r: id = %, % -> %', psh, lrec_r.phs_link_id, lrec_r.port_id1, lrec_r.port_id2;
                lrec_l := next_phs_link(lrec_l, psh, dir);
                RAISE INFO 'NEXT Left : psh = "%" lrec_r: id = %, % -> %', psh, lrec_r.phs_link_id, lrec_r.port_id1, lrec_r.port_id2;
                psh := COALESCE(lrec_l.port_shared, 'NC');
                EXIT WHEN psh = 'NC';     -- Broken
                dir := 'Right';
                IF  lrec_l.phs_link_id = ANY (path_l)  -- Loop?
                OR array_length(path_l, 1) > 10 THEN   -- Too long chain ?
                    PERFORM error('Loop', lrec_l.phs_link_id, 'phs_link_id', 'post_insert_phs_links()', TG_TABLE_NAME, TG_OP);
                END IF;
                path_l := array_prepend(lrec_l.phs_link_id, path_l);
                EXIT WHEN lrec_l.phs_link_type2 = 'Term';    -- Bingo, right also.
            END LOOP;
            IF psh <> 'NC' THEN           -- bingo
                lt := link_type12(lrec_r.link_type, lrec_l.link_type);
                path_r := path_l || path_r;
                RAISE INFO 'Insert logical link record %(%) - %(%) [%] ...',
                        port_id2full_name(lrec_l.port_id2), lrec_l.port_id2, port_id2full_name(lrec_r.port_id2), lrec_r.port_id2, array_to_string(path_r, ',');
                INSERT INTO log_links_table (port_id1,        port_id2,        phs_link_chain, share_result, link_type)
                                     VALUES (lrec_l.port_id2, lrec_r.port_id2, path_r,         psh,          lt);
                RAISE INFO 'Call shares_filt(%, %)', shares, psh;
                shares = shares_filt(shares, psh);  -- Drop collisions shares
                RAISE INFO 'Result shares_filt() : %', shares;
            ELSE
                RAISE INFO 'Broken chain to the left';
                -- No results, maybe the next
            END IF;
        END LOOP;
    END IF;
    RETURN NEW;
END;

Function: public.protocol_id2name(bigint)

Returns: text

Language: PLPGSQL

 DECLARE name text; BEGIN IF $1 IS NULL THEN RETURN NULL;  END IF; SELECT protocol_name INTO name FROM ipprotocols WHERE protocol_id = $1; IF NOT FOUND THEN PERFORM error('IdNotFound', $1, 'protocol_id', 'protocol_id2name', 'ipprotocols'); END IF; RETURN name; END 

Function: public.refresh_arps()

Returns: integer

Language: PLPGSQL

Törli azokat a rekordokat az arps táblából, melyeknél a last_time értéke túl régi. A lejárati időintervallumot a "arps_expire_interval" rendszerváltozó tartalmazza. Visszatérési érték a törölt rekordok száma. A törlés oka "expired"lessz.

DECLARE
    a  arps;
    ret integer := 0;
    t timestamp;
BEGIN
    t := now() - get_interval_sys_param('arps_expire_interval');
    FOR a IN SELECT * FROM arps
        WHERE  set_type < 'config'::settype AND last_time < t
    LOOP
        PERFORM arp_remove(a, 'expired');
        ret := ret +1;
    END LOOP;
    RETURN ret;
END;

Function: public.refresh_mactab()

Returns: integer

Language: PLPGSQL

Frissíti a mactab tábla rekordokban a mactab_state mezőket. Törli azokat a rekordokat a mactab táblából, melyeknál a last_time értéke túl régi. A lejárati időintervallumokat a "mactab_suspect_expire_interval", "mactab_reliable_expire_interval" és "mactab_expire_interval" rendszerváltozó tartalmazza. Azt, hogy melyik lejárati idő érvényes, azt a rekord mactab_state mező értéke határozza meg. A törlés oka "expired"lessz. Szintén törl azokat a rekordokat, melyeknél a portra létezik a "query_mac_tab" paraméter hamis értékkel, vagy a "suspected_uplink" paraméter igaz értékkel. Ebben az esetben a törlés oka "discard" lesz. Végül azokat a rekordokat is törli, melyre portokra létezik lldp_links rekord, és nincs a portra "query_mac_tab" paraméter igaz értékkel. Ebben az esetben is "discard" lesz a törlés oka. Visszatérési érték a törölt rekordok száma.

DECLARE
    mt  mactab;
    ret integer := 0;
    t1 timestamp;
    t2 timestamp;
    t3 timestamp;
BEGIN
    t1 := now() - get_interval_sys_param('mactab_check_stat_interval');
    FOR mt IN SELECT * FROM mactab
        WHERE  state_updated_time < t1
    LOOP
        IF 'update' = mactab_changestat(mt, current_mactab_stat(mt.port_id, mt.hwaddress, mt.mactab_state)) THEN
            ret := ret + 1;
        END IF;
    END LOOP;
    
    t1 := now() - get_interval_sys_param('mactab_suspect_expire_interval');
    t2 := now() - get_interval_sys_param('mactab_expire_interval');
    t3 := now() - get_interval_sys_param('mactab_reliable_expire_interval');
    FOR mt IN SELECT * FROM mactab
        WHERE ( last_time < t1  AND     mactab_state && ARRAY['suspect']     ::mactabstate[] )
           OR ( last_time < t2  AND NOT mactab_state && ARRAY['arp','likely']::mactabstate[] )
           OR ( last_time < t3)
    LOOP
	RAISE INFO 'Remove (expired) : %', mt;
        PERFORM mactab_remove(mt, 'expired');
        ret := ret +1;
    END LOOP;
    
    FOR mt IN SELECT DISTINCT(mactab.*)
	FROM mactab
	JOIN port_params USING(port_id)
	JOIN param_types USING(param_type_id)
	WHERE (param_type_name = 'query_mac_tab'    AND NOT cast_to_boolean(param_value, true)) 
	   OR (param_type_name = 'suspected_uplink' AND     cast_to_boolean(param_value, false)) 
    LOOP
	RAISE INFO 'Remove (discard) : %', mt;
        PERFORM mactab_remove(mt, 'discard');
        ret := ret +1;
    END LOOP;

    RETURN ret;
END;

Function: public.replace_arp(hsi inet, stp macaddr, hwa public.settype, ipa bigint)

Returns: reasons

Language: PLPGSQL

A detektált MAC - IP cím pár alapján modosítja az arps táblát, és kezeli a napló táblát is Ellenörzi, és frissíti az ip_addresses táblát is (ha stp = "config", akkor feltételezi, hogy ez egy fixip típusú cím) Ha ütközést észlel, akkor létrehoz egy alarms rekordot (szolgáltatás : ticket, host_service_id = 0). Paraméterek: ipa IP cím hwa MAC stp adat forrás, default "query" hsi opcionális host_service_id Visszatérési érték: Ha létrejött egy új rekord, akkor "insert". Ha nincs változás (csak a last_time frissül), akkor "found". Ha a cím összerendelés nem változott, de a set_type igen, akkor "update". Ha az IP cím egy másik MAC-hez lett rendelve, akkor "modfy".

DECLARE
    arp     arps;               -- arps record
    noipa   boolean := false;   -- Not found ip_address record
    joint   boolean := false;   -- Is joint type ip address
    oip     ip_addresses;       -- Found IP address record
    n       integer;            -- record number
    t       text;               -- Text for arps record (arp_note)
    msg     text;               -- Text for ip_address record (ip_address_note), or other message
    col     boolean := false;   -- Address collision
    adt addresstype := 'fixip';
BEGIN
    -- RAISE INFO 'ARP : % - %; %', ipa, hwa, stp;
    -- check ip_addresses table (set: noipa and joint)
    BEGIN       -- IP -> Get old () ip_addresses record
        SELECT * INTO STRICT oip FROM ip_addresses WHERE address = ipa AND ip_address_type <> 'private'::addresstype;
        joint := 'joint'::addresstype = oip.ip_address_type;
        EXCEPTION
            WHEN NO_DATA_FOUND THEN
                noipa := true;
                -- RAISE INFO 'No ip_addresses record.';
            WHEN TOO_MANY_ROWS THEN
		-- RAISE INFO 'More ip_addresses record.';
                IF 0 < COUNT(*) FROM ip_addresses WHERE address = ipa AND NOT(ip_address_type = 'joint'::addresstype OR ip_address_type = 'private'::addresstype) THEN
                    PERFORM error('DataError', -1, 'address', 'replace_arp(' || ipa::text || ', ' || hwa::text || ')', 'ip_addresses');
                END IF;
                -- RAISE INFO 'ip_addresses records is all join.';
                joint := true;
    END;
    IF NOT noipa THEN
        IF hwa <> hwaddress FROM interfaces WHERE port_id = oip.port_id THEN
            IF oip.ip_address_type = 'dynamic' THEN
                -- Delete outdated address
                UPDATE ip_addresses SET address = NULL WHERE ip_address_id = oip.ip_address_id;
                INSERT INTO ip_address_logs(reason, daemon_id, ip_address_id, ip_address_type_new, port_id, address_old, ip_address_type_old)
                    VALUES('discard', hsi, oip.ip_address_id, 'dynamic', oip.port_id, oip.address, 'dynamic');
                noipa := true;
            ELSE
                col := true;
            END IF;
        END IF;
    END IF;
    IF noipa THEN   -- ip_addresses record not found by IP address (ipa)
        -- ip address record(s) by MAC
        SELECT ip_addresses.* INTO oip FROM ip_addresses JOIN interfaces USING(port_id)
                WHERE hwaddress = hwa AND (ip_address_type = 'fixip'::addresstype OR ip_address_type = 'dynamic'::addresstype);
        GET DIAGNOSTICS n = ROW_COUNT;
        IF n = 1 AND (stp = 'config' OR oip.ip_address_type = 'dynamic') THEN
            DECLARE
                det text;
                hnt text;
                snid bigint := oip.subnet_id;
            BEGIN 
                IF stp = 'query' AND is_dyn_addr(ipa) IS NOT NULL THEN
                    adt := 'dynamic';
                END IF;
                IF NOT ipa << netaddr FROM subnets WHERE subnet_id = snid THEN
                    snid := NULL;
                END IF;
                t := 'Modify by config : ' || oip.ip_address_type  || ' -> ' || adt || '; ' || oip.address || ' -> ' || ipa;
                msg := 'Modify by replace_arp(), service : ' || COALESCE(host_service_id2name(hsi), 'NULL') || ' ' || NOW()::text;
                UPDATE ip_addresses SET ip_address_note = msg, address = ipa, ip_address_type = adt, subnet_id = snid WHERE ip_address_id = oip.ip_address_id;
                INSERT INTO ip_address_logs(reason, message, daemon_id, ip_address_id, address_new, ip_address_type_new, port_id, address_old, ip_address_type_old)
                    VALUES('modify', msg, hsi, oip.ip_address_id, ipa, adt, oip.port_id, oip.address, oip.ip_address_type);
            EXCEPTION WHEN OTHERS THEN
                GET STACKED DIAGNOSTICS
                    msg = MESSAGE_TEXT,
                    det = PG_EXCEPTION_DETAIL,
                    hnt = PG_EXCEPTION_HINT;
                t := 'IP address update error : ' || ipa::text || ' -- ' || hwa::text || ' type is ' || stp
                    || ' The existing IP address record port name : ' || port_id2full_name(oip.port_id)
                    || ' . Message : ' || msg || ' Detail : ' || det || ' Hint : ' hnt;
                -- RAISE WARNING 'Ticket : %', t; 
                PERFORM ticket_alarm('critical', t, hsi);
            END;
        ELSE
            DECLARE
                pid bigint;
            BEGIN
                SELECT port_id INTO pid FROM interfaces WHERE hwaddress = hwa;
                GET DIAGNOSTICS n = ROW_COUNT;
                IF n = 1 THEN
                    IF stp = 'query' AND is_dyn_addr(ipa) IS NOT NULL THEN
                        adt := 'dynamic';
                    END IF;
                    t := 'Inser IP address (' || adt || ') record : port : ' || port_id2full_name(pid) || ' .';
                    msg := 'Insert by replace_arp(), service : ' || COALESCE(host_service_id2name(hsi), 'NULL') || ' ' || NOW()::text;
                    INSERT INTO ip_addresses(port_id, ip_address_note, address, ip_address_type) VALUES(pid, msg, ipa, adt);
                END IF;
            END;
        END IF;
    ELSIF col THEN  -- ip_addresses found by IP address (ipa) AND colision
        t := 'IP address collision : ' || ipa::text || ' -- ' || hwa::text || ' type is ' || stp || '. '
          || 'The existing IP address record port name : ' || port_id2full_name(oip.port_id);
        -- RAISE WARNING 'Ticket : %', t; 
        PERFORM ticket_alarm('critical', t, hsi);
    ELSE            -- ip_addresses found by IP address (ipa) AND NOT colision
        IF stp = 'config' AND oip.ip_address_type = 'dynamic' THEN
            DECLARE
                sid bigint := NULL;
            BEGIN
                UPDATE ip_addresses SET ip_address_type = 'fixip' WHERE ip_address_id = oip.ip_address_id;
                INSERT INTO ip_address_logs(reason, message, daemon_id, ip_address_id, address_new, ip_address_type_new, port_id, address_old, ip_address_type_old)
                    VALUES('update', msg, hsi, oip.ip_address_id, ipa, 'fixip', oip.port_id, ipa, 'dynamic');
            END;
        END IF;
    END IF;
    -- update arps table
    -- RAISE INFO 'Get arps record : %', ipa;
    SELECT * INTO arp FROM arps WHERE ipaddress = ipa;
    IF NOT FOUND THEN
        -- RAISE INFO 'Insert arps: % - %', ipa, hwa;
        INSERT INTO arps(ipaddress, hwaddress,set_type, host_service_id, arp_note) VALUES (ipa, hwa, stp, hsi, t);
        RETURN 'insert';
    ELSE
        IF arp.hwaddress = hwa THEN
	    IF arp.set_type < stp THEN
                -- RAISE INFO 'Update arps: % - %', ipa, hwa;
	        UPDATE arps SET set_type = stp, host_service_id = hsi, last_time = CURRENT_TIMESTAMP, arp_note = t WHERE ipaddress = arp.ipaddress;
		RETURN 'update';
	    ELSE
                -- RAISE INFO 'Touch arps: % - %', ipa, hwa;
	        UPDATE arps SET last_time = CURRENT_TIMESTAMP, arp_note = t WHERE ipaddress = arp.ipaddress;
		RETURN 'found';
	    END IF;
        ELSE
            -- RAISE INFO 'Move arps: % - % -> %', ipa, arp.hwaddress, hwa;
            UPDATE arps
                SET hwaddress = hwa,  first_time = CURRENT_TIMESTAMP, set_type = stp, host_service_id = hsi, last_time = CURRENT_TIMESTAMP, arp_note = t
                WHERE ipaddress = arp.ipaddress;
            INSERT INTO
                arp_logs(reason, ipaddress, hwaddress_new, hwaddress_old, set_type_old, host_service_id_old, first_time_old, last_time_old)
                VALUES( 'move',  ipa,       hwa,           arp.hwaddress, arp.set_type, arp.host_service_id, arp.first_time, arp.last_time);
            RETURN 'modify';
        END IF;
    END IF;
END;

Function: public.replace_dyn_addr_range(snid inet, excl inet, hsid bigint, eaddr boolean, baddr bigint)

Returns: reasons

Language: PLPGSQL

DECLARE
    brec dyn_addr_ranges;
    erec dyn_addr_ranges;
    bcol  boolean;
    ecol  boolean;
    r     reasons;
    snid2 bigint;
BEGIN
    IF snid IS NULL THEN 
        BEGIN       -- kezdő cím subnet-je
            SELECT subnet_id INTO STRICT snid FROM subnets WHERE netaddr >> baddr;
            EXCEPTION
                WHEN NO_DATA_FOUND THEN     -- nem találtunk
                    RETURN 'notfound';
                WHEN TOO_MANY_ROWS THEN     -- több találat is van, nem egyértelmű
                    RETURN 'ambiguous';
        END;
        BEGIN       -- vég cím subnet-je
            SELECT subnet_id INTO STRICT snid2 FROM subnets WHERE netaddr >> eaddr;
            EXCEPTION
                WHEN NO_DATA_FOUND THEN     -- nem találtunk
                    RETURN 'notfound';
                WHEN TOO_MANY_ROWS THEN     -- több találat is van, nem egyértelmű
                    RETURN 'ambiguous';
        END;
        IF snid <> snid2 THEN
            RETURN 'caveat';
        END IF;
    END IF;
    
    SELECT * INTO brec FROM dyn_addr_ranges WHERE begin_address <= baddr AND baddr <= end_address AND exclude = excl;
    bcol := FOUND;
    SELECT * INTO erec FROM dyn_addr_ranges WHERE begin_address <= eaddr AND eaddr <= end_address AND exclude = excl;
    ecol := FOUND;
    IF bcol AND ecol AND brec.dyn_addr_range_id = erec.dyn_addr_range_id AND baddr = brec.begin_address AND brec.end_address = eaddr THEN
        RAISE INFO '1: % < % ; % = %', baddr, eaddr, brec, erec; 
        UPDATE dyn_addr_ranges
            SET
                last_time = CURRENT_TIMESTAMP,
                host_service_id = hsid,
                flag = false
            WHERE dyn_addr_range_id = brec.dyn_addr_range_id;
        RETURN 'update';
    END IF;
    IF bcol AND ecol THEN
        RAISE INFO '2: % < % ; % <> %', baddr, eaddr, brec, erec;
        if brec.dyn_addr_range_id <> erec.dyn_addr_range_id THEN
            DELETE FROM dyn_addr_ranges WHERE dyn_addr_range_id = erec.dyn_addr_range_id;
            r := 'remove';
        ELSE
            r := 'modify';
        END IF;
        UPDATE dyn_addr_ranges
            SET
                begin_address = baddr,
                end_address = eaddr,
                subnet_id = snid,
                last_time = CURRENT_TIMESTAMP,
                host_service_id = hsid,
                flag = false
            WHERE dyn_addr_range_id = brec.dyn_addr_range_id;
        RETURN r;
    END IF;
    IF bcol OR ecol THEN
        if ecol THEN
            RAISE INFO '3: % < % ; ecol %', baddr, eaddr, erec;
            brec := erec;
        ELSE
            RAISE INFO '3: % < % ; bcol %', baddr, eaddr, brec;
        END IF;
        UPDATE dyn_addr_ranges
            SET
                begin_address = baddr,
                end_address = eaddr,
                subnet_id = snid,
                last_time = CURRENT_TIMESTAMP,
                host_service_id = hsid,
                flag = false
            WHERE dyn_addr_range_id = brec.dyn_addr_range_id;
        RETURN 'modify';
    END IF;
    RAISE INFO '4: % < % ', baddr, eaddr;
    INSERT INTO dyn_addr_ranges (begin_address, end_address, exclude, subnet_id, host_service_id) VALUES(baddr, eaddr, excl, snid, hsid);
    return 'insert';
END;

Function: public.replace_mactab(mst bigint, typ macaddr, mac public.settype, pid public.mactabstate[])

Returns: reasons

Language: PLPGSQL

Egy (switch) port és mac (cím tábla) összerendelés létrehozása, vagy módosítása. Paraméterek: pid A (switch) port ID. mac A hozzárandelendő MAC cím (a port címtáblálábol kiolvasott érték). typ Az összerendelés típusa, alapértelmezett a "query". mst Az összerendelés jellemzői (megbízhatóság) alapértelmezetten egy üres tömb. Csak egy elem adható meg, a suspect, a többi jelző beállítása automatikus. Visszaadott érték: Ha a pid-del azonosított portnak van egy "suspected_uplink" típusú paramétere, és ennek értéke true, akkor a függvény nem csinál semmit, és a "discard" értékkel tér vissza. Ha az összerendelés létezik, akkor csak a last_time mező értékét aktualizálja, és "unchange" értékkel tér vissza, ill. ha az állapot változott, akkor az "update" értékkel. Ha az összerendlés még nem létezik, akkor beszúrja a mactab rekordot, és az "insert" értékkel tér vissza. Ha a MAC egy másik porthoz volt hozzárandelve, akkor megvizsgálja, hogy a megadott MAC cím hányszor jelent meg más-más porton egy megadott időn bellül. A váltások maximális megengedett számát a "mactab_move_check_count" nevű és egész típusú, a vizsgállt időintervallumot pedig a "mactab_move_check_interval" intervallum típusú rendszer paraméter tartalmazza. Ha a váltások száma nem nagyobb mint a megengedett, akkor módosítja a mactab rekordot, és a "move" értékkel tér vissza. Ellenkező esetben megvizsgálja, hogy a régi vagy az új MAC-hoz rendelt porton volt-e több változás a viszgállt időintervallumban. Amelyiken több változás volt, ahhoz a porthoz hozzárendeli a "suspected_uplink" nevű és true értékű port paraméteret. Ha ez az új port, akkor "modify" értékkel tér vissza. Ha a régi, akkor módosítj a mactab rekordot az új port ID-vel, és "restire" értékkel tér vissza. A viszgállt időintervallumban a feltételezhetően tévesen keletkezett mactab_logs rekordokban true-ra állítja a be_void mezőt. Ha a régebbi porton be van állítva a "suspected_uplink" nevű paraméter és értéke true, az egyenértékkű azzal az esettel, mintha azon lett volna több változás.

DECLARE
    mt       mactab;
BEGIN
    IF get_bool_port_param(pid, 'suspected_uplink') THEN
        RETURN 'discard';
    END IF;
    mst := current_mactab_stat(pid, mac, mst);
    SELECT * INTO mt FROM mactab WHERE hwaddress = mac;
    IF NOT FOUND THEN            -- NEW
        INSERT INTO mactab(hwaddress, port_id, mactab_state,set_type) VALUES (mac, pid, mst, typ);
        RETURN 'insert';
    ELSIF mt.port_id = pid THEN  -- No changed, refresh state
        RETURN mactab_changestat(mt, mst, typ, true);
    ELSIF get_bool_port_param(mt.port_id, 'suspected_uplink') THEN -- Move, old port is suspect: simple move
        PERFORM mactab_move(mt, pid, mac, typ, mst);
        RETURN 'move';
    ELSE                        -- Move, check suspected uplink
        DECLARE 
            mactab_move_check_count    CONSTANT integer  := get_int_sys_param('mactab_move_check_count');
            mactab_move_check_interval CONSTANT interval := get_interval_sys_param('mactab_move_check_interval');
            begin_time      timestamp;
            my_moved_cnt    integer;    -- moved my port
            an_moved_cnt    integer;    -- moved other port
        BEGIN
            begin_time := NOW() - mactab_move_check_interval;
            SELECT COUNT(*) INTO my_moved_cnt FROM mactab_logs
                WHERE begin_time < date_of
                  AND (port_id_old = pid OR port_id_new = pid)
                  AND reason = 'move';
            IF mactab_move_check_count < my_moved_cnt THEN
                -- Suspect, which?
                SELECT COUNT(*) INTO an_moved_cnt FROM mactab_logs
                    WHERE begin_time < date_of
                      AND (port_id_old = mt.port_id OR port_id_new = mt.port_id)
                      AND reason = 'move';
                IF my_moved_cnt < an_moved_cnt THEN
                    -- another port is suspect
                    PERFORM set_bool_port_param(mt.port_id, true, 'suspected_uplink');
                    PERFORM mactab_move(mt, pid, mac, typ, mst);
                    UPDATE mactab_logs SET be_void = true
                        WHERE date_of > begin_time
                          AND (port_id_old = mt.port_id OR port_id_new = mt.port_id)
                          AND hwaddress = mac
                          AND reason = 'restore';
                    RETURN 'restore';
                ELSE
                    -- my port is suspect
                    PERFORM set_bool_port_param(pid, true, 'suspected_uplink');
                    UPDATE mactab_logs SET be_void = true
                        WHERE date_of > begin_time
                          AND (port_id_old = pid OR port_id_new = pid)
                          AND hwaddress = mac
                          AND reason = 'move';
                    RETURN 'discard';
                END IF;
            ELSE
                -- Symple move
                PERFORM mactab_move(mt, pid, mac, typ, mst);
                RETURN 'move';
            END IF;
        END;
    END IF;
END;

Function: public.replace_oui(nnote macaddr, nname text, noui text)

Returns: reasons

Language: PLPGSQL

OUI rekord beszúrása, vagy modosítása. Visszatérési értékek: Ha nem történt változás, akkor "unchange". Ha módosítva lett egy rekord, akkor "modify". Ha viszont be lett szúrva egy új rekord, akkor "insert".

DECLARE
    rec ouis;
BEGIN
    SELECT * INTO rec FROM ouis WHERE oui = noui;
    IF NOT FOUND THEN
        INSERT INTO ouis VALUES(noui, nname, nnote);
        RETURN 'insert';
    END IF;
    IF rec.oui_name = nname AND rec.oui_note = nnote THEN
        RETURN 'unchange';
    END IF;
    UPDATE ouis SET oui_name = nname, oui_note = nnote WHERE oui = noui;
    RETURN 'modify';
END;

Function: public.restrict_modfy_node_id_before_update()

Returns: trigger

Language: PLPGSQL

BEGIN
    IF NEW.node_id <> OLD.node_id THEN
        PERFORM error('Constant', -1, 'node_id', 'restrict_modfy_node_id_before_update()', TG_TABLE_NAME, TG_OP);
    END IF;
    RETURN NEW;
END;

Function: public.rm_unmarked_port_vlan(nid bigint)

Returns: integer

Language: PLPGSQL

DECLARE
    rec port_vlans;
    n integer;
BEGIN
    n := 0;
    FOR rec IN SELECT port_vlans.* FROM port_vlans JOIN nports USING(port_id) WHERE port_vlans.flag = false AND node_id = nid LOOP
        n := n + 1;
        INSERT INTO port_vlan_logs(reason,       port_id,     vlan_id,      old_type, first_time_old, last_time_old)
                            VALUES('remove', rec.port_id, rec.vlan_id, rec.vlan_type, rec.first_time, rec.last_time);
        DELETE FROM port_vlans WHERE port_vlan_id = rec.port_vlan_id;
        
    END LOOP;
    RETURN n;
END;

Function: public.rrd_beat_id2name(bigint)

Returns: text

Language: PLPGSQL

 DECLARE name text; BEGIN IF $1 IS NULL THEN RETURN NULL;  END IF; SELECT rrd_beat_name INTO name FROM rrd_beats WHERE rrd_beat_id = $1; IF NOT FOUND THEN PERFORM error('IdNotFound', $1, 'rrd_beat_id', 'rrd_beat_id2name', 'rrd_beats'); END IF; RETURN name; END 

Function: public.rrd_file_id2name(bigint)

Returns: text

Language: PLPGSQL

 DECLARE name text; BEGIN IF $1 IS NULL THEN RETURN NULL;  END IF; SELECT rrd_file_name INTO name FROM rrd_files WHERE rrd_file_id = $1; IF NOT FOUND THEN PERFORM error('IdNotFound', $1, 'rrd_file_id', 'rrd_file_id2name', 'rrd_files'); END IF; RETURN name; END 

Function: public.service_cron(did bigint)

Returns: void

Language: PLPGSQL

BEGIN
    PERFORM services_heartbeat(did);
    PERFORM expired_online_alarm();
    PERFORM expired_offline_alarm();
    PERFORM refresh_mactab();
    PERFORM refresh_arps();
END

Function: public.service_id2name(bigint)

Returns: text

Language: PLPGSQL

DECLARE
    name TEXT;
BEGIN
    IF $1 IS NULL THEN
        return NULL;
    END IF;
    SELECT service_name INTO name FROM services WHERE service_id = $1;
    IF NOT FOUND THEN
        PERFORM error('IdNotFound', $1, 'service_id', 'service_id2name()', 'services');
    END IF;
    RETURN name;

END;

Function: public.service_name2id(text)

Returns: bigint

Language: PLPGSQL

DECLARE
    id bigint;
BEGIN
    SELECT service_id INTO id FROM services WHERE service_name = $1;
    IF NOT FOUND THEN
        PERFORM error('NameNotFound', -1, $1, 'service_name2id()', 'services');
    END IF;
    RETURN id;

END;

Function: public.service_rrd_value_after()

Returns: trigger

Language: PLPGSQL

DECLARE
    val text;
    pt paramtype;
    payload text;
BEGIN
    IF NOT NEW.rrd_disabled AND NEW.raw_value IS NOT NULL AND NEW.last_time IS NOT NULL THEN -- Next value?
        IF COALESCE((NEW.last_time > OLD.last_time), true) THEN
            IF raw_to_rrd FROM service_var_types WHERE service_var_type_id = NEW.service_var_type_id THEN
                SELECT param_type_type INTO pt
                    FROM param_types       AS pt
                    JOIN service_var_types AS vt ON vt.raw_param_type_id = pt.param_type_id
                    WHERE NEW.service_var_type_id = vt.service_var_type_id;
                val := NEW.raw_value;
            ELSE
                SELECT param_type_type INTO pt
                    FROM param_types       AS pt
                    JOIN service_var_types AS vt USING(param_type_id)
                    WHERE NEW.service_var_type_id = vt.service_var_type_id;
                val := NEW.service_var_value;
            END IF;
            IF pt = 'integer' OR pt = 'real' OR pt = 'interval' THEN -- Numeric
                IF pt = 'interval' THEN
                    val := extract(EPOCH FROM val::interval)::text;
                END IF;
                payload := 'rrd '
                        || NEW.rrdhelper_id::text || ' '
                        || extract(EPOCH FROM NEW.last_time  AT TIME ZONE 'CETDST' AT TIME ZONE 'UTC')::bigint::text || ' '
                        || val || ' ' 
                        || NEW.service_var_id::text;
                PERFORM pg_notify('rrdhelper', payload);
            END IF;
        END IF;
    END IF;
    RETURN NEW;
END;

Function: public.service_type_id2name(bigint)

Returns: text

Language: PLPGSQL

 DECLARE name text; BEGIN IF $1 IS NULL THEN RETURN NULL;  END IF; SELECT service_type_name INTO name FROM service_types WHERE service_type_id = $1; IF NOT FOUND THEN PERFORM error('IdNotFound', $1, 'service_type_id', 'service_type_id2name', 'service_types'); END IF; RETURN name; END 

Function: public.service_value2text(raw text, typeid bigint, val boolean)

Returns: text

Language: PLPGSQL

Segéd függvény a service_vars értékeinek megjelenítéséhez mértékegységgel.

DECLARE
    dim text;
BEGIN
    IF raw THEN
        SELECT param_type_dim INTO dim
            FROM service_var_types AS vt
            JOIN param_types       AS pt ON pt.param_type_id = vt.raw_param_type_id
            WHERE vt.service_var_type_id = typeid;
    ELSE
        SELECT param_type_dim INTO dim
            FROM service_var_types AS vt
            JOIN param_types       AS pt ON pt.param_type_id = vt.param_type_id
            WHERE vt.service_var_type_id = typeid;
    END IF;
    IF dim IS NULL OR dim = '' THEN
        dim := '';
    ELSE
        dim := ' ' || dim;
    END IF;
    RETURN val || dim;
END;

Function: public.service_var2service_rrd_var(vid bigint)

Returns: service_rrd_vars

Language: PLPGSQL

DECLARE
    sv  service_vars;
    srv service_rrd_vars;
BEGIN
    SELECT * INTO sv FROM ONLY service_vars WHERE service_var_id = vid;
    IF NOT FOUND THEN
        PERFORM error('IdNotFound', vid, 'service_var_id', 'service_var2service_rrd_var(bigint)', 'service_vars');
        RETURN NULL;
    END IF;
    UPDATE alarm_service_vars SET service_var_id = -vid WHERE service_var_id = -vid;
    DELETE FROM service_vars WHERE service_var_id = vid;
    INSERT INTO service_rrd_vars(
            service_var_id, service_var_name, service_var_note, service_var_type_id, 
            host_service_id, service_var_value, var_state, last_time, features, 
            deleted, raw_value, delegate_service_state, state_msg, delegate_port_state, 
            disabled, flag, rarefaction, rrdhelper_id, rrd_beat_id, rrd_disabled)
        VALUES (
            vid, sv.service_var_name, sv.service_var_note, sv.service_var_type_id, 
            sv.host_service_id, sv.service_var_value, sv.var_state, sv.last_time, sv.features, 
            sv.deleted, sv.raw_value, sv.delegate_service_state, sv.state_msg, sv.delegate_port_state, 
            sv.disabled, sv.flag, sv.rarefaction, NULL, NULL, true)
        RETURNING * INTO srv;
    UPDATE alarm_service_vars SET service_var_id = vid WHERE service_var_id = vid;
    RETURN srv;
END;

Function: public.service_var_id2name(bigint)

Returns: text

Language: PLPGSQL

 DECLARE name text; BEGIN IF $1 IS NULL THEN RETURN NULL;  END IF; SELECT service_var_name INTO name FROM service_vars WHERE service_var_id = $1; IF NOT FOUND THEN PERFORM error('IdNotFound', $1, 'service_var_id', 'service_var_id2name', 'service_vars'); END IF; RETURN name; END 

Function: public.service_var_type_id2name(bigint)

Returns: text

Language: PLPGSQL

 DECLARE name text; BEGIN IF $1 IS NULL THEN RETURN NULL;  END IF; SELECT service_var_type_name INTO name FROM service_var_types WHERE service_var_type_id = $1; IF NOT FOUND THEN PERFORM error('IdNotFound', $1, 'service_var_type_id', 'service_var_type_id2name', 'service_var_types'); END IF; RETURN name; END 

Function: public.services_heartbeat(did bigint)

Returns: void

Language: PLPGSQL

DECLARE
    hsr host_services;
    msg text;
BEGIN
    FOR hsr IN SELECT hs.*
         FROM host_services AS hs
         JOIN services      AS s  USING(service_id)
         WHERE
           host_service_state <> 'unknown' AND
           (NOW() - last_touched) > COALESCE(hs.heartbeat_time, s.heartbeat_time)
    LOOP
	msg := 'Expired "' || hsr.host_service_state::text || '" state : ' || (NOW() - hsr.last_touched)::text;
	-- RAISE NOTICE '%1 : %2', host_service_id2name(hsr.host_service_id), msg;
	PERFORM set_service_stat(hsr.host_service_id, 'unknown'::notifswitch, msg, did, true);
    END LOOP;
END

Function: public.set_bool_port_param(name bigint, val boolean, pid text)

Returns: void

Language: PLPGSQL

BEGIN
    INSERT INTO port_params(port_param_name, port_id, param_type_id, param_value)
        VALUES (name, pid, param_type_name2id('boolean'), val::text)
    ON CONFLICT ON CONSTRAINT port_params_port_param_name_port_id_key DO UPDATE
        SET param_type_id = EXCLUDED.param_type_id, param_value = EXCLUDED.param_value;
END;

Function: public.set_bool_sys_param(tname text, boolval boolean, pname text)

Returns: reasons

Language: PLPGSQL

BEGIN
    RETURN set_text_sys_param(pname, boolval::text, tname);
END

Function: public.set_db_version(minor integer, major integer)

Returns: reasons

Language: PLPGSQL

BEGIN
    PERFORM set_int_sys_param('version_minor', minor);
    RETURN set_int_sys_param('version_major', major);
END

Function: public.set_host_status(hs public.host_services)

Returns: void

Language: PLPGSQL

Beállítja a node állapotás a szervíz állapot (hard_state) alapján, amennyiben a szervíz rekordban a delegate_host_state igaz. és nincs ojan szervíz példány, aminél delegate_host_state szintén igaz, és az állapota nem rosszabb (nagyobb), vagy azonos.

DECLARE
    st notifswitch;
    ost notifswitch;
BEGIN
    IF hs.delegate_host_state THEN
        st := hs.hard_state;
        SELECT hard_state INTO ost FROM host_services
                WHERE node_id = hs.node_id AND delegate_host_state AND host_service_id <> hs.host_service_id
                ORDER BY hard_state DESC limit 1;
        IF NOT FOUND THEN
            ost := 'on';
        END IF;
        IF st >= ost THEN
            UPDATE nodes SET node_stat = st WHERE node_id = hs.node_id;
        END IF;
    END IF;
END

Function: public.set_image_hash_if_null()

Returns: trigger

Language: PLPGSQL

BEGIN
    IF NEW.image_hash IS NULL THEN
        NEW.image_hash := digest(NEW.image_data, 'sha512');
    END IF;
    RETURN NEW;
END

Function: public.set_int_sys_param(tname text, intval bigint, pname text)

Returns: reasons

Language: PLPGSQL

BEGIN
    RETURN set_text_sys_param(pname, intval::text, tname);
END

Function: public.set_interval_sys_param(tname text, ival interval, pname text)

Returns: reasons

Language: PLPGSQL

BEGIN
    RETURN set_text_sys_param(pname, ival::text, tname);
END

Function: public.set_language(c character varying, l character varying)

Returns: integer

Language: PLPGSQL

DECLARE
    id integer;
BEGIN
    IF c IS NULL THEN
        id := language_id FROM languages WHERE l = lang_2 LIMIT 1;
    ELSE 
        id := COALESCE(
            (SELECT language_id FROM languages WHERE l = lang_2 AND c = country_a2),
            (SELECT language_id FROM languages WHERE l = lang_2 LIMIT 1),
            (SELECT language_id FROM languages WHERE c = country_a2 LIMIT 1));
    END IF;
    IF id IS NULL THEN
        id := COALESCE(get_int_sys_param('default_language'), get_int_sys_param('failower_language'));
    END IF;
    PERFORM set_config('lanview2.language_id', id::text, false);
    RETURN id;
END;

Function: public.set_language_id(id integer)

Returns: integer

Language: PLPGSQL

BEGIN
    PERFORM set_config('lanview2.language_id', id::text, false);
    RETURN id;
END;

Function: public.set_service_stat(forced bigint, dmid public.notifswitch, note text, state bigint, hsid boolean)

Returns: host_services

Language: PLPGSQL

DECLARE
    hs          host_services;  -- New host services record
    old_hs      host_services;  -- Old host_services record
    s           services;       -- Services rekord
    na          isnoalarm;      -- Alarm barring status
    supaid      bigint;         -- Superior host_service act alarm_id
    tflapp      interval;       -- Flapping detection time window
    iflapp      integer;        -- Changes in the state within the time window
    alid        bigint;         -- Actual alarm record ID
    mca         integer;        -- max_check_attempts
    aldo        reasons := 'unknown';
BEGIN
    hs := touch_host_service(hsid);
    SELECT * INTO  s FROM services WHERE service_id = hs.service_id;
    IF NOT FOUND THEN
        PERFORM error('IdNotFound', hs.service_id, 'service_id', 'set_service_stat()', 'services');
    END IF;
    IF state = hs.host_service_state AND state = hs.hard_state AND state = hs.soft_state THEN
        RETURN hs;  -- No change in status
    END IF;
    old_hs := hs;
    -- set new record states
    IF state < 'warning'::notifswitch THEN   -- ok:_ 'on' or 'recovered'
        state := 'on'::notifswitch;  -- 'on' or 'recovered' -> 'on'
        IF old_hs.hard_state >= 'warning'::notifswitch THEN
            hs.host_service_state := 'recovered';
        ELSE
            hs.host_service_state := 'on'::notifswitch;
        END IF;
        hs.hard_state := 'on'::notifswitch;
        hs.soft_state := 'on'::notifswitch;
        hs.check_attempts := 0;
    ELSE                        -- not ok
        hs.soft_state := state;
        IF old_hs.hard_state >= 'warning'::notifswitch THEN   -- So far it was bad
            hs.hard_state := state;
            hs.host_service_state := state;
            hs.check_attempts := 0;
        ELSE
            IF old_hs.soft_state = 'on'::notifswitch THEN    -- Is this the first mistake?
                hs.check_attempts := 1;     -- Yes. Let's start counting
            ELSE
                hs.check_attempts := hs.check_attempts + 1; -- No. We continue to count
            END IF;
            mca := COALESCE(hs.max_check_attempts, s.max_check_attempts, 1);
            IF forced OR hs.check_attempts >= mca THEN  -- It is definitely a problem
                hs.hard_state := state;
                hs.host_service_state := state;
            END IF;
        END IF;
    END IF;
    -- flapping
    tflapp := COALESCE(hs.flapping_interval, s.flapping_interval);
    iflapp := COALESCE(hs.flapping_max_change, s.flapping_max_change);
    IF chk_flapping(hsid, tflapp, iflapp) THEN
        hs.host_service_state := 'flapping'::notifswitch;
        state := 'flapping'::notifswitch;
    END IF;
    -- delegate status to node
    PERFORM set_host_status(hs);
    supaid := check_superior_service(hs);
    -- Disable alarms status?
    na := is_noalarm(hs.noalarm_flag, hs.noalarm_from, hs.noalarm_to);
    IF na = 'expired'::isnoalarm THEN  -- If it has expired, it will be deleted
        hs.noalarm_flag := 'off'::noalarmtype;
        hs.noalarm_from := NULL;
        hs.noalarm_to   := NULL;
        na := 'off'::isnoalarm;
    END IF;
    -- last changed time
    IF hs.last_changed IS NULL OR old_hs.host_service_state <> hs.host_service_state THEN
        hs.last_changed = CURRENT_TIMESTAMP;
    END IF;
    -- Alarm ...
    alid := old_hs.act_alarm_log_id;
    -- RAISE INFO 'act_alarm_log_id = %', alid;
    IF hs.hard_state < 'warning'::notifswitch THEN        -- ok
        IF alid IS NOT NULL THEN   -- close act alarm
            -- RAISE INFO 'Close % alarms record for % service.', alid, hs.host_service_id;
            UPDATE alarms SET end_time = CURRENT_TIMESTAMP WHERE alarm_id = alid;
            hs.last_alarm_log_id := alid;
            hs.act_alarm_log_id := NULL;
            aldo := 'close'::reasons;
        ELSE
            IF hs.host_service_state = old_hs.host_service_state THEN
                aldo := 'unchange'::reasons;
            ELSE
                aldo := 'modify'::reasons;
            END IF;
        END IF;
    ELSE                        -- not ok
        IF alid IS NULL THEN    -- create new alarm
            -- RAISE INFO 'New (%) alarms record for % service.', na, hs.host_service_id;
            IF na = 'off'::isnoalarm AND NOT s.disabled AND NOT hs.disabled THEN -- Alarm is not disabled, and services is not disabled
                INSERT INTO alarms (host_service_id, daemon_id, first_status, max_status, last_status, event_note, superior_alarm_id)
                    VALUES(hsid, dmid, state, state, state, note, supaid )
                    RETURNING alarm_id INTO hs.act_alarm_log_id;
                aldo := 'new'::reasons;
                alid := hs.act_alarm_log_id;
                -- RAISE INFO 'New alarm_id = %', alid;
            ELSE
                -- RAISE INFO 'New alarm discard';
                aldo := 'discard'::reasons;
                -- DELETE FROM alarms WHERE alarm_id = alid;    Hülyeség! alid = NULL
            END IF;
        ELSE                    -- not ok and there was an alarm
            IF na = 'on'::isnoalarm OR s.disabled OR hs.disabled THEN -- Alarm is disabled, or services is disabled
                aldo := 'remove'::reasons;
                DELETE FROM alarms WHERE alarm_id = alid;
                -- RAISE INFO 'Disable alarm, remove (alarm_id = %)', alid;
                alid := NULL;
                hs.last_alarm_log_id := NULL;
            ELSIF old_hs.host_service_state <> state THEN
                UPDATE alarms SET
                        max_status  = greatest(hs.host_service_state, max_status),
                        last_status = hs.host_service_state,
                        superior_alarm_id = supaid
                    WHERE alarm_id = alid;
                aldo := 'modify'::reasons;
                -- RAISE INFO 'Update alarm (alarm_id = %', alid;
            ELSE
                aldo := 'unchange'::reasons;
                -- RAISE INFO 'Unchange alarm (alarm_id = %', alid;
            END IF;
        END IF;
    END IF;
    -- save record
    UPDATE host_services SET
            max_check_attempts = hs.max_check_attempts,
            host_service_state = hs.host_service_state,
            hard_state         = hs.hard_state,
            soft_state         = hs.soft_state,
            state_msg          = note,
            check_attempts     = hs.check_attempts,
            last_changed       = hs.last_changed,
            act_alarm_log_id   = hs.act_alarm_log_id,
            last_alarm_log_id  = hs.last_alarm_log_id,
            noalarm_flag       = hs.noalarm_flag,
            noalarm_from       = hs.noalarm_from,
            noalarm_to         = hs.noalarm_to
        WHERE host_service_id  = hsid;
    -- RAISE INFO '/ set_service_stat() = %', hs;
    -- Create log
    IF hs.host_service_state <> old_hs.host_service_state OR
       hs.hard_state         <> old_hs.hard_state OR
       hs.soft_state         <> old_hs.soft_state THEN
        INSERT INTO host_service_logs(host_service_id, old_state, old_soft_state, old_hard_state,
                           new_state, new_soft_state, new_hard_state, event_note, superior_alarm_id, noalarm,
                           alarm_id, alarm_do)
            VALUES  (hsid, old_hs.host_service_state, old_hs.soft_state, old_hs.hard_state,
                           hs.host_service_state, hs.soft_state, hs.hard_state, note, supaid, na = 'on',
                           alid, aldo);
    END IF;
    RETURN hs;
END

Function: public.set_superior(ptyp bigint, hsnm text, hsid text)

Returns: boolean

Language: PLPGSQL

DECLARE
    hsrv  host_services;            -- Az frissítendő host_services rekord
BEGIN
    SELECT * INTO hsrv FROM host_services WHERE host_service_id = hsid;
    IF NOT FOUND THEN
        PERFORM error('IdNotFound', hsid, 'host_service_id', 'set_superior()', 'host_services');
    END IF;
    IF hsrv.superior_host_service_id IS NULL THEN
        hsrv := find_superior(hsrv, hsnm, ptyp);
    ELSE
        RETURN FALSE;
    END IF;
    IF hsrv.superior_host_service_id IS NULL THEN
        RETURN FALSE;
    END IF;
    UPDATE host_services SET
            superior_host_service_id = hsrv.host_service_id
        WHERE host_service_id = hsid;
    RETURN TRUE;
END

Function: public.set_text_sys_param(tname text, txtval text, pname text)

Returns: reasons

Language: PLPGSQL

Egy rendszer paraméter (sys_params tábla egy rekordja) értékének, és adat típusának a megadása. A függvény paraméterei pname A paraméter neve txtval A paraméter értéke tname A paraméter típusleíró rekord neve. Opcionálís, ha nem adjuk meg, akkor "text". Visszatérési érték: Ha a paraméter már létezik, és a megadott értékű és típusú, akkor "found". Ha még nincs ilyen paraméter, akkor "insert" Ha magadtuk a típus nevet, és nincs ilyen típus rekord, akkor "notfound". Ha volt ilyen nevű paraméter, és csak az érték változott, akkor "update" Ha volt ilyen paraméter, és a típus változott, akkor "modify".

DECLARE
    type_id bigint;
    rec sys_params;
BEGIN
    SELECT param_type_id INTO type_id FROM param_types WHERE param_type_name = tname;
    IF NOT FOUND THEN
        RETURN 'notfound';
    END IF;
    SELECT * INTO rec FROM sys_params WHERE sys_param_name = pname;
    IF NOT FOUND THEN
        INSERT INTO sys_params(sys_param_name, param_type_id, param_value) VALUES (pname, type_id, txtval);
        RETURN 'insert';
    END IF;
    IF type_id = rec.param_type_id THEN
        IF txtval = rec.param_value THEN
            RETURN 'found';
        END IF;
        UPDATE sys_params SET param_value = txtval WHERE sys_param_name = pname;
        RETURN 'update';
    END IF;
    UPDATE sys_params SET param_value = txtval, param_type_id = type_id WHERE sys_param_name = pname;
    RETURN 'modify';
END

Function: public.set_user_id(bigint)

Returns: users

Language: PLPGSQL

DECLARE
    ur users%ROWTYPE;
    ri rights;
BEGIN
    SELECT * INTO ur FROM users WHERE user_id = $1;
    IF NOT FOUND THEN
        PERFORM set_config('lanview2.user_name',   'unknown', false);
        PERFORM set_config('lanview2.user_id',     '0',       false);
        PERFORM set_config('lanview2.user_rights', 'none',    false);
        PERFORM error('UserName', $1, '', 'set_user_id()', 'users');
    ELSE
        SELECT MAX(group_rights) INTO ri FROM group_users JOIN groups USING(group_id) WHERE user_id = ur.user_id;
        PERFORM set_config('lanview2.user_name',   CAST(ur.user_name AS text), false);
        PERFORM set_config('lanview2.user_id',     CAST(ur.user_id   AS text), false);
        PERFORM set_config('lanview2.user_rights', CAST(ri           AS text), false);
    END IF;
    RETURN ur;
END;

Function: public.set_user_name(text)

Returns: users

Language: PLPGSQL

DECLARE
    ur users%ROWTYPE;
    ri rights;
BEGIN
    SELECT * INTO ur FROM users WHERE user_name = $1;
    IF NOT FOUND THEN
        PERFORM set_config('lanview2.user_name',   'unknown', false);
        PERFORM set_config('lanview2.user_id',     '0',       false);
        PERFORM set_config('lanview2.user_rights', 'none',    false);
        PERFORM error('UserName', -1, $1, 'set_user_name()', 'users');
    ELSE
        SELECT MAX(group_rights) INTO ri FROM group_users JOIN groups USING(group_id) WHERE user_id = ur.user_id;
        PERFORM set_config('lanview2.user_name',   CAST(ur.user_name AS text), false);
        PERFORM set_config('lanview2.user_id',     CAST(ur.user_id   AS text), false);
        PERFORM set_config('lanview2.user_rights', CAST(ri           AS text), false);
    END IF;
    RETURN ur;
END;

Function: public.shared_cable(pref bigint, pid text)

Returns: text

Language: PLPGSQL

DECLARE
    port   pports;
BEGIN
    SELECT * INTO port FROM pports WHERE port_id = pid;
    RETURN CASE 
        WHEN port.shared_port_id IS NULL AND port.shared_cable = ''::portshare THEN ''
        WHEN port.shared_port_id IS NULL THEN pref || port.shared_cable::text
        ELSE pref || port.shared_cable::text || '(' || port_id2name(port.shared_port_id) || ')'
    END;
END;

Function: public.shared_cable_back(pid bigint)

Returns: text

Language: PLPGSQL

DECLARE
    port   pports;
    ta     text[];
BEGIN
    SELECT * INTO port FROM pports WHERE port_id = pid;
    CASE 
        WHEN port.shared_port_id IS NULL AND port.shared_cable = ''::portshare THEN
            RETURN '';
        WHEN port.shared_port_id IS NULL THEN
            SELECT array_agg(shared_cable || ':' || port_name) INTO ta FROM pports WHERE shared_port_id = port.port_id;
            IF array_length(ta, 1) > 0 THEN
                RETURN port.shared_cable::text || ' / ' || array_to_string(ta, '; ');
            ELSE
                RETURN port.shared_cable::text;
            END IF;
        ELSE
            RETURN port.shared_cable::text || '!!(' || port_id2name(port.shared_port_id) || ')';
    END CASE;
END;

Function: public.shares_filt(sh public.portshare[], shares public.portshare)

Returns: portshare[]

Language: PLPGSQL

Egy portshare tömbnek azon elemeivel tér vissza, melyek nem ütköznek a második paraméterrel

DECLARE
    oshs    portshare[];
    i       bigint;
BEGIN
    FOR i IN 0 .. array_length(shares, 1) LOOP
        IF check_shared(shares[i], sh) THEN
            oshs := oshs || shares[i];
        END IF;
    END LOOP;
    RETURN oshs;
END;

Function: public.subnet_check_before_update()

Returns: trigger

Language: PLPGSQL

Trigger függvény, megakadályozza a subnets táblában az ID módosítását.

BEGIN
    IF TG_OP = 'UPDATE' THEN
        IF NEW.subnet_id <> OLD.subnet_id THEN
            PERFORM error('Constant', -1, 'subnet_id', 'subnet_check_before_update()', TG_TABLE_NAME, TG_OP);
        END IF;
    END IF;
    RETURN NEW;
END;

Function: public.subnet_delete_before()

Returns: trigger

Language: PLPGSQL

BEGIN
    UPDATE ip_addresses SET subnet_id = NULL, address = NULL WHERE subnet_id = OLD.subnet_id;
    RETURN OLD;
END;

Function: public.subnet_id2name(bigint)

Returns: text

Language: PLPGSQL

 DECLARE name text; BEGIN IF $1 IS NULL THEN RETURN NULL;  END IF; SELECT subnet_name INTO name FROM subnets WHERE subnet_id = $1; IF NOT FOUND THEN PERFORM error('IdNotFound', $1, 'subnet_id', 'subnet_id2name', 'subnets'); END IF; RETURN name; END 

Function: public.table_is_exists(text)

Returns: boolean

Language: PLPGSQL

Ha a paraméterként megadott bevű tábla létezik, akkor igaz értékkel, egyébként hamis értékkel tér vissza

BEGIN
    RETURN 1 = COUNT(*) FROM information_schema.tables WHERE 'BASE TABLE' = table_type AND $1 = table_name;
END

Function: public.table_or_view_is_exists(text)

Returns: boolean

Language: PLPGSQL

Ha a paraméterként megadott bevű tábla vagy nézet tábla létezik, akkor igaz értékkel, egyébként hamis értékkel tér vissza

BEGIN
    RETURN 1 = COUNT(*) FROM information_schema.tables WHERE $1 = table_name;
END

Function: public.table_shape_field_id2name(bigint)

Returns: text

Language: PLPGSQL

 DECLARE name text; BEGIN IF $1 IS NULL THEN RETURN NULL;  END IF; SELECT table_shape_field_name INTO name FROM table_shape_fields WHERE table_shape_field_id = $1; IF NOT FOUND THEN PERFORM error('IdNotFound', $1, 'table_shape_field_id', 'table_shape_field_id2name', 'table_shape_fields'); END IF; RETURN name; END 

Function: public.table_shape_field_name2id(text, text)

Returns: bigint

Language: PLPGSQL

DECLARE
    id bigint;
BEGIN
    SELECT table_shape_field_id  INTO id FROM table_shape_fields JOIN table_shapes USING (table_shape_id) WHERE table_shape_name = $1 AND table_shape_field_name = $2;
    IF NOT FOUND THEN
        PERFORM error('NameNotFound', -1, $1, 'table_shape_field_name2id()', 'table_shape_fields');
    END IF;
    RETURN id;
END

Function: public.table_shape_id2name(bigint)

Returns: text

Language: PLPGSQL

 DECLARE name text; BEGIN IF $1 IS NULL THEN RETURN NULL;  END IF; SELECT table_shape_name INTO name FROM table_shapes WHERE table_shape_id = $1; IF NOT FOUND THEN PERFORM error('IdNotFound', $1, 'table_shape_id', 'table_shape_id2name', 'table_shapes'); END IF; RETURN name; END 

Function: public.table_shape_id2name(bigint[])

Returns: text

Language: PLPGSQL

DECLARE
    tsid bigint;
    name text;
    rlist text := '';
BEGIN
    IF $1 IS NULL THEN
        RETURN NULL;
    END IF;
    FOREACH tsid IN ARRAY $1 LOOP
        SELECT table_shape_name INTO name FROM table_shapes WHERE table_shape_id = tsid;
        IF NOT FOUND THEN
            PERFORM error('IdNotFound', tsid, '', 'table_shape_id2name(bigint)', 'table_shapes');
        END IF;
        rlist := rlist || name || ',';
    END LOOP;
    RETURN trim( trailing ',' FROM rlist);
END

Function: public.table_shape_name2id(text)

Returns: bigint

Language: PLPGSQL

DECLARE
    id bigint;
BEGIN
    SELECT table_shape_id INTO id FROM table_shapes WHERE table_shape_name = $1;
    IF NOT FOUND THEN
        PERFORM error('NameNotFound', -1, $1, 'table_shape_name2id()', 'table_shapes');
    END IF;
    RETURN id;
END

Function: public.ticket_alarm(mst public.notifswitch, fst text, aid bigint, did bigint, msg public.notifswitch, lst public.notifswitch)

Returns: alarms

Language: PLPGSQL

DECLARE
    ar alarms;
    hs host_services;
    repi interval;
    sid bigint := 0;    -- host_service_id : nil.ticket == node_id : nil == service_id : ticket
BEGIN
    SELECT * INTO hs FROM host_services WHERE host_service_id = sid;
    IF NOT FOUND THEN
        IF 0 = COUNT(*) FROM nodes WHERE node_id = sid THEN
            INSERT INTO nodes(node_id, node_name, node_note,    node_type )
               VALUES        (sid,     'nil',   'Independent', '{node, virtual}');
        END IF;
        IF 0 = COUNT(*) FROM services WHERE service_id = sid THEN
            INSERT INTO services (service_id, service_name, service_note, disabled, service_type_id)
                 VALUES          (  sid,      'ticket',     'Hiba jegy',  true,     sid );
        END IF;
        INSERT INTO host_services (host_service_id, node_id, service_id,  host_service_note, disabled)
             VALUES               (  sid,           sid,     sid,         'Hiba jegy',       true)
             RETURNING * INTO hs;
    END IF;
    IF 'on' <> is_noalarm(hs.noalarm_flag, hs.noalarm_from, hs.noalarm_to) THEN
        repi := COALESCE(get_interval_sys_param('ticet_reapeat_time'), '14 days'::interval);
        SELECT * INTO ar FROM alarms
                    WHERE host_service_id = sid
                    AND (begin_time + repi) > NOW()
                    AND end_time IS NULL
                    AND lst = last_status
                    AND COALESCE(aid, -1) = COALESCE(superior_alarm_id, -1)
                    AND COALESCE(did, -1) = COALESCE(daemon_id, -1)
                    AND msg = event_note
                    LIMIT 1;
        IF NOT FOUND THEN
            INSERT INTO alarms (host_service_id, daemon_id, first_status, max_status, last_status, event_note, superior_alarm_id)
                        VALUES (sid,             did, COALESCE(fst, lst), COALESCE(mst, lst), lst, msg,        aid)
                    RETURNING * INTO ar;
        END IF;
    END IF;
    RETURN ar;
END;

Function: public.time_in_timeperiod(bigint, timestamp without time zone)

Returns: boolean

Language: PLPGSQL

BEGIN
    CASE $1
        WHEN  0 THEN    -- always
            RETURN TRUE;
        WHEN -1 THEN    -- never
            RETURN FALSE;
        ELSE
            RETURN 0 < COUNT(*) FROM tpows JOIN timeperiod_tpows USING (tpow_id)
                WHERE $1 = timeperiod_id AND int2dow(EXTRACT(DOW FROM $2)::integer) = dow AND $2::time >= begin_time AND $2::time < end_time;
    END CASE;
END;

Function: public.timeperiod_id2name(bigint)

Returns: text

Language: PLPGSQL

 DECLARE name text; BEGIN IF $1 IS NULL THEN RETURN NULL;  END IF; SELECT timeperiod_name INTO name FROM timeperiods WHERE timeperiod_id = $1; IF NOT FOUND THEN PERFORM error('IdNotFound', $1, 'timeperiod_id', 'timeperiod_id2name', 'timeperiods'); END IF; RETURN name; END 

Function: public.timeperiod_name2id(text)

Returns: bigint

Language: PLPGSQL

BEGIN
    RETURN timeperiod_id FROM timeperiods WHERE timeperiod_name = $1;
END

Function: public.timeperiod_next_on_time(bigint, timestamp without time zone)

Returns: timestamp without time zone

Language: PLPGSQL

DECLARE
    dw  dayofweek;
    dwi integer;
    dd  integer;
    btm record;
    tm  time;
BEGIN
    IF $1 <= 0 OR $1 IS NULL THEN    -- always, never, NULL, <invalid>
        RETURN NULL;
    END IF;
    dwi := EXTRACT(DOW FROM $2)::integer;
    dw  := int2dow(dwi);
    RAISE INFO 'datetime = %, dwi = %, dw = %', $2, dwi, dw;
    SELECT begin_time INTO tm FROM tpows JOIN timeperiod_tpows USING (tpow_id)
        WHERE $1 = timeperiod_id AND dw = dow AND $2::time <= begin_time AND $2::time < end_time
        ORDER BY begin_time ASC
        LIMIT 1;
    IF FOUND THEN
	RAISE INFO 'dd = nulla, new time = %', tm; 
        RETURN $2::date + tm;
    END IF;
    SELECT begin_time, dow INTO btm FROM tpows JOIN timeperiod_tpows USING (tpow_id)
        WHERE $1 = timeperiod_id AND dw < dow
        ORDER BY dow ASC, begin_time ASC
        LIMIT 1;
    IF FOUND THEN
        dd := dow2int(btm.dow) - dwi;
        RAISE INFO 'DOW = %, dd = %, new time = %', btm.dow, dd, btm.begin_time; 
        RETURN ($2::date + dd) + btm.begin_time;
    END IF;
    SELECT begin_time, dow INTO btm FROM tpows JOIN timeperiod_tpows USING (tpow_id)
        WHERE $1 = timeperiod_id AND dw >= dow
        ORDER BY dow ASC, begin_time ASC
        LIMIT 1;
    IF FOUND THEN
        dd := dow2int(btm.dow) - dwi + 7;
        RAISE INFO 'DOW*= %, dd = %, new time = %', btm.dow, dd, btm.begin_time; 
        RETURN ($2::date + dd) + btm.begin_time;
    END IF;
    RETURN NULL;
END;

Function: public.to_choose(rec text, stype text)

Returns: selects

Language: PLPGSQL

BEGIN
    SELECT * INTO rec FROM selects
        WHERE stype = select_type
          AND ((pattern_type = 'equal'   AND sval = pattern)
            OR (pattern_type = 'equali'  AND lower(sval) = lower(pattern))
            OR (pattern_type = 'similar' AND sval similar TO pattern)
            OR (pattern_type = 'regexp'  AND sval ~  pattern)
            OR (pattern_type = 'regexpi' AND sval ~* pattern))
        ORDER BY precedence
        LIMIT 1;
END

Function: public.touch_host_service(hsid bigint)

Returns: host_services

Language: PLPGSQL

A megadott azonosítójú host_services rekordban a last_touched mezőt az aktuális időpontra változtatja, és a módosított rekord tartalomával tér vissza

DECLARE
    hs          host_services;
BEGIN
    UPDATE host_services SET last_touched = CURRENT_TIMESTAMP WHERE host_service_id = hsid
        RETURNING * INTO hs;
    IF NOT FOUND THEN
        PERFORM error('IdNotFound', hsid, 'host_service_id', 'touch_host_service()', 'host_services');
    END IF;
    RETURN hs;
END

Function: public.tpow_name2id(text)

Returns: bigint

Language: PLPGSQL

DECLARE
    id bigint;
BEGIN
    SELECT tpow_id INTO id FROM tpows WHERE tpow_name = $1;
    IF NOT FOUND THEN
        PERFORM error('NameNotFound', -1, $1, 'tpow_name2id(text)', 'tpows');
    END IF;
    RETURN id;
END

Function: public.truncate_disabled_alarms()

Returns: trigger

Language: PLPGSQL

BEGIN
    UPDATE host_services     SET act_alarm_log_id  = NULL WHERE act_alarm_log_id  IN (SELECT alarm_id FROM disabled_alarms);
    UPDATE host_services     SET last_alarm_log_id = NULL WHERE last_alarm_log_id IN (SELECT alarm_id FROM disabled_alarms);
    UPDATE host_service_logs SET alarm_id          = NULL WHERE alarm_id          IN (SELECT alarm_id FROM disabled_alarms);
    UPDATE host_service_logs SET superior_alarm_id = NULL WHERE superior_alarm_id IN (SELECT alarm_id FROM disabled_alarms);
    RETURN OLD;
END;

Function: public.update_port_vlan(st bigint, vt bigint, vid public.vlantype, pid public.settype)

Returns: reasons

Language: PLPGSQL

DECLARE
    rec port_vlans;
    r reasons;
BEGIN
    SELECT * INTO rec FROM port_vlans WHERE port_id = pid AND vlan_id = vid;
    IF NOT FOUND THEN
        IF 0 = COUNT(*) FROM vlans WHERE vlan_id = vid THEN
            INSERT INTO vlans(vlan_id, vlan_name) VALUES(vid, 'AUTO_INSERTED_VLAN' || vid::text);
            r := 'new';
        ELSE
            r := 'insert';
        END IF;
        INSERT INTO port_vlans (port_id, vlan_id, vlan_type, set_type, flag) VALUES (pid, vid, vt, st, true);
        RETURN r;
    END IF;
    IF rec.vlan_type = vt THEN
        UPDATE port_vlans SET last_time = now(), flag = true WHERE port_id = pid AND vlan_id = vid;
        RETURN 'unchange';
    END IF;
    UPDATE port_vlans SET vlan_type = vt, set_type = st, first_time = now(), last_time = now(), flag = true WHERE port_id = pid AND vlan_id = vid;
    INSERT INTO port_vlan_logs(reason, port_id, vlan_id,   old_type, first_time_old, last_time_old, new_type)
                        VALUES('modify', pid,    vid, rec.vlan_type, rec.first_time, rec.last_time, vt);
    RETURN 'modify';
END;

Function: public.user_events_before()

Returns: trigger

Language: PLPGSQL

BEGIN
    IF NEW.happened IS NULL AND NEW.event_state <> 'necessary'::usereventstate THEN
        NEW.happened := NOW();
    END IF;
    RETURN NEW;
END;

Function: public.user_id2name(bigint)

Returns: text

Language: PLPGSQL

 DECLARE name text; BEGIN IF $1 IS NULL THEN RETURN NULL;  END IF; SELECT user_name INTO name FROM users WHERE user_id = $1; IF NOT FOUND THEN PERFORM error('IdNotFound', $1, 'user_id', 'user_id2name', 'users'); END IF; RETURN name; END 

Function: public.user_is_any_groups_member(gids bigint, uid bigint[])

Returns: boolean

Language: PLPGSQL

DECLARE
    gid bigint;
BEGIN
    IF gids IS NULL THEN
        RETURN FALSE;
    END IF;
    FOREACH gid IN ARRAY gids LOOP
        IF user_is_group_member(uid, gid) THEN
            RETURN TRUE;
        END IF;
    END LOOP;
    RETURN FALSE;
END;

Function: public.user_is_group_member(gid bigint, uid bigint)

Returns: boolean

Language: PLPGSQL

BEGIN
    RETURN COUNT(*) > 0 FROM group_users WHERE user_id = uid AND group_id = gid;
END;

Function: public.user_name2id(text)

Returns: bigint

Language: PLPGSQL

BEGIN
    RETURN user_id FROM users WHERE user_name = $1;
END

Function: public.view_is_exists(text)

Returns: boolean

Language: PLPGSQL

Ha a paraméterként megadott bevű nézet tábla létezik, akkor igaz értékkel, egyébként hamis értékkel tér vissza

BEGIN
    RETURN 1 = COUNT(*) FROM information_schema.tables WHERE 'VIEW' = table_type AND $1 = table_name;
END

Function: public.vlan_delete_before()

Returns: trigger

Language: PLPGSQL

BEGIN
    DELETE FROM subnets WHERE vlan_id = OLD.vlan_id;
    RETURN OLD;
END;

Function: public.vlan_id2name(bigint)

Returns: text

Language: PLPGSQL

 DECLARE name text; BEGIN IF $1 IS NULL THEN RETURN NULL;  END IF; SELECT vlan_name INTO name FROM vlans WHERE vlan_id = $1; IF NOT FOUND THEN PERFORM error('IdNotFound', $1, 'vlan_id', 'vlan_id2name', 'vlans'); END IF; RETURN name; END 

Function: public.xor(boolean, boolean)

Returns: boolean

Language: PLPGSQL

BEGIN
    RETURN ( $1 and not $2) or ( not $1 and $2);
END

Schema test

Generated by PostgreSQL Autodoc

W3C HTML 4.01 Strict