~ubuntu-branches/ubuntu/hardy/net-snmp/hardy-updates

« back to all changes in this revision

Viewing changes to agent/mibgroup/ucd-snmp/diskio.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2007-12-08 14:59:50 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20071208145950-u1tykhpw56nyzqik
Tags: 5.4.1~dfsg-4ubuntu1
* Merge from debian unstable.
* Remaining Ubuntu changes:
  - Remove stop links from rc0 and rc6
  - Munge Maintainer field as per spec.
* Ubuntu changes dropped:
  - Symlink common files between the packages, CDBS ought to handle that
    for us automatically.
* The latest Debian changes has dropped history from the changelog. Slot in
  the Ubuntu changes as best I can. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
282
282
        long_ret = (uint32_t) kio.nwritten;
283
283
        return (u_char *) & long_ret;
284
284
    case DISKIO_NREADX:
285
 
        *var_len = 8;
 
285
        *var_len = sizeof(struct counter64);
286
286
        c64_ret.low = kio.nread & 0xffffffff;;
287
287
        c64_ret.high = kio.nread >> 32;
288
288
        return (u_char *) & c64_ret;
289
289
    case DISKIO_NWRITTENX:
290
 
        *var_len = 8;
 
290
        *var_len = sizeof(struct counter64);
291
291
        c64_ret.low = kio.nwritten & 0xffffffff;;
292
292
        c64_ret.high = kio.nwritten >> 32;
293
293
        return (u_char *) & c64_ret;
608
608
#endif
609
609
        return (u_char *) & long_ret;
610
610
    case DISKIO_NREADX:
611
 
        *var_len = 8;
 
611
        *var_len = sizeof(struct counter64);
612
612
#if defined(freebsd5) && __FreeBSD_version >= 500107
613
613
        longlong_ret = stat->dinfo->devices[indx].bytes[DEVSTAT_READ];
614
614
#else
618
618
        c64_ret.high = longlong_ret >> 32;
619
619
        return (u_char *) & c64_ret;
620
620
    case DISKIO_NWRITTENX:
621
 
        *var_len = 8;
 
621
        *var_len = sizeof(struct counter64);
622
622
#if defined(freebsd5) && __FreeBSD_version >= 500107
623
623
        longlong_ret = stat->dinfo->devices[indx].bytes[DEVSTAT_WRITE];
624
624
#else
737
737
    else {
738
738
        /* See if a 2.4 kernel */
739
739
        char buffer[1024];
 
740
        int rc;
740
741
        parts = fopen("/proc/partitions", "r");
741
742
        if (!parts) {
742
743
            snmp_log_perror("/proc/partitions");
758
759
            }
759
760
            pTemp = &head.indices[head.length];
760
761
 
761
 
            fscanf (parts, "%d %d %lu %s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
 
762
            rc = fscanf (parts, "%d %d %lu %s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
762
763
                    &pTemp->major, &pTemp->minor, &pTemp->blocks, pTemp->name,
763
764
                    &pTemp->rio, &pTemp->rmerge, &pTemp->rsect, &pTemp->ruse,
764
765
                    &pTemp->wio, &pTemp->wmerge, &pTemp->wsect, &pTemp->wuse,
765
766
                    &pTemp->running, &pTemp->use, &pTemp->aveq);
 
767
            if (rc != 15) {
 
768
               snmp_log(LOG_ERR, "diskio.c: cannot find statistics in /proc/partitions\n");
 
769
               return 1;
 
770
            }
766
771
            head.length++;
767
772
        }
768
773
    }
818
823
      long_ret = head.indices[indx].wio;
819
824
      return (u_char *) & long_ret;
820
825
    case DISKIO_NREADX:
821
 
      *var_len = 8;
 
826
      *var_len = sizeof(struct counter64);
822
827
      c64_ret.low = head.indices[indx].rsect * 512 & 0xffffffff;
823
828
      c64_ret.high = head.indices[indx].rsect >> (32 - 9);
824
829
      return (u_char *) & c64_ret;
825
830
    case DISKIO_NWRITTENX:
826
 
      *var_len = 8;
 
831
      *var_len = sizeof(struct counter64);
827
832
      c64_ret.low = head.indices[indx].wsect * 512 & 0xffffffff;
828
833
      c64_ret.high = head.indices[indx].wsect >> (32 - 9);
829
834
      return (u_char *) & c64_ret;
927
932
handle_drive(io_registry_entry_t drive, struct drivestats * dstat)
928
933
{
929
934
    io_registry_entry_t parent;
930
 
    CFDictionaryRef     properties;
 
935
    CFMutableDictionaryRef     properties;
931
936
    CFStringRef         name;
932
937
    CFNumberRef         number;
933
938
    kern_return_t       status;
943
948
    if (IOObjectConformsTo(parent, "IOBlockStorageDriver")) {
944
949
 
945
950
        /* get drive properties */
946
 
        status = IORegistryEntryCreateCFProperties(drive, (CFMutableDictionaryRef *)&properties,
 
951
        status = IORegistryEntryCreateCFProperties(drive, &properties,
947
952
                                            kCFAllocatorDefault, kNilOptions);
948
953
        if (status != KERN_SUCCESS) {
949
954
            snmp_log(LOG_ERR, "diskio: device has no properties\n");
958
963
                                            CFSTR(kIOBSDUnitKey));
959
964
 
960
965
        /* Collect stats and if succesful store them with the name and unitnumber */
961
 
        if (!collect_drive_stats(parent, dstat->stats)) {
 
966
        if (name && number && !collect_drive_stats(parent, dstat->stats)) {
962
967
 
963
968
            CFStringGetCString(name, dstat->name, MAXDRIVENAME, CFStringGetSystemEncoding());
964
969
            CFNumberGetValue(number, kCFNumberSInt32Type, &dstat->bsd_unit_number);
1144
1149
        long_ret = (signed long) 0;     /* AIX has just one value for read/write transfers */
1145
1150
        return (u_char *) & long_ret;
1146
1151
    case DISKIO_NREADX:
1147
 
        *var_len = 8;
 
1152
        *var_len = sizeof(struct counter64);
1148
1153
        c64_ret.low = (ps_disk[indx].rblks * ps_disk[indx].bsize) & 0xffffffff;;
1149
1154
        c64_ret.high = (ps_disk[indx].rblks * ps_disk[indx].bsize) >> 32;
1150
1155
        return (u_char *) & c64_ret;
1151
1156
    case DISKIO_NWRITTENX:
1152
 
        *var_len = 8;
 
1157
        *var_len = sizeof(struct counter64);
1153
1158
        c64_ret.low = (ps_disk[indx].wblks * ps_disk[indx].bsize) & 0xffffffff;;
1154
1159
        c64_ret.high = (ps_disk[indx].wblks * ps_disk[indx].bsize) >> 32;
1155
1160
        return (u_char *) & c64_ret;