Monitor file size through nagios
Andreas Ericsson
ae at op5.se
Tue Apr 28 09:33:29 CEST 2009
asam30 at gmail.com wrote:
> Hi,
>
> I am aware of monitoring disk space using nagios (disk partitions -->
> check_disk). Now, I have a situation that I would like to monitor size of an
> individual file through nagios. Ex,
>
> /var/log/custom-snmpd.log -- > this file will grow very fast and i would
> like to monitor if the size of this file crosses 1.5 G
>
> Is there anyway we can do this?
>
int main(int argc, char **argv)
{
int i;
for (i = 1; i < argc; i++) {
struct stat st;
const char *path = argv[i];
if (stat(path, &st) < 0)
die("Failed to stat %s: %s", path, strerror(errno));
if (st.st_size > 1500 * 1024 * 1024)
critical("Filesize (%d) > %d", st.st_size, 1500 * 1024 * 1024);
}
ok("No file is larger than %d", 1500 * 1024 * 1024);
}
Writing the various helpers is left as an exercise to the reader.
--
Andreas Ericsson andreas.ericsson at op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
Register now for Nordic Meet on Nagios, June 3-4 in Stockholm
http://nordicmeetonnagios.op5.org/
Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.
------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of
expert-led, hands-on workshops and two days of sessions from industry
leaders in dedicated Performance & Operations tracks. Use code vel09scf
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list