#!/bin/bash CUST1_N="VWD" OUTPUT="result_cust_$CUST1_N.html" SELECT="select_cust_$CUST1_N.sql" HOST="127.0.0.1" FIND="%-vwd-%" cd /scripts/rancid/dev_port_overview/ || exit echo 'select count(*) as "Network devices (SW/RTR/DWDM)" from devices where type="network" and hostname like "%-vwd-%";' > $SELECT CUST1_R=$(mysql -h $HOST -u observium -pobservium -D observium < $SELECT | tail -n1) echo "

$CUST1_N Device and Port Report

Devices

" > $OUTPUT echo 'select count(*) as "Firewalls (inc Cluster)" from devices where type="firewall" and hostname like "%-vwd-%";' > $SELECT CUST1_R=$(mysql -h $HOST -u observium -pobservium -D observium < $SELECT | tail -n1) echo " " >> $OUTPUT echo 'select count(distinct hostname) as "Firewall Cluster" from devices t1 inner join status t2 on t1.device_id = t2.device_id where t1.type="firewall" and t2.status_descr like "Failover%" and t1.hostname like "%-vwd-%";' > $SELECT CUST1_R=$(mysql -h $HOST -u observium -pobservium -D observium < $SELECT | tail -n1) echo " " >> $OUTPUT echo 'select count(*) as "Wireless devices" from devices where type="wireless" and hostname like "%-vwd-%";' > $SELECT CUST1_R=$(mysql -h $HOST -u observium -pobservium -D observium < $SELECT | tail -n1) echo " " >> $OUTPUT echo 'select count(distinct p1.device_id) as "FC Devices" from ports p1 inner join devices d1 on p1.device_id = d1.device_id where p1.ifOperStatus="up" and p1.ifType="fibreChannel" and d1.hostname like "%-vwd-%";' > $SELECT CUST1_R=$(mysql -h $HOST -u observium -pobservium -D observium < $SELECT | tail -n1) echo " " >> $OUTPUT echo "
Switches, Router, DWDM Firewalls (inclusive Cluster) Firewall Cluster Wireless Fibre Channel
$CUST1_R$CUST1_R$CUST1_R$CUST1_R$CUST1_R

Ports

" >> $OUTPUT echo 'select count(*) as "All Ports" from ports p1 inner join devices d1 on p1.device_id = d1.device_id where p1.deleted="0" and d1.hostname like "%-vwd-%";' > $SELECT CUST1_R=$(mysql -h $HOST -u observium -pobservium -D observium < $SELECT | tail -n1) echo "
all
$CUST1_R
" >> $OUTPUT echo "

Fiber Channel

" >> $OUTPUT echo 'select count(*) as "active FC Ports" from ports p1 inner join devices d1 on p1.device_id = d1.device_id where p1.ifOperStatus="up" and p1.ifType="fibreChannel" and p1.port_label_base="fc" and p1.deleted="0" and (d1.hostname like "%-vwd-%" or p1.ifalias like "tso%");' > $SELECT CUST1_R=$(mysql -h $HOST -u observium -pobservium -D observium < $SELECT | tail -n1) echo " " >> $OUTPUT echo 'select count(*) as "non-active FC Ports" from ports p1 inner join devices d1 on p1.device_id = d1.device_id where p1.ifOperStatus="down" and p1.ifType="fibreChannel" and p1.port_label_base="fc" and p1.deleted="0" and (d1.hostname like "%-vwd-%" or p1.ifalias like "tso%");' > $SELECT CUST1_R=$(mysql -h $HOST -u observium -pobservium -D observium < $SELECT | tail -n1) echo " " >> $OUTPUT echo 'select count(*) as "active 4G FC Ports" from ports p1 inner join devices d1 on p1.device_id = d1.device_id where p1.ifOperStatus="up" and p1.ifType="fibreChannel" and p1.port_label_base="fc" and p1.ifspeed="4000000000" and p1.deleted="0" and (d1.hostname like "%-vwd-%" or p1.ifalias like "tso%");' > $SELECT CUST1_R=$(mysql -h $HOST -u observium -pobservium -D observium < $SELECT | tail -n1) echo " " >> $OUTPUT echo 'select count(*) as "non-active 4G FC Ports" from ports p1 inner join devices d1 on p1.device_id = d1.device_id where p1.ifOperStatus="down" and p1.ifType="fibreChannel" and p1.port_label_base="fc" and p1.ifspeed="4000000000" and p1.deleted="0" and (d1.hostname like "%-vwd-%" or p1.ifalias like "tso%");' > $SELECT CUST1_R=$(mysql -h $HOST -u observium -pobservium -D observium < $SELECT | tail -n1) echo " " >> $OUTPUT echo 'select count(*) as "active 8G FC Ports" from ports p1 inner join devices d1 on p1.device_id = d1.device_id where p1.ifOperStatus="up" and p1.ifType="fibreChannel" and p1.port_label_base="fc" and p1.ifspeed="8000000000" and p1.deleted="0" and (d1.hostname like "%-vwd-%" or p1.ifalias like "tso%");' > $SELECT CUST1_R=$(mysql -h $HOST -u observium -pobservium -D observium < $SELECT | tail -n1) echo " " >> $OUTPUT echo 'select count(*) as "non-active 8G FC Ports" from ports p1 inner join devices d1 on p1.device_id = d1.device_id where p1.ifOperStatus="down" and p1.ifType="fibreChannel" and p1.port_label_base="fc" and p1.ifspeed="8000000000" and p1.deleted="0" and (d1.hostname like "%-vwd-%" or p1.ifalias like "tso%");' > $SELECT CUST1_R=$(mysql -h $HOST -u observium -pobservium -D observium < $SELECT | tail -n1) echo " " >> $OUTPUT echo 'select count(*) as "active 16G FC Ports"from ports p1 inner join devices d1 on p1.device_id = d1.device_id where p1.ifOperStatus="up" and p1.ifType="fibreChannel" and p1.port_label_base="fc" and p1.ifspeed="16000000000" and p1.deleted="0" and (d1.hostname like "%-vwd-%" or p1.ifalias like "tso%");' > $SELECT CUST1_R=$(mysql -h $HOST -u observium -pobservium -D observium < $SELECT | tail -n1) echo " " >> $OUTPUT echo 'select count(*) as "non-active 16G FC Ports"from ports p1 inner join devices d1 on p1.device_id = d1.device_id where p1.ifOperStatus="down" and p1.ifType="fibreChannel" and p1.port_label_base="fc" and p1.ifspeed="16000000000" and p1.deleted="0" and (d1.hostname like "%-vwd-%" or p1.ifalias like "tso%");' > $SELECT CUST1_R=$(mysql -h $HOST -u observium -pobservium -D observium < $SELECT | tail -n1) echo " " >> $OUTPUT echo "
active non-active active 4G non-active 4G active 8G non-active 8G active 16G non-active 16G
$CUST1_R$CUST1_R$CUST1_R$CUST1_R$CUST1_R$CUST1_R$CUST1_R$CUST1_R
" >> $OUTPUT echo "

Ethernet

" >> $OUTPUT echo 'select count(*) as "active Ethernet Ports" from ports p1 inner join devices d1 on p1.device_id = d1.device_id where p1.ifOperStatus="up" and p1.ifType="ethernetCsmacd" and p1.deleted="0" and d1.hostname like "%-vwd-%";' > $SELECT CUST1_R=$(mysql -h $HOST -u observium -pobservium -D observium < $SELECT | tail -n1) echo " " >> $OUTPUT echo 'select count(*) as "non-active Ethernet Ports" from ports p1 inner join devices d1 on p1.device_id = d1.device_id where p1.ifOperStatus="down" and p1.ifType="ethernetCsmacd" and p1.deleted="0" and d1.hostname like "%-vwd-%";' > $SELECT CUST1_R=$(mysql -h $HOST -u observium -pobservium -D observium < $SELECT | tail -n1) echo " " >> $OUTPUT echo 'select count(*) as "active Gigabit Ethernet Ports" from ports p1 inner join devices d1 on p1.device_id = d1.device_id where p1.ifOperStatus="up" and p1.ifType="ethernetCsmacd" and p1.ifspeed="1000000000" and p1.deleted="0" and d1.hostname like "%-vwd-%";' > $SELECT CUST1_R=$(mysql -h $HOST -u observium -pobservium -D observium < $SELECT | tail -n1) echo " " >> $OUTPUT echo 'select count(*) as "non-active Gigabit Ethernet Ports" from ports p1 inner join devices d1 on p1.device_id = d1.device_id where p1.ifOperStatus="down" and p1.ifType="ethernetCsmacd" and p1.ifspeed="1000000000" and p1.deleted="0" and d1.hostname like "%-vwd-%";' > $SELECT CUST1_R=$(mysql -h $HOST -u observium -pobservium -D observium < $SELECT | tail -n1) echo " " >> $OUTPUT echo 'select count(*) as "active 10Gigabit Ethernet Ports" from ports p1 inner join devices d1 on p1.device_id = d1.device_id where p1.ifOperStatus="up" and p1.ifType="ethernetCsmacd" and p1.ifspeed="10000000000" and p1.deleted="0" and d1.hostname like "%-vwd-%";' > $SELECT CUST1_R=$(mysql -h $HOST -u observium -pobservium -D observium < $SELECT | tail -n1) echo " " >> $OUTPUT echo 'select count(*) as "non-active 10Gigabit Ethernet Ports" from ports p1 inner join devices d1 on p1.device_id = d1.device_id where p1.ifOperStatus="down" and p1.ifType="ethernetCsmacd" and p1.ifspeed="10000000000" and p1.deleted="0" and d1.hostname like "%-vwd-%";' > $SELECT CUST1_R=$(mysql -h $HOST -u observium -pobservium -D observium < $SELECT | tail -n1) echo " " >> $OUTPUT echo "
active non-active active 1G non-active 1G active 10G non-active 10G
$CUST1_R$CUST1_R$CUST1_R$CUST1_R$CUST1_R$CUST1_R

IPSec

" >> $OUTPUT echo 'select count(distinct i1.local_addr) as "Devices (FW/RTR) with Tunnels" from ipsec_tunnels i1 inner join devices d1 on i1.device_id = d1.device_id where i1.tunnel_status="active" and i1.tunnel_deleted="0" and d1.hostname like "%-vwd-%";' > $SELECT CUST1_R=$(mysql -h $HOST -u observium -pobservium -D observium < $SELECT | tail -n1) echo " " >> $OUTPUT echo 'select count(distinct i1.peer_addr) as "Remote Firewalls" from ipsec_tunnels i1 inner join devices d1 on i1.device_id = d1.device_id where i1.tunnel_status="active" and i1.tunnel_deleted="0" and d1.hostname like "%-vwd-%";' > $SELECT CUST1_R=$(mysql -h $HOST -u observium -pobservium -D observium < $SELECT | tail -n1) echo " " >> $OUTPUT echo 'select count(*) as "active IPSec SAs" from ipsec_tunnels i1 inner join devices d1 on i1.device_id = d1.device_id where i1.tunnel_status="active" and i1.tunnel_deleted="0" and d1.hostname like "%-vwd-%";' > $SELECT CUST1_R=$(mysql -h $HOST -u observium -pobservium -D observium < $SELECT | tail -n1) echo " " >> $OUTPUT echo "
Firewalls, Router with Tunnels Remote Firewalls active IPSec SAs
$CUST1_R$CUST1_R$CUST1_R
" >> $OUTPUT rm $SELECT