Subversion Repositories vnag

Rev

Rev 44 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
44 daniel-mar 1
<?php /* <ViaThinkSoftSignature>
46 daniel-mar 2
DoLNft7Sdu3ePi+nSXN2sn1rZfmAxotlrnJdcyD/sLEQIXP9r0TYkhkPeQhns9gAy
3
A8gheT9CYyZ89Wa9eAAanbapthrk6rFk/A3xKxVVGe1ieqlEefmkPPs98eMkLlAyw
4
HpDFLR9aplZH714N2QqHazvVM2tl5nu/POgSJoPcAIlAyj0O70zTUuh5muRA1kJRF
5
sp0E7dEulwOYLb2+UBiKhzmcIe1ixJvVsJzrroK6LHwGvUmES54EVfRu0hVkkrUBv
6
j5LF0uDTWLeDudPbJK+oldLM6KRA06EBSkKQZxfTPMpDkEk3I76rojAnjm8Cp9/bI
7
G5uyU1YrEBJOpo8tIJWqI8GFs6dRDVVQXnLNz2TZHDSeuL2Ij5LCBk3RnUDSzzFni
8
/YAcu9HkM6706NylZJ0IR1z3GmUAlRnGN/sGaophcvpzPm+RAhOpr3H7N2/IxXPdl
9
VUsL5Q95LmBFCXPDRIqQmhhqDS+HO6aoYrxu8pEvd3JdQjh616XLWQDeHHtl1x6cE
10
SszyAzeVpCSyEyNzk7Bn9ypIZqO+/pauLraS1xL3Xt/xCGQvzYZAVjtoln2y/nbqO
11
vKBBZdXRXXCOExCbZB/u8sp/Wc0vua/qWoONWx+YtDjySUXdEs/JF0ZGEVndRym0r
12
4TfM7GJposp+kz/NKbQ1Kh+UnSMk6L5y/I4xMWAuBTCpQ9zl0yDpFvLzeOvsH3Etr
13
WeACWabnH6GVXWlI/JyAVThHWHrog+no7/OSIymRBHgRwsRu/87qW1aZVB2H05jW9
14
PlnCBNF7nz3XgDaBac1W02YeHc9hYv9uOjeMX9nEI7W3gDoO/Mn/PrTaEvB0UO50k
15
/ZHh7k5nQqZKq20kmfgEbII6Rtn9pUZNAmKEpwEMV9Hg3gRpNrvG+ZCw48ts1+P/T
16
6tsshOByw4o3gRa88tr/LSlGR47EzAdYotq1ZleoWYt5Nc2kJmM29xOc5PVLP5mrY
17
QecXl7IL35JFzyazi0z/QX4e2VyI/llLcMI767Oq1dckhXlf1YpE0yG3O4bRzDvf3
18
tH2aWeuhREviasvFK5UUQAc0mWmFuklB35i/v4x+/63sB3zUjHitqI/L+mpjxHTtz
19
km6KpaBKFQ0UeYnH+zuX9ttjDi8yxTxp7i73ZU0KcOD7KT6aTztSyKTwvyfyVzi7A
20
81q88rMWDPioVHW/XE32/T2VDuD4RuhC30T2bKQtMPqGcSs0xnNlGGaGjPKkxEVxQ
21
K6CIAO1fi4B9FH7R/GqY+nbJ6I3eazIE294xbKTp+5DbR6hJ0rC8f7UL9mkyyHeHW
22
3BQiZndJkv0akOtd+CaWii1bNucrPuAdVm6icwk1WPOorjdZoAgZSRSFIUf/05bRT
23
Q==
44 daniel-mar 24
</ViaThinkSoftSignature> */ ?>
25
<?php
26
 
27
/*
28
 * VNag - Nagios Framework for PHP
29
 * Developed by Daniel Marschall, ViaThinkSoft <www.viathinksoft.com>
30
 * Licensed under the terms of the Apache 2.0 license
31
 *
32
 * Revision 2022-01-12
33
 */
34
 
35
declare(ticks=1);
36
 
37
class VNagAastra430VoiceMail extends VNag {
38
        protected $argFtpHostname = null;
39
        protected $argFtpUsername = null;
40
        protected $argFtpPassword = null;
41
 
42
        const DEFAULT_USERNAME = 'admin';
43
        const DEFAULT_PASSWORD = '33aastra'; // https://productdocuments.mitel.com/doc_finder/DocFinder/syd-0343_de.pdf?get&DNR=syd-0343?get&DNR=syd-0343 , Page 178
44
 
45
        public function __construct() {
46
                parent::__construct();
47
 
48
                if ($this->is_http_mode()) {
49
                        // Don't allow the standard arguments via $_REQUEST
50
                        $this->registerExpectedStandardArguments('');
51
                } else {
52
                        $this->registerExpectedStandardArguments('Vht');
53
                }
54
                $this->addExpectedArgument($this->argFtpHostname = new VNagArgument('H', 'ftphostname', VNagArgument::VALUE_REQUIRED, 'ftphostname', 'The FTP hostname', null));
55
                $this->addExpectedArgument($this->argFtpUsername = new VNagArgument('u', 'ftpusername', VNagArgument::VALUE_REQUIRED, 'ftpusername', 'The FTP username (usually "'.self::DEFAULT_USERNAME.'")', self::DEFAULT_USERNAME));
56
                $this->addExpectedArgument($this->argFtpPassword = new VNagArgument('p', 'ftppassword', VNagArgument::VALUE_REQUIRED, 'ftppassword', 'The FTP password (default "'.self::DEFAULT_PASSWORD.'")', self::DEFAULT_PASSWORD));
57
 
58
                $this->getHelpManager()->setPluginName('vnag_aastra_430_voicemail');
59
                $this->getHelpManager()->setVersion('1.0');
60
                $this->getHelpManager()->setShortDescription('This plugin checks for voicemail messages on a Aastra 430.');
61
                $this->getHelpManager()->setCopyright('Copyright (C) 2011-$CURYEAR$ Daniel Marschall, ViaThinkSoft.');
62
                $this->getHelpManager()->setSyntax('$SCRIPTNAME$ -H <ftphost> -u <ftpusername> -p <ftppassword>');
63
                $this->getHelpManager()->setFootNotes('If you encounter bugs, please contact ViaThinkSoft at www.viathinksoft.com');
64
        }
65
 
66
        protected static function aastra430NumVm($ftp_host, $user, $password) {
46 daniel-mar 67
                if (!($conn = @ftp_connect($ftp_host))) throw new Exception('FTP connect failed');
68
                if (!@ftp_login($conn, $user, $password)) throw new Exception('FTP login failed');
44 daniel-mar 69
 
70
                // TODO: Only count vm*.dat
71
                // TODO: Also check timestamp of oldest and newest message!
72
 
73
                $messages = @ftp_nlist($conn, '/home/voice/vm/gen'); // the files are named vm*.dat
46 daniel-mar 74
                if (!is_array($messages)) throw new Exception('FTP folder not found!');
44 daniel-mar 75
                $count = count($messages);
76
                @ftp_close($conn);
77
                return $count;
78
        }
79
 
80
        protected function cbRun() {
81
                $this->argFtpHostname->require();
82
                // $this->argFtpUsername->require();
83
                // $this->argFtpPassword->require();
84
 
85
                $ftp_hostname = $this->argFtpHostname->getValue();
86
                $ftp_username = $this->argFtpUsername->getValue();
87
                $ftp_password = $this->argFtpPassword->getValue();
88
 
89
                $count = self::aastra430NumVm($ftp_hostname, $ftp_username, $ftp_password);
90
 
91
                $this->setStatus("$count new voicemail messsages", true);
92
                if ($count == 0) {
93
                        $this->setStatus(VNag::STATUS_OK);
94
                } else {
95
                        $this->setStatus(VNag::STATUS_WARNING);
96
                }
97
        }
46 daniel-mar 98
}