#!/usr/local/bin/perl use strict; use warnings; my $community = defined($ARGV[0]) ? shift(@ARGV) : die "use: [community] [version] [host] [reboot | savereboot]\n"; my $version = defined($ARGV[0]) ? shift(@ARGV) : die "use: $community [version(read-write)] [host] [reboot | savereboot]\n"; my $host = defined($ARGV[0]) ? shift(@ARGV) : die "use: $community $version [host] [reboot | savereboot]\n"; my $state = defined($ARGV[0]) and ($ARGV[0] eq 'reboot' or $ARGV[0] eq 'savereboot') ? shift(@ARGV) : die "use: $community $version $host [reboot | savereboot]\n"; use Net::SNMP; use constant SNMP_OID_REBOOT => '.1.3.6.1.4.1.11863.6.3.1.1.0'; my $snmp = Net::SNMP->session( -hostname => $host, -community => $community, -version => $version ); defined($snmp) or die $snmp->error() . "\n"; my $result = $snmp->set_request( -varbindlist => [SNMP_OID_REBOOT, INTEGER, $state eq 'reboot' ? 1 : 2]#.INTEGER {notReBoot(0), reboot(1),reBootAndSave(2) } ); defined($result) or die $snmp->error() . "\n"; print "Reboot...\n";