Sigit Yoga's Personal blog

berikut dokumentasi untuk script create table bulanan dan harian menggunakan postgresql

— Create table harian —

#!/bin/bash
day=$(date –date ‘tomorrow’ +”%Y%m%d”)

psql -U<user> -h127.0.0.1 -d new_vegeta -c “CREATE TABLE report_$day (
id serial, service_id integer, service_description text, host_address character varying(200), servicecode character varying(200),
service_status character varying(200), service_plugin_output text, datesending timestamp without time zone, datecome timestamp without time zone,
ipsending character varying(100), service_problem_has_been_acknowledged character varying(200), service_has_comments character varying(200),
service_accept_passive_service_checks character varying(200), service_notifications_enabled character varying(200), service_checks_enabled character varying(200),
service_is_flapping character varying(200), service_scheduled_downtime_depth character varying(200), service_notes_url character varying(200),
service_action_url character varying(255), service_icon_image character varying(200), service_state_duration character varying(200),
service_current_attempt character varying(200), service_max_attempts character varying(200), service_performance_data text);”

sleep 3

psql -U<user> -h127.0.0.1 -d new_vegeta -c “ALTER TABLE report_$day owner to aplikasi;”


— Create table bulanan —

#!/bin/bash
bulan=$(date –date ‘-1 day’ +”%Y%m”)

psql -U<user> -h127.0.0.1 -d <nama_database> -c “CREATE TABLE report_$bulan (
id serial, service_id integer, service_description text, host_address character varying(200), servicecode character varying(200),
service_status character…

View original post 71 more words