Files
scripts-conlxsyslog03/rancid/dev_port_overview/create_output_orig.sh
conetadm 5718e70f15 init
2024-11-14 21:11:06 +01:00

154 lines
9.6 KiB
Bash
Executable File

#!/bin/bash
OUTPUT="result.html"
cd /scripts/rancid/dev_port_overview/ || exit
echo 'select count(distinct location) as "Locations" from devices_locations;' > select.sql
OUT1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
OUT2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo "<html>
<head>
</head>
<body>
<h1>Device and Port Report</h1>
<hr>
<h2>Locations</h2>RZ: $OUT1<br>FLW: $OUT2<br>" > $OUTPUT
echo 'select count(*) as "Network devices (SW/RTR/DWDM)" from devices where type="network";' > select.sql
OUT1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
OUT2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo "
<hr>
<h2>Devices</h2>
<h3>Network devices (SW/RTR/DWDM)</h3>RZ: $OUT1<br>FLW: $OUT2" >> $OUTPUT
echo 'select count(*) as "Firewalls (inc Cluster)" from devices where type="firewall";' > select.sql
OUT1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
OUT2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo " <h3>Firewalls (inclusive Cluster)</h3>RZ: $OUT1<br>FLW: $OUT2" >> $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%";' > select.sql
OUT1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
OUT2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo " <h3>Firewall Cluster)</h3>RZ: $OUT1<br>FLW: $OUT2" >> $OUTPUT
echo 'select count(*) as "Wireless devices" from devices where type="wireless";' > select.sql
OUT1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
OUT2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo " <h3>Wireless</h3>RZ: $OUT1<br>FLW: $OUT2" >> $OUTPUT
echo 'select count(distinct device_id) as "FC Devices" from ports where ifOperStatus="up" and ifType="fibreChannel";' > select.sql
OUT1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
OUT2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo " <h3>Fibre Channel</h3>RZ: $OUT1<br>FLW: $OUT2" >> $OUTPUT
echo 'select count(*) as "All Ports" from ports where deleted="0";' > select.sql
OUT1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
OUT2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo "
<hr>
<h2>Ports</h2>
<h3>All</h3>RZ: $OUT1<br>FLW: $OUT2" >> $OUTPUT
echo 'select count(*) as "active FC Ports" from ports where ifOperStatus="up" and ifType="fibreChannel" and port_label_base="fc" and deleted="0";' > select.sql
OUT1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
OUT2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo " <h3>active FC Ports</h3>RZ: $OUT1<br>FLW: $OUT2" >> $OUTPUT
echo 'select count(*) as "non-active FC Ports" from ports where ifOperStatus="down" and ifType="fibreChannel" and port_label_base="fc" and deleted="0";' > select.sql
OUT1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
OUT2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo " <h3>non-active FC Ports</h3>RZ: $OUT1<br>FLW: $OUT2" >> $OUTPUT
echo 'select count(*) as "active 4G FC Ports" from ports where ifOperStatus="up" and ifType="fibreChannel" and port_label_base="fc" and ifspeed="4000000000" and deleted="0";' > select.sql
OUT1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
OUT2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo " <h3>active 4G FC Ports</h3>RZ: $OUT1<br>FLW: $OUT2" >> $OUTPUT
echo 'select count(*) as "non-active 4G FC Ports" from ports where ifOperStatus="down" and ifType="fibreChannel" and port_label_base="fc" and ifspeed="4000000000" and deleted="0";' > select.sql
OUT1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
OUT2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo " <h3>non-active 4G FC Ports</h3>RZ: $OUT1<br>FLW: $OUT2" >> $OUTPUT
echo 'select count(*) as "active 8G FC Ports" from ports where ifOperStatus="up" and ifType="fibreChannel" and port_label_base="fc" and ifspeed="8000000000" and deleted="0";' > select.sql
OUT1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
OUT2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo " <h3>active 8G FC Ports</h3>RZ: $OUT1<br>FLW: $OUT2" >> $OUTPUT
echo 'select count(*) as "non-active 8G FC Ports" from ports where ifOperStatus="down" and ifType="fibreChannel" and port_label_base="fc" and ifspeed="8000000000" and deleted="0";' > select.sql
OUT1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
OUT2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo " <h3>non-active 8G FC Ports</h3>RZ: $OUT1<br>FLW: $OUT2" >> $OUTPUT
echo 'select count(*) as "active 16G FC Ports"from ports where ifOperStatus="up" and ifType="fibreChannel" and port_label_base="fc" and ifspeed="16000000000" and deleted="0";' > select.sql
OUT1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
OUT2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo " <h3>active 16G FC Ports</h3>RZ: $OUT1<br>FLW: $OUT2" >> $OUTPUT
echo 'select count(*) as "non-active 16G FC Ports"from ports where ifOperStatus="down" and ifType="fibreChannel" and port_label_base="fc" and ifspeed="16000000000" and deleted="0";' > select.sql
OUT1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
OUT2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo " <h3>non-active 16G FC Ports</h3>RZ: $OUT1<br>FLW: $OUT2" >> $OUTPUT
echo 'select count(*) as "active Ethernet Ports" from ports where ifOperStatus="up" and ifType="ethernetCsmacd" and deleted="0";' > select.sql
OUT1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
OUT2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo " <h3>active Ethernet Ports</h3>RZ: $OUT1<br>FLW: $OUT2" >> $OUTPUT
echo 'select count(*) as "non-active Ethernet Ports" from ports where ifOperStatus="down" and ifType="ethernetCsmacd" and deleted="0";' > select.sql
OUT1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
OUT2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo " <h3>non-active Ethernet Ports</h3>RZ: $OUT1<br>FLW: $OUT2" >> $OUTPUT
echo 'select count(*) as "active Gigabit Ethernet Ports" from ports where ifOperStatus="up" and ifType="ethernetCsmacd" and ifspeed="1000000000" and deleted="0";' > select.sql
OUT1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
OUT2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo " <h3>active Gigabit Ethernet Ports</h3>RZ: $OUT1<br>FLW: $OUT2" >> $OUTPUT
echo 'select count(*) as "non-active Gigabit Ethernet Ports" from ports where ifOperStatus="down" and ifType="ethernetCsmacd" and ifspeed="1000000000" and deleted="0";' > select.sql
OUT1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
OUT2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo " <h3>non-active Gigabit Ethernet Ports</h3>RZ: $OUT1<br>FLW: $OUT2" >> $OUTPUT
echo 'select count(*) as "active 10Gigabit Ethernet Ports" from ports where ifOperStatus="up" and ifType="ethernetCsmacd" and ifspeed="10000000000" and deleted="0";' > select.sql
OUT1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
OUT2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo " <h3>active 10Gigabit Ethernet Ports</h3>RZ: $OUT1<br>FLW: $OUT2" >> $OUTPUT
echo 'select count(*) as "non-active 10Gigabit Ethernet Ports" from ports where ifOperStatus="down" and ifType="ethernetCsmacd" and ifspeed="10000000000" and deleted="0";' > select.sql
OUT1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
OUT2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo " <h3>non-active 10Gigabit Ethernet Ports</h3>RZ: $OUT1<br>FLW: $OUT2" >> $OUTPUT
echo 'select count(distinct local_addr) as "Devices (FW/RTR) with Tunnels" from ipsec_tunnels where tunnel_status="active" and tunnel_deleted="0";' > select.sql
OUT1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
OUT2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo "
<hr>
<h2>IPSec</h2>
<h3>Devices (FW/RTR) with Tunnels</h3>RZ: $OUT1<br>FLW: $OUT2" >> $OUTPUT
echo 'select count(distinct peer_addr) as "Remote Firewalls" from ipsec_tunnels where tunnel_status="active" and tunnel_deleted="0";' > select.sql
OUT1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
OUT2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo " <h3>Remote Firewalls</h3>RZ: $OUT1<br>FLW: $OUT2" >> $OUTPUT
echo 'select count(*) as "active IPSec SAs" from ipsec_tunnels where tunnel_status="active" and tunnel_deleted="0";' > select.sql
OUT1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
OUT2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo " <h3>active IPSec SAs</h3>RZ: $OUT1<br>FLW: $OUT2" >> $OUTPUT
echo "
<hr>
</body>
</html>" >> $OUTPUT