aboutsummaryrefslogtreecommitdiffstats
path: root/web/api
diff options
context:
space:
mode:
Diffstat (limited to 'web/api')
-rwxr-xr-xweb/api/public/switch-state2
-rwxr-xr-xweb/api/read/oplog7
-rwxr-xr-xweb/api/write/fap19
-rwxr-xr-xweb/api/write/switches3
4 files changed, 26 insertions, 5 deletions
diff --git a/web/api/public/switch-state b/web/api/public/switch-state
index d192504..2aff40c 100755
--- a/web/api/public/switch-state
+++ b/web/api/public/switch-state
@@ -80,7 +80,7 @@ while ( my $ref = $q->fetchrow_hashref() ) {
$json{'switches'}{$sysname}{vcp}{jnxVirtualChassisPortInOctets} = $data{'vcp'}{'jnxVirtualChassisPortInOctets'};
$json{'switches'}{$sysname}{vcp}{jnxVirtualChassisPortOutOctets} = $data{'vcp'}{'jnxVirtualChassisPortOutOctets'};
- $json{'switches'}{$sysname}{'temp'} = $data{'misc'}{'jnxOperatingTemp'}{'7.1.0.0'} || $data{'misc'}{'ciscoEnvMonTemperatureStatusValue'}{'1011'} || $data{'misc'}{'ciscoEnvMonTemperatureStatusValue'}{'1008'};
+ $json{'switches'}{$sysname}{'temp'} = $data{'misc'}{'jnxOperatingTemp'}{'7.1.0.0'} || $data{'misc'}{'jnxOperatingTemp'}{'7.1.0.0'} || $data{'misc'}{'jnxOperatingTemp'}{'7.2.0.0'} || $data{'misc'}{'jnxOperatingTemp'}{'7.3.0.0'} || $data{'misc'}{'jnxOperatingTemp'}{'7.4.0.0'} || $data{'misc'}{'jnxOperatingTemp'}{'7.5.0.0'} || $data{'misc'}{'jnxOperatingTemp'}{'7.6.0.0'} || $data{'misc'}{'ciscoEnvMonTemperatureStatusValue'}{'1011'} || $data{'misc'}{'ciscoEnvMonTemperatureStatusValue'}{'1008'};
$json{'switches'}{$sysname}{'time'} = $ref->{'time'};
}
diff --git a/web/api/read/oplog b/web/api/read/oplog
index 88a7616..22e21ac 100755
--- a/web/api/read/oplog
+++ b/web/api/read/oplog
@@ -17,9 +17,12 @@ my $query = $nms::web::dbh->prepare('select id,date_trunc(\'second\',time) as ti
$query->execute();
while (my $ref = $query->fetchrow_hashref()) {
my %meh;
+ if (!defined($ref->{'log'})) {
+ next;
+ }
$meh{'time'} = $ref->{'h'} . ":" . $ref->{'m'};
- $meh{'log'} = $ref->{'log'};
- $meh{'username'} = $ref->{'username'};
+ $meh{'log'} = $ref->{'log'} || "weird?";
+ $meh{'username'} = $ref->{'username'} || "undefined";
$meh{'id'} = $ref->{'id'};
$meh{'systems'} = $ref->{'systems'};
$meh{'timestamp'} = $ref->{'timestamp'};
diff --git a/web/api/write/fap b/web/api/write/fap
new file mode 100755
index 0000000..69058eb
--- /dev/null
+++ b/web/api/write/fap
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+fil=/var/log/apache2/kek
+echo 'Content-Type: text/html'
+echo
+echo
+pw="<REDACTED>"
+sw=$(echo $PATH_INFO | sed 's/^\///')
+POST -H'Content-Type: application/json' https://gondul:${pw}@awx.tg23.gathering.org/api/v2/job_templates/19/launch/ >/dev/null 2>&1 <<_EOF_
+{"credential_passwords":{},"limit":"$sw","extra_vars":{}}
+_EOF_
+ret=$?
+./oplog >/dev/null 2>&1 <<_EOF_
+{"systems": "$sw", "log": "Refap queued in AWX for $sw"}
+_EOF_
+while read; do
+ true
+done
+echo '"ok"'
diff --git a/web/api/write/switches b/web/api/write/switches
index e0ee950..470cde1 100755
--- a/web/api/write/switches
+++ b/web/api/write/switches
@@ -23,7 +23,6 @@ my @dups;
my $sth = $nms::web::dbh->prepare("SELECT sysname FROM switches WHERE sysname=?");
-
my @fields = ( 'community', 'tags', 'distro_name', 'distro_phy_port', 'mgmt_v4_addr', 'mgmt_v6_addr', 'mgmt_vlan', 'placement', 'poll_frequency', 'sysname', 'traffic_vlan', 'deleted');
sub convertplace
@@ -112,7 +111,7 @@ foreach my $tmp2 (@tmp) {
push @set, "$_=" . $dbh->quote($switch{$_});
}
} keys %switch;
- $nms::web::dbh->do("UPDATE SWITCHES SET " . join(", ", @set) . "WHERE sysname=" . $dbh->quote($switch{'sysname'}) . ";");
+ $nms::web::dbh->do("UPDATE SWITCHES SET " . join(", ", @set) . " WHERE sysname=" . $dbh->quote($switch{'sysname'}) . ";");
push @dups, $switch{'sysname'};
}
}