This commit is contained in:
conetadm
2024-11-14 21:11:06 +01:00
commit 5718e70f15
657 changed files with 9401652 additions and 0 deletions

View File

@@ -0,0 +1,279 @@
#!/bin/bash
OUTPUT="result.html"
cd /scripts/rancid/dev_port_overview/ || exit
echo "<html>
<head>
<style>
table, td {
border: 1px solid black;
border-collapse: collapse;
text-align: center;
}
.tdSpacer {
border-top: 1px solid white;
border-bottom: 1px solid white;
width: 3px;
}
.tdTopLeftCorner {
border: 1px solid white;
border-bottom: 1px solid black;
}
.tdNoBorder {
border: 1px solid white;
}
</style>
</head>
<body>
<h1>Device and Port Report</h1>
<h2>Locations</h2>" > $OUTPUT
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 " <table>
<tr>
<td class=tdTopLeftCorner></td>
<td class=tdSpacer rowspan=3></td>
<td>via snmp</td>
</tr>
<tr>
<td>RZ</td>
<td>$OUT1</td>
</tr>
<!--
<tr>
<td>FLW</td>
<td>$OUT2</td>
</tr>
-->
</table>" >> $OUTPUT
echo " <h2>Devices</h2>" >> $OUTPUT
echo 'select count(*) as "Network devices (SW/RTR/DWDM)" from devices where type="network";' > select.sql
OUTa1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
#OUTa2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo 'select count(*) as "Firewalls (inc Cluster)" from devices where type="firewall";' > select.sql
OUTb1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
#OUTb2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
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
OUTc1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
#OUTc2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo 'select count(*) as "Wireless devices" from devices where type="wireless";' > select.sql
OUTd1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
#OUTd2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo 'select count(distinct device_id) as "FC Devices" from ports where ifOperStatus="up" and ifType="fibreChannel";' > select.sql
OUTe1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
#OUTe2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo " <table border=0>
<tr>
<td class=tdTopLeftCorner></td>
<td class=tdSpacer rowspan=3></td>
<td>SW/RTR/DWDM</td>
<td class=tdSpacer rowspan=3></td>
<td>Firewalls (inc Cluster)</td>
<td>Firewall Cluster</td>
<td class=tdSpacer rowspan=3></td>
<td>Wireless</td>
<td class=tdSpacer rowspan=3></td>
<td>FibreChannel</td>
</tr>
<tr>
<td>RZ</td>
<td>$OUTa1</td>
<td>$OUTb1</td>
<td>$OUTc1</td>
<td>$OUTd1</td>
<td>$OUTe1</td>
</tr>
<!---
<tr>
<td>FLW</td>
<td>$OUTa2</td>
<td>$OUTb2</td>
<td>$OUTc2</td>
<td>$OUTd2</td>
<td>$OUTe2</td>
</tr>
-->
</table>" >> $OUTPUT
echo " <h2>Ports</h2>" >> $OUTPUT
echo 'select count(*) as "All Ports" from ports where deleted="0";' > select.sql
OUTa1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
#OUTa2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
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
OUTb1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
#OUTb2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
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
OUTc1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
#OUTc2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
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
OUTd1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
#OUTd2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
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
OUTe1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
#OUTe2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
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
OUTf1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
#OUTf2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
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
OUTg1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
#OUTg2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
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
OUTh1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
#OUTh2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
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
OUTi1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
#OUTi2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo 'select count(*) as "active Ethernet Ports" from ports where ifOperStatus="up" and ifType="ethernetCsmacd" and deleted="0";' > select.sql
OUTj1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
#OUTj2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo 'select count(*) as "non-active Ethernet Ports" from ports where ifOperStatus="down" and ifType="ethernetCsmacd" and deleted="0";' > select.sql
OUTk1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
#OUTk2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo 'select count(*) as "active Gigabit Ethernet Ports" from ports where ifOperStatus="up" and ifType="ethernetCsmacd" and ifspeed="1000000000" and deleted="0";' > select.sql
OUTl1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
#OUTl2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
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
OUTm1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
#OUTm2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo 'select count(*) as "active 10Gigabit Ethernet Ports" from ports where ifOperStatus="up" and ifType="ethernetCsmacd" and ifspeed="10000000000" and deleted="0";' > select.sql
OUTn1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
#OUTn2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
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
OUTo1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
#OUTo2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo " <table>
<tr>
<td rowspan=2 class=tdTopLeftCorner></td>
<td rowspan=4 class=tdSpacer></td>
<td rowspan=2>All Ports</td>
<td rowspan=4 class=tdSpacer></td>
<td colspan=8>FibreChannel</td>
<td rowspan=4 class=tdSpacer></td>
<td colspan=8>Ethernet</td>
</tr>
<tr>
<td>active FC</td>
<td>non-active FC</td>
<td>active 4G FC</td>
<td>non-active 4G</td>
<td>active 8G FC</td>
<td>non-active 8G</td>
<td>active 16G FC</td>
<td>non-active 16G</td>
<td>active Ethernet</td>
<td>non-active Ethernet</td>
<td>active Gigabit</td>
<td>non-active Gigabit</td>
<td>active 10Gigabit</td>
<td>non-active 10Gigabit</td>
</tr>
<tr>
<td>RZ</td>
<td>$OUTa1</td>
<td>$OUTb1</td>
<td>$OUTc1</td>
<td>$OUTd1</td>
<td>$OUTe1</td>
<td>$OUTf1</td>
<td>$OUTg1</td>
<td>$OUTh1</td>
<td>$OUTi1</td>
<td>$OUTj1</td>
<td>$OUTk1</td>
<td>$OUTl1</td>
<td>$OUTm1</td>
<td>$OUTn1</td>
<td>$OUTo1</td>
</tr>
<!--
<tr>
<td>FLW</td>
<td>$OUTa2</td>
<td>$OUTb2</td>
<td>$OUTc2</td>
<td>$OUTd2</td>
<td>$OUTe2</td>
<td>$OUTf2</td>
<td>$OUTg2</td>
<td>$OUTh2</td>
<td>$OUTi2</td>
<td>$OUTj2</td>
<td>$OUTk2</td>
<td>$OUTl2</td>
<td>$OUTm2</td>
<td>$OUTn2</td>
<td>$OUTo2</td>
</tr>
-->
</table>" >> $OUTPUT
echo " <h2>IPSec</h2>" >> $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
OUTa1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
#OUTa2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo 'select count(distinct peer_addr) as "Remote Firewalls" from ipsec_tunnels where tunnel_status="active" and tunnel_deleted="0";' > select.sql
OUTb1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
#OUTb2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo 'select count(*) as "active IPSec SAs" from ipsec_tunnels where tunnel_status="active" and tunnel_deleted="0";' > select.sql
OUTc1=$(mysql -u observium -pobservium -D observium < select.sql | tail -n1)
#OUTc2=$(mysql -h 10.140.8.100 -u observium -pobservium -D observium < select.sql | tail -n1)
echo " <table>
<tr>
<td class=tdTopLeftCorner></td>
<td class=tdSpacer rowspan=3></td>
<td>Devices (FW/RTR) with Tunnels</td>
<td class=tdSpacer rowspan=3></td>
<td>Remote Firewalls</td>
<td class=tdSpacer rowspan=3></td>
<td>active IPSec SAs</td>
</tr>
<tr>
<td>RZ</td>
<td>$OUTa1</td>
<td>$OUTb1</td>
<td>$OUTc1</td>
</tr>
<!--
<tr>
<td>FLW</td>
<td>$OUTa2</td>
<td>$OUTb2</td>
<td>$OUTc2</td>
</tr>
-->
</table>
</body>
</html>" >> $OUTPUT
rm select.sql

View File

@@ -0,0 +1,153 @@
#!/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

View File

@@ -0,0 +1,188 @@
#!/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 "<html>
<head>
</head>
<body>
<h1>$CUST1_N Device and Port Report</h1>
<h2>Devices</h2>
<table border='1'>
<tr>
<td>Switches, Router, DWDM</td>
<td>Firewalls (inclusive Cluster)</td>
<td>Firewall Cluster</td>
<td>Wireless</td>
<td>Fibre Channel</td>
</tr>
<tr>
<td>$CUST1_R</td>" > $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 " <td>$CUST1_R</td>" >> $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 " <td>$CUST1_R</td>" >> $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 " <td>$CUST1_R</td>" >> $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 " <td>$CUST1_R</td>" >> $OUTPUT
echo " </tr>
</table>
<h2>Ports</h2>" >> $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 "
<table border='1'>
<tr>
<td>all</td>
</tr>
<tr>
<td>$CUST1_R</td>
</tr>
</table>" >> $OUTPUT
echo "
<h3>Fiber Channel</h3>
<table border='1'>
<tr>
<td>active</td>
<td>non-active</td>
<td>active 4G</td>
<td>non-active 4G</td>
<td>active 8G</td>
<td>non-active 8G</td>
<td>active 16G</td>
<td>non-active 16G</td>
</tr>
<tr>" >> $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 " <td>$CUST1_R</td>" >> $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 " <td>$CUST1_R</td>" >> $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 " <td>$CUST1_R</td>" >> $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 " <td>$CUST1_R</td>" >> $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 " <td>$CUST1_R</td>" >> $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 " <td>$CUST1_R</td>" >> $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 " <td>$CUST1_R</td>" >> $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 " <td>$CUST1_R</td>" >> $OUTPUT
echo " </tr>
</table>" >> $OUTPUT
echo "
<h3>Ethernet</h3>
<table border='1'>
<tr>
<td>active</td>
<td>non-active</td>
<td>active 1G</td>
<td>non-active 1G</td>
<td>active 10G</td>
<td>non-active 10G</td>
</tr>
<tr>" >> $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 " <td>$CUST1_R</td>" >> $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 " <td>$CUST1_R</td>" >> $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 " <td>$CUST1_R</td>" >> $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 " <td>$CUST1_R</td>" >> $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 " <td>$CUST1_R</td>" >> $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 " <td>$CUST1_R</td>" >> $OUTPUT
echo " </tr>
</table>
<h2>IPSec</h2>
<table border='1'>
<tr>
<td>Firewalls, Router with Tunnels</td>
<td>Remote Firewalls</td>
<td>active IPSec SAs</td>
</tr>
<tr>" >> $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 " <td>$CUST1_R</td>" >> $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 " <td>$CUST1_R</td>" >> $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 " <td>$CUST1_R</td>" >> $OUTPUT
echo " </tr>
</table>
</body>
</html>" >> $OUTPUT
rm $SELECT

View File

@@ -0,0 +1,169 @@
<html>
<head>
<style>
table, td {
border: 1px solid black;
border-collapse: collapse;
text-align: center;
}
.tdSpacer {
border-top: 1px solid white;
border-bottom: 1px solid white;
width: 3px;
}
.tdTopLeftCorner {
border: 1px solid white;
border-bottom: 1px solid black;
}
.tdNoBorder {
border: 1px solid white;
}
</style>
</head>
<body>
<h1>Device and Port Report</h1>
<h2>Locations</h2>
<table>
<tr>
<td class=tdTopLeftCorner></td>
<td class=tdSpacer rowspan=3></td>
<td>via snmp</td>
</tr>
<tr>
<td>RZ</td>
<td>8</td>
</tr>
<!--
<tr>
<td>FLW</td>
<td></td>
</tr>
-->
</table>
<h2>Devices</h2>
<table border=0>
<tr>
<td class=tdTopLeftCorner></td>
<td class=tdSpacer rowspan=3></td>
<td>SW/RTR/DWDM</td>
<td class=tdSpacer rowspan=3></td>
<td>Firewalls (inc Cluster)</td>
<td>Firewall Cluster</td>
<td class=tdSpacer rowspan=3></td>
<td>Wireless</td>
<td class=tdSpacer rowspan=3></td>
<td>FibreChannel</td>
</tr>
<tr>
<td>RZ</td>
<td>51</td>
<td>11</td>
<td>4</td>
<td>3</td>
<td>8</td>
</tr>
<!---
<tr>
<td>FLW</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
-->
</table>
<h2>Ports</h2>
<table>
<tr>
<td rowspan=2 class=tdTopLeftCorner></td>
<td rowspan=4 class=tdSpacer></td>
<td rowspan=2>All Ports</td>
<td rowspan=4 class=tdSpacer></td>
<td colspan=8>FibreChannel</td>
<td rowspan=4 class=tdSpacer></td>
<td colspan=8>Ethernet</td>
</tr>
<tr>
<td>active FC</td>
<td>non-active FC</td>
<td>active 4G FC</td>
<td>non-active 4G</td>
<td>active 8G FC</td>
<td>non-active 8G</td>
<td>active 16G FC</td>
<td>non-active 16G</td>
<td>active Ethernet</td>
<td>non-active Ethernet</td>
<td>active Gigabit</td>
<td>non-active Gigabit</td>
<td>active 10Gigabit</td>
<td>non-active 10Gigabit</td>
</tr>
<tr>
<td>RZ</td>
<td>4366</td>
<td>36</td>
<td>164</td>
<td>0</td>
<td>3</td>
<td>34</td>
<td>18</td>
<td>2</td>
<td>0</td>
<td>1232</td>
<td>2061</td>
<td>687</td>
<td>761</td>
<td>373</td>
<td>384</td>
</tr>
<!--
<tr>
<td>FLW</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
-->
</table>
<h2>IPSec</h2>
<table>
<tr>
<td class=tdTopLeftCorner></td>
<td class=tdSpacer rowspan=3></td>
<td>Devices (FW/RTR) with Tunnels</td>
<td class=tdSpacer rowspan=3></td>
<td>Remote Firewalls</td>
<td class=tdSpacer rowspan=3></td>
<td>active IPSec SAs</td>
</tr>
<tr>
<td>RZ</td>
<td>3</td>
<td>49</td>
<td>114</td>
</tr>
<!--
<tr>
<td>FLW</td>
<td></td>
<td></td>
<td></td>
</tr>
-->
</table>
</body>
</html>

View File

@@ -0,0 +1,99 @@
<html>
<head>
</head>
<body>
<h1>VWD Device and Port Report</h1>
<h2>Devices</h2>
<table border='1'>
<tr>
<td>Switches, Router, DWDM</td>
<td>Firewalls (inclusive Cluster)</td>
<td>Firewall Cluster</td>
<td>Wireless</td>
<td>Fibre Channel</td>
</tr>
<tr>
<td>6</td>
<td>1</td>
<td>1</td>
<td>0</td>
<td>0</td>
</tr>
</table>
<h2>Ports</h2>
<table border='1'>
<tr>
<td>all</td>
</tr>
<tr>
<td>527</td>
</tr>
</table>
<h3>Fiber Channel</h3>
<table border='1'>
<tr>
<td>active</td>
<td>non-active</td>
<td>active 4G</td>
<td>non-active 4G</td>
<td>active 8G</td>
<td>non-active 8G</td>
<td>active 16G</td>
<td>non-active 16G</td>
</tr>
<tr>
<td>8</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>8</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
</table>
<h3>Ethernet</h3>
<table border='1'>
<tr>
<td>active</td>
<td>non-active</td>
<td>active 1G</td>
<td>non-active 1G</td>
<td>active 10G</td>
<td>non-active 10G</td>
</tr>
<tr>
<td>87</td>
<td>303</td>
<td>52</td>
<td>280</td>
<td>31</td>
<td>7</td>
</tr>
</table>
<h2>IPSec</h2>
<table border='1'>
<tr>
<td>Firewalls, Router with Tunnels</td>
<td>Remote Firewalls</td>
<td>active IPSec SAs</td>
</tr>
<tr>
<td>1</td>
<td>13</td>
<td>22</td>
</tr>
</table>
</body>
</html>